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,EAAE,EAAE,CAAC;YACtC,IAAI,sBAAsB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,WAAW,GAAG,OAAO,CAAC,yBAAyB,CACjD,sBAAsB,CACvB,CAAC;YACF,IAAI,MAAM,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;gBAC3B,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,kEAAkE;IAClE,MAAM,CAAC,QAAQ,CAAC,SAAiB,EAAE,WAAmB;QACpD,IAAI,gBAAgB,GAAmB,CACrC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,WAAW,CAAC,CACrD,CAAC;QACF,IAAI,KAAK,GAAG,QAAQ,CAAC,sBAAsB,CACzC,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAChC,CAAC;QACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,IAAI,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;gBACnE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CAqDF","file":"daytool_injector.js","sourcesContent":["import { reset_casting } from \"../../helpers.js\";\r\nimport { DAYTOOL } from \"../daytool.js\";\r\nimport {\r\n daytool_case,\r\n daytool_entity,\r\n daytool_event,\r\n daytool_feed,\r\n daytool_goal,\r\n daytool_need,\r\n daytool_note,\r\n daytool_person,\r\n daytool_plan,\r\n daytool_stat,\r\n} from \"../daytool_entity.js\";\r\nimport { daytool_ui } from \"../daytool_ui.js\";\r\nimport { reset_actions } from \"./daytool_actions.js\";\r\nimport { daytool_templates } from \"./daytool_templates.js\";\r\n\r\nexport class daytool_injector {\r\n static addToListDOM(\r\n entity:\r\n | daytool_need\r\n | daytool_event\r\n | daytool_goal\r\n | daytool_case\r\n | daytool_feed\r\n | daytool_note\r\n | daytool_stat\r\n | daytool_person\r\n | daytool_plan\r\n ) {\r\n var list_DOM: HTMLElement = (\r\n document.getElementById(\"list_\" + entity.type)\r\n );\r\n var casted_entity = reset_casting([entity])[0];\r\n var newElement = document.createElement(\"div\");\r\n if (casted_entity instanceof daytool_need) {\r\n var initialize_slides = ``;\r\n if (list_DOM.children.length == 0) {\r\n initialize_slides = `active`;\r\n }\r\n newElement.innerHTML = daytool_templates.Clipboard(\"\", casted_entity);\r\n list_DOM.append(newElement.childNodes[0]);\r\n var child = list_DOM.querySelector('.entity_clipboard[data-entity-id=\"'+entity.id+'\"][data-entity-type=\"'+entity.type+'\"]');\r\n reset_actions(child);\r\n child.classList.remove(\"fadeOut\");\r\n } else {\r\n newElement.innerHTML = daytool_templates.Card(\"\", entity);\r\n list_DOM.prepend(newElement.childNodes[0]);\r\n var child = list_DOM.querySelector('.entity_card[data-entity-id=\"'+entity.id+'\"][data-entity-type=\"'+entity.type+'\"]');\r\n reset_actions(child);\r\n setTimeout(() => {\r\n child.scrollIntoView({\r\n behavior: \"smooth\", // Smooth scrolling animation\r\n block: \"nearest\", // Ensures minimal scrolling\r\n });\r\n }, 700);\r\n }\r\n }\r\n static addToClipboardDOM(\r\n entity:\r\n | daytool_need\r\n | daytool_event\r\n | daytool_goal\r\n | daytool_case\r\n | daytool_feed\r\n | daytool_note\r\n | daytool_stat\r\n | daytool_person\r\n | daytool_plan\r\n ) {\r\n if (entity.type !== \"needs\") {\r\n var newElement = document.createElement(\"div\");\r\n newElement.innerHTML = daytool_templates.Clipboard(\"\", entity);\r\n document.getElementById(\"clipboard\").prepend(newElement.childNodes[0]);\r\n var child = (\r\n document.getElementById(\"clipboard\").querySelector(\".entity_clipboard\")\r\n );\r\n reset_actions(child);\r\n child.classList.remove(\"fadeIn\");\r\n\r\n var card = (\r\n document.querySelector(\r\n `.entity_card[data-entity-id=\"${entity.id}\"][data-entity-type=\"${entity.type}\"]`\r\n )\r\n );\r\n setTimeout(() => {\r\n child.scrollIntoView({\r\n behavior: \"smooth\", // Smooth scrolling animation\r\n block: \"start\", // Ensures minimal scrolling\r\n });\r\n }, 700);\r\n }\r\n }\r\n\r\n static confirm_pulse(completed: boolean) {\r\n daytool_ui.switchModalView(\"confirm_pulse_modal\");\r\n if (completed == false) {\r\n setTimeout(function () {\r\n window.open(\"/pulse\", \"_blank\");\r\n }, 2500);\r\n }\r\n }\r\n\r\n static fetchEntityLinks(entity: daytool_entity) {\r\n var items_to_return: any[] = [];\r\n var links = entity.links;\r\n for (var l = 0; l < links.length; l++) {\r\n var current_link_entity_id = links[l];\r\n items_to_return.push(\r\n DAYTOOL.getEntityByObjectEntityId(current_link_entity_id)\r\n );\r\n }\r\n return items_to_return;\r\n }\r\n\r\n static fetchEntityNotes(entity: daytool_entity) {\r\n var items_to_return: any[] = [];\r\n var links = entity.links;\r\n for (var l = 0; l < links.length; l++) {\r\n var current_link_entity_id = links[l];\r\n var this_entity = DAYTOOL.getEntityByObjectEntityId(\r\n current_link_entity_id\r\n );\r\n if (entity.type == \"notes\") {\r\n items_to_return.push(this_entity);\r\n }\r\n }\r\n return items_to_return;\r\n }\r\n // Finds and returns existing daytool checklist entity DOM or null\r\n static fetchDOM(entity_id: number, entity_type: string) {\r\n var checklist_entity = (\r\n DAYTOOL.getEntityByIdAndType(entity_id, entity_type)\r\n );\r\n var cards = document.getElementsByClassName(\r\n \"card \" + checklist_entity.type\r\n );\r\n for (var c = 0; c < cards.length; c++) {\r\n if (entity_id == parseInt(cards[c].getAttribute(\"data-entity-id\"))) {\r\n return cards[c];\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n // getEventCells(repetition_number: number | null): HTMLElement[] {\r\n // var ecs = document.getElementsByClassName(\"ec\");\r\n // var cells_to_return: HTMLElement[] = [];\r\n // for (var x = ecs.length - 1; x > -1; x--) {\r\n // var ec = ecs[x];\r\n // if (ec instanceof HTMLElement) {\r\n // var current_event_cell_entity_id = parseInt(\r\n // ec.getAttribute(\"data-entity-id\")\r\n // );\r\n // var current_event_cell_repetition_number = parseInt(\r\n // ec.getAttribute(\"data-repetition-number\")\r\n // );\r\n // if (current_event_cell_entity_id == this.id) {\r\n // if (\r\n // (repetition_number != null &&\r\n // current_event_cell_repetition_number == repetition_number) ||\r\n // repetition_number == null\r\n // ) {\r\n // cells_to_return.push(ec);\r\n // }\r\n // }\r\n // }\r\n // }\r\n // return cells_to_return;\r\n // }\r\n\r\n // getEventCellsById(event_id: number, repetition_number: number) {\r\n // var current_event_cells: HTMLElement[] = [];\r\n // var current_day_events = document.getElementsByClassName(\"ec\");\r\n // for (var i = 0; i < current_day_events.length; i++) {\r\n // var current_event_cell = current_day_events[i];\r\n // if (\r\n // current_event_cell instanceof HTMLElement &&\r\n // current_event_cell.getAttribute(\"event_id\") == event_id.toString()\r\n // ) {\r\n // // If repetition_number is provided - get return array with specific\r\n // if (\r\n // repetition_number > 0 &&\r\n // current_event_cell.getAttribute(\"data-repetition-number\") ==\r\n // repetition_number.toString()\r\n // ) {\r\n // current_event_cells.push(current_event_cell);\r\n // return current_event_cells;\r\n // //\r\n // } else if (!repetition_number) {\r\n // current_event_cells.push(current_event_cell);\r\n // }\r\n // }\r\n // }\r\n // return current_event_cells;\r\n // }\r\n}\r\n"]}