{"version":3,"file":"CommentItem-DPieWrkL.mjs","names":[],"sources":["../src/components/display/comments/item/CommentItem.vue","../src/components/display/comments/item/CommentItem.vue"],"sourcesContent":["<template>\n  <div\n    class=\"d-flex flex-column flex-grow-1 w-100 really-light-secondary-bg\"\n    :class=\"isAnAnswer && !isFlatList ? 'my-1 p-0' : 'my-3 p-2'\"\n  >\n    <div class=\"d-flex flex-nowrap justify-content-between align-items-center\">\n      <CommentBasicView :comment=\"comment\" :edit-right=\"editRight\" />\n      <CommentMoreActions\n        v-model:comment=\"commentForVmodel\"\n        :edit-right=\"editRight\"\n        :podcast=\"podcast\"\n        :config=\"config\"\n        @delete-comment=\"emitDeleteComment\"\n      />\n    </div>\n    <template v-if=\"isValidComment\">\n      <div class=\"d-flex align-items-center mt-1\">\n        <LikeSection\n          v-model:comment=\"commentForVmodel\"\n          :edit-right=\"editRight\"\n          :podcast=\"podcast\"\n        />\n        <button\n          v-if=\"!comment.answerTo && canPostComment\"\n          class=\"btn btn-transparent\"\n          @click=\"answerComment\"\n        >\n          {{ t(\"To answer\") }}\n        </button>\n        <button\n          v-if=\"isFlatList && comment.answerTo\"\n          class=\"btn btn-transparent d-flex align-items-center\"\n          @click=\"showParentComment = !showParentComment\"\n        >\n          {{ t(\"In response to\") }}\n          <ChevronDownIcon :class=\"{ 'arrow-transform': showParentComment }\" />\n        </button>\n      </div>\n      <CommentInput\n        v-if=\"isAnsweringComment && canPostComment\"\n        class=\"ms-4\"\n        :focus=\"focus\"\n        :podcast=\"podcast\"\n        :in-answer-comment=\"comment\"\n        @cancel-action=\"isAnsweringComment = false\"\n        @new-comment=\"newComment\"\n      />\n      <div\n        v-if=\"comment.responses?.length && !isFlatList\"\n        class=\"ms-4 mt-2 answers-section\"\n      >\n        <button\n          class=\"d-flex align-items-center btn-transparent text-primary\"\n          @click=\"showAnswers = !showAnswers\"\n        >\n          <ChevronDownIcon :class=\"{ 'arrow-transform': showAnswers }\" />\n          {{ t(\"nb answers\", { nb: comment.responses.length }) }}\n        </button>\n        <CommentList\n          v-if=\"showAnswers\"\n          ref=\"commentList\"\n          :podcast=\"podcast\"\n          :size=\"5\"\n          :answer-to-comment=\"comment.commentId\"\n          :config=\"config\"\n          :event-to-handle=\"eventToHandle\"\n          @comment-deleted=\"updateForAnswerDeleted\"\n        />\n      </div>\n    </template>\n    <CommentParentInfo\n      v-if=\"showParentComment\"\n      class=\"ms-4\"\n      :comment-id=\"comment.answerTo\"\n      :edit-right=\"editRight\"\n    />\n  </div>\n</template>\n\n<script setup lang=\"ts\">\nimport ChevronDownIcon from \"vue-material-design-icons/ChevronDown.vue\";\nimport { CommentPodcast } from \"@/stores/class/general/comment\";\nimport { Podcast } from \"../../../../stores/class/general/podcast\";\nimport CommentBasicView from \"./CommentBasicView.vue\";\nimport { useCommentStore } from \"../../../../stores/CommentStore\";\nimport { useAuthStore } from \"../../../../stores/AuthStore\";\nimport { defineAsyncComponent, ref, Ref, computed } from \"vue\";\nimport {\n  CommentMessage,\n  CommentsConfig,\n} from \"../../../../stores/class/config/commentsConfig\";\nimport { useI18n } from \"vue-i18n\";\nconst CommentInput = defineAsyncComponent(() => import(\"../CommentInput.vue\"));\nconst CommentParentInfo = defineAsyncComponent(\n  () => import(\"../CommentParentInfo.vue\"),\n);\nconst LikeSection = defineAsyncComponent(\n  () => import(\"../like/LikeSection.vue\"),\n);\nconst CommentMoreActions = defineAsyncComponent(\n  () => import(\"./CommentMoreActions.vue\"),\n);\nconst CommentList = defineAsyncComponent(() => import(\"../CommentList.vue\"));\n\n\n//Props \nconst props = defineProps({\n  comment: { default: () => ({}), type: Object as () => CommentPodcast },\n  podcast: { default: undefined, type: Object as () => Podcast },\n  isFlatList: { default: false, type: Boolean },\n  config: { default: undefined, type: Object as () => CommentsConfig },\n  organisationId: { default: undefined, type: String },\n})\n\n//Emits\nconst emit = defineEmits([\"deleteComment\", \"update:comment\"]);\n\n//Data \nconst isAnsweringComment = ref(false);\nconst showAnswers = ref(false);\nconst focus = ref(false);\nconst showParentComment = ref(false);\nconst eventToHandle : Ref<CommentMessage | undefined>= ref(undefined);\n\n//Composables\nconst { t } = useI18n();\nconst authStore = useAuthStore();\nconst commentStore = useCommentStore();\n\n\n//Computed\nconst commentForVmodel = computed({\n  get(): CommentPodcast {\n    return props.comment;\n  },\n  set(value: CommentPodcast) {\n    if (!eventActive.value) {\n      emit(\"update:comment\", value);\n    }\n  },\n});\nconst isAnAnswer = computed(() => undefined !== props.comment.answerTo);\nconst editRight = computed(() => {\n  return (\n    (true === authStore.isRoleComments &&\n      (authStore.authOrgaId === props.podcast?.organisation.id ||\n      authStore.authOrgaId === props.organisationId)) ||\n    true === authStore.isRoleAdmin\n  );\n});\nconst isValidComment = computed(() => \"VALIDATED\" === props.comment.state);\nconst canPostComment = computed(() => {\n  return commentStore.getCanPostComment(\n    props.config,\n    props.podcast,\n    undefined !== authStore.authOrgaId,\n  );\n});\nconst eventActive = computed(() => undefined !== props.podcast?.conferenceId);\n\n \n//Methods\nfunction answerComment(): void {\n  isAnsweringComment.value = true;\n  focus.value = !focus.value;\n}\nfunction newComment(comment: CommentPodcast): void {\n  modifyAnswerNumber(comment.commentId);\n  if (!eventActive.value) {\n    eventToHandle.value = { type: \"CREATE\", comment: comment };\n  }\n  isAnsweringComment.value = false;\n}\nfunction modifyAnswerNumber(commentId: number, isAdd = true) {\n  const commentToEdit = props.comment;\n  if (commentToEdit.responses) {\n    if (isAdd) {\n      commentToEdit.responses.push(commentId);\n    } else {\n      const index = commentToEdit.responses.indexOf(commentId);\n      if (index !== -1) {\n        commentToEdit.responses.splice(index, 1);\n      }\n    }\n  } else if (isAdd) {\n    commentToEdit.responses = [commentId];\n  }\n  emit(\"update:comment\", commentToEdit);\n}\nfunction emitDeleteComment() {\n  if (!eventActive.value) {\n    emit(\"deleteComment\");\n  }\n}\nfunction receiveEvent(event: CommentMessage) {\n  if (\"CREATE\" === event.type) {\n    modifyAnswerNumber(event.comment.commentId);\n  } else if (\"DELETE\" === event.type) {\n    modifyAnswerNumber(event.comment.commentId, false);\n  }\n  eventToHandle.value = event;\n}\nfunction updateForAnswerDeleted(commentId: number) {\n  modifyAnswerNumber(commentId, false);\n}\n//Expose\ndefineExpose({\n  receiveEvent\n});\n</script>\n","<template>\n  <div\n    class=\"d-flex flex-column flex-grow-1 w-100 really-light-secondary-bg\"\n    :class=\"isAnAnswer && !isFlatList ? 'my-1 p-0' : 'my-3 p-2'\"\n  >\n    <div class=\"d-flex flex-nowrap justify-content-between align-items-center\">\n      <CommentBasicView :comment=\"comment\" :edit-right=\"editRight\" />\n      <CommentMoreActions\n        v-model:comment=\"commentForVmodel\"\n        :edit-right=\"editRight\"\n        :podcast=\"podcast\"\n        :config=\"config\"\n        @delete-comment=\"emitDeleteComment\"\n      />\n    </div>\n    <template v-if=\"isValidComment\">\n      <div class=\"d-flex align-items-center mt-1\">\n        <LikeSection\n          v-model:comment=\"commentForVmodel\"\n          :edit-right=\"editRight\"\n          :podcast=\"podcast\"\n        />\n        <button\n          v-if=\"!comment.answerTo && canPostComment\"\n          class=\"btn btn-transparent\"\n          @click=\"answerComment\"\n        >\n          {{ t(\"To answer\") }}\n        </button>\n        <button\n          v-if=\"isFlatList && comment.answerTo\"\n          class=\"btn btn-transparent d-flex align-items-center\"\n          @click=\"showParentComment = !showParentComment\"\n        >\n          {{ t(\"In response to\") }}\n          <ChevronDownIcon :class=\"{ 'arrow-transform': showParentComment }\" />\n        </button>\n      </div>\n      <CommentInput\n        v-if=\"isAnsweringComment && canPostComment\"\n        class=\"ms-4\"\n        :focus=\"focus\"\n        :podcast=\"podcast\"\n        :in-answer-comment=\"comment\"\n        @cancel-action=\"isAnsweringComment = false\"\n        @new-comment=\"newComment\"\n      />\n      <div\n        v-if=\"comment.responses?.length && !isFlatList\"\n        class=\"ms-4 mt-2 answers-section\"\n      >\n        <button\n          class=\"d-flex align-items-center btn-transparent text-primary\"\n          @click=\"showAnswers = !showAnswers\"\n        >\n          <ChevronDownIcon :class=\"{ 'arrow-transform': showAnswers }\" />\n          {{ t(\"nb answers\", { nb: comment.responses.length }) }}\n        </button>\n        <CommentList\n          v-if=\"showAnswers\"\n          ref=\"commentList\"\n          :podcast=\"podcast\"\n          :size=\"5\"\n          :answer-to-comment=\"comment.commentId\"\n          :config=\"config\"\n          :event-to-handle=\"eventToHandle\"\n          @comment-deleted=\"updateForAnswerDeleted\"\n        />\n      </div>\n    </template>\n    <CommentParentInfo\n      v-if=\"showParentComment\"\n      class=\"ms-4\"\n      :comment-id=\"comment.answerTo\"\n      :edit-right=\"editRight\"\n    />\n  </div>\n</template>\n\n<script setup lang=\"ts\">\nimport ChevronDownIcon from \"vue-material-design-icons/ChevronDown.vue\";\nimport { CommentPodcast } from \"@/stores/class/general/comment\";\nimport { Podcast } from \"../../../../stores/class/general/podcast\";\nimport CommentBasicView from \"./CommentBasicView.vue\";\nimport { useCommentStore } from \"../../../../stores/CommentStore\";\nimport { useAuthStore } from \"../../../../stores/AuthStore\";\nimport { defineAsyncComponent, ref, Ref, computed } from \"vue\";\nimport {\n  CommentMessage,\n  CommentsConfig,\n} from \"../../../../stores/class/config/commentsConfig\";\nimport { useI18n } from \"vue-i18n\";\nconst CommentInput = defineAsyncComponent(() => import(\"../CommentInput.vue\"));\nconst CommentParentInfo = defineAsyncComponent(\n  () => import(\"../CommentParentInfo.vue\"),\n);\nconst LikeSection = defineAsyncComponent(\n  () => import(\"../like/LikeSection.vue\"),\n);\nconst CommentMoreActions = defineAsyncComponent(\n  () => import(\"./CommentMoreActions.vue\"),\n);\nconst CommentList = defineAsyncComponent(() => import(\"../CommentList.vue\"));\n\n\n//Props \nconst props = defineProps({\n  comment: { default: () => ({}), type: Object as () => CommentPodcast },\n  podcast: { default: undefined, type: Object as () => Podcast },\n  isFlatList: { default: false, type: Boolean },\n  config: { default: undefined, type: Object as () => CommentsConfig },\n  organisationId: { default: undefined, type: String },\n})\n\n//Emits\nconst emit = defineEmits([\"deleteComment\", \"update:comment\"]);\n\n//Data \nconst isAnsweringComment = ref(false);\nconst showAnswers = ref(false);\nconst focus = ref(false);\nconst showParentComment = ref(false);\nconst eventToHandle : Ref<CommentMessage | undefined>= ref(undefined);\n\n//Composables\nconst { t } = useI18n();\nconst authStore = useAuthStore();\nconst commentStore = useCommentStore();\n\n\n//Computed\nconst commentForVmodel = computed({\n  get(): CommentPodcast {\n    return props.comment;\n  },\n  set(value: CommentPodcast) {\n    if (!eventActive.value) {\n      emit(\"update:comment\", value);\n    }\n  },\n});\nconst isAnAnswer = computed(() => undefined !== props.comment.answerTo);\nconst editRight = computed(() => {\n  return (\n    (true === authStore.isRoleComments &&\n      (authStore.authOrgaId === props.podcast?.organisation.id ||\n      authStore.authOrgaId === props.organisationId)) ||\n    true === authStore.isRoleAdmin\n  );\n});\nconst isValidComment = computed(() => \"VALIDATED\" === props.comment.state);\nconst canPostComment = computed(() => {\n  return commentStore.getCanPostComment(\n    props.config,\n    props.podcast,\n    undefined !== authStore.authOrgaId,\n  );\n});\nconst eventActive = computed(() => undefined !== props.podcast?.conferenceId);\n\n \n//Methods\nfunction answerComment(): void {\n  isAnsweringComment.value = true;\n  focus.value = !focus.value;\n}\nfunction newComment(comment: CommentPodcast): void {\n  modifyAnswerNumber(comment.commentId);\n  if (!eventActive.value) {\n    eventToHandle.value = { type: \"CREATE\", comment: comment };\n  }\n  isAnsweringComment.value = false;\n}\nfunction modifyAnswerNumber(commentId: number, isAdd = true) {\n  const commentToEdit = props.comment;\n  if (commentToEdit.responses) {\n    if (isAdd) {\n      commentToEdit.responses.push(commentId);\n    } else {\n      const index = commentToEdit.responses.indexOf(commentId);\n      if (index !== -1) {\n        commentToEdit.responses.splice(index, 1);\n      }\n    }\n  } else if (isAdd) {\n    commentToEdit.responses = [commentId];\n  }\n  emit(\"update:comment\", commentToEdit);\n}\nfunction emitDeleteComment() {\n  if (!eventActive.value) {\n    emit(\"deleteComment\");\n  }\n}\nfunction receiveEvent(event: CommentMessage) {\n  if (\"CREATE\" === event.type) {\n    modifyAnswerNumber(event.comment.commentId);\n  } else if (\"DELETE\" === event.type) {\n    modifyAnswerNumber(event.comment.commentId, false);\n  }\n  eventToHandle.value = event;\n}\nfunction updateForAnswerDeleted(commentId: number) {\n  modifyAnswerNumber(commentId, false);\n}\n//Expose\ndefineExpose({\n  receiveEvent\n});\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4FA,MAAM,eAAe,2BAA2B,OAAO,8BAAsB;EAC7E,MAAM,oBAAoB,2BAClB,OAAO,mCACf;EACA,MAAM,cAAc,2BACZ,OAAO,6BACf;EACA,MAAM,qBAAqB,2BACnB,OAAO,oCACf;EACA,MAAM,cAAc,2BAA2B,OAAO,6BAAqB;EAI3E,MAAM,QAAQ;EASd,MAAM,OAAO;EAGb,MAAM,qBAAqB,IAAI,KAAK;EACpC,MAAM,cAAc,IAAI,KAAK;EAC7B,MAAM,QAAQ,IAAI,KAAK;EACvB,MAAM,oBAAoB,IAAI,KAAK;EACnC,MAAM,gBAAiD,IAAI,KAAA,CAAS;EAGpE,MAAM,EAAE,MAAM,QAAQ;EACtB,MAAM,YAAY,aAAa;EAC/B,MAAM,eAAe,gBAAgB;EAIrC,MAAM,mBAAmB,SAAS;GAChC,MAAsB;IACpB,OAAO,MAAM;GACf;GACA,IAAI,OAAuB;IACzB,IAAI,CAAC,YAAY,OACf,KAAK,kBAAkB,KAAK;GAEhC;EACF,CAAC;EACD,MAAM,aAAa,eAAe,KAAA,MAAc,MAAM,QAAQ,QAAQ;EACtE,MAAM,YAAY,eAAe;GAC/B,OACG,SAAS,UAAU,mBACjB,UAAU,eAAe,MAAM,SAAS,aAAa,MACtD,UAAU,eAAe,MAAM,mBACjC,SAAS,UAAU;EAEvB,CAAC;EACD,MAAM,iBAAiB,eAAe,gBAAgB,MAAM,QAAQ,KAAK;EACzE,MAAM,iBAAiB,eAAe;GACpC,OAAO,aAAa,kBAClB,MAAM,QACN,MAAM,SACN,KAAA,MAAc,UAAU,UAC1B;EACF,CAAC;EACD,MAA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