{"version":3,"file":"usePodcastView-CImOmif2.mjs","names":[],"sources":["../src/components/composable/podcasts/usePodcastView.ts"],"sourcesContent":["import { Conference } from '@/stores/class/conference/conference';\nimport { Podcast } from '@/stores/class/general/podcast';\n// @ts-expect-error Bibliothèque non typée\nimport humanizeDuration from \"humanize-duration\";\nimport {computed, Ref} from 'vue';\nimport { useI18n } from 'vue-i18n';\nimport {useOrgaComputed} from \"../useOrgaComputed\"\nimport { state } from '../../../stores/ParamSdkStore';\nimport { useDayjs } from '../useDayjs';\n\nexport const usePodcastView = (podcast: Ref<Podcast|undefined>,  podcastConference: Ref<Conference|undefined>)=>{\n\n  const {locale} = useI18n();\n  const { dayjs } = useDayjs();\n\n  const {isEditRights, isPodcastmaker} = useOrgaComputed();\n\n\n  const editRight = computed(() => { \n    return isEditRights(podcast.value?.organisation.id);\n  });\n  const isLiveReadyToRecord = computed(() => { \n    return (\n      undefined !== podcast.value?.conferenceId &&\n      0 !== podcast.value.conferenceId &&\n      \"READY_TO_RECORD\" === podcast.value.processingStatus\n    );\n  });\n  const isCounter = computed(() => { \n    return (\n      isLiveReadyToRecord.value &&\n      undefined !==  podcastConference.value &&\n      (\"PLANNED\" ===  podcastConference.value.status ||\n        \"PENDING\" ===  podcastConference.value.status)\n    );\n  });\n\n  const timeRemaining = computed(() => { \n    return !podcast.value ? 0: dayjs(podcast.value.pubDate).diff(dayjs(), \"seconds\");\n  });\n\n  const isPlannedInProcessor = computed(() => \"PLANNED\" === podcast.value?.processingStatus);\n  \n  const date = computed(() => { \n    if (!podcast.value || 1970 === dayjs(podcast.value.pubDate).year()) {\n      return \"\";\n    }\n    if (isLiveReadyToRecord.value || state.generalParameters.showTimeWithDates) {\n      return dayjs(podcast.value.pubDate).format(\"D MMMM YYYY - HH:mm\");\n    }\n    return dayjs(podcast.value.pubDate).format(\"D MMMM YYYY\");\n  });\n\n  const duration = computed(() => { \n    if (!podcast.value || podcast.value.duration <= 1){return \"\"};\n    if (podcast.value.duration > 600000) {\n      return humanizeDuration(podcast.value.duration, {\n        language: locale.value,\n        largest: 1,\n        round: true,\n      });\n    }\n    return humanizeDuration(podcast.value.duration, {\n      language: locale.value,\n      largest: 2,\n      round: true,\n    });\n  });\n\n  const durationIso = computed(() => { \n    if (!podcast.value || podcast.value.duration <= 1){return \"\";}\n    return dayjs.duration({ milliseconds: podcast.value.duration }).toISOString();\n  });\n\treturn {\n    isLiveReadyToRecord,\n    isCounter,\n    timeRemaining,\n    isPlannedInProcessor,\n    date,\n    duration,\n    durationIso,\n    editRight,\n    isPodcastmaker\n\t}\n}\n"],"mappings":";;;;;;;AAUA,IAAa,kBAAkB,SAAkC,sBAA+C;CAE9G,MAAM,EAAC,WAAU,QAAQ;CACzB,MAAM,EAAE,UAAU,SAAS;CAE3B,MAAM,EAAC,cAAc,mBAAkB,gBAAgB;CAGvD,MAAM,YAAY,eAAe;EAC/B,OAAO,aAAa,QAAQ,OAAO,aAAa,EAAE;CACpD,CAAC;CACD,MAAM,sBAAsB,eAAe;EACzC,OACE,KAAA,MAAc,QAAQ,OAAO,gBAC7B,MAAM,QAAQ,MAAM,gBACpB,sBAAsB,QAAQ,MAAM;CAExC,CAAC;CA8CF,OAAO;EACJ;EACA,WA/CgB,eAAe;GAC/B,OACE,oBAAoB,SACpB,KAAA,MAAe,kBAAkB,UAChC,cAAe,kBAAkB,MAAM,UACtC,cAAe,kBAAkB,MAAM;EAE7C,CAwCE;EACA,eAvCoB,eAAe;GACnC,OAAO,CAAC,QAAQ,QAAQ,IAAG,MAAM,QAAQ,MAAM,OAAO,EAAE,KAAK,MAAM,GAAG,SAAS;EACjF,CAqCE;EACA,sBApC2B,eAAe,cAAc,QAAQ,OAAO,gBAoCvE;EACA,MAnCW,eAAe;GAC1B,IAAI,CAAC,QAAQ,SAAS,SAAS,MAAM,QAAQ,MAAM,OAAO,EAAE,KAAK,GAC/D,OAAO;GAET,IAAI,oBAAoB,SAAS,MAAM,kBAAkB,mBACvD,OAAO,MAAM,QAAQ,MAAM,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