{"version":3,"file":"SharePlayerTypes-CqCLmT11.mjs","names":[],"sources":["../src/components/display/sharing/SharePlayerTypes.vue","../src/components/display/sharing/SharePlayerTypes.vue"],"sourcesContent":["<template>\n  <label for=\"iframe-select\" title=\"select miniplayer\" >\n    <select\n      id=\"iframe-select\"\n      :value=\"iFrameModel\"\n      @change=\"selectChange($event)\"\n    >\n      <optgroup v-show=\"isCustomPlayer\" id=\"player-default-opt-group\" :label=\"t('Default version')\"></optgroup>\n      <Teleport defer :disabled=\"!isCustomPlayer\" to=\"#player-default-opt-group\">\n        <template v-for=\"option in optionsSelect\" :key=\"option.value\">\n          <option v-if=\"option.condition\" :value=\"option.value\">\n            {{ option.name }}\n          </option>\n        </template>\n      </Teleport>\n      \n      <optgroup v-if=\"isCustomPlayer\" :label=\"t('Custom version')\">\n        <option\n          v-for=\"player in customPlayersDisplay\"\n          :key=\"player.customId\"\n          :value=\"player.customId\"\n        >\n          {{ t(\"Custom version\") + \" «\" + player.name + \"»\" }}\n        </option>\n      </optgroup>\n    </select>\n  </label>\n</template>\n\n<script setup lang=\"ts\">\nimport classicApi from \"../../../api/classicApi\";\nimport { useAuthStore } from \"../../../stores/AuthStore\";\nimport { Podcast } from \"@/stores/class/general/podcast\";\nimport { CustomPlayer } from \"@/stores/class/general/customPlayer\";\nimport { computed, onBeforeMount, onMounted, Ref, ref } from \"vue\";\nimport { Emission } from \"@/stores/class/general/emission\";\nimport { Playlist } from \"@/stores/class/general/playlist\";\nimport { InterfacePageable } from \"@/stores/class/general/interfacePageable\";\nimport { useI18n } from \"vue-i18n\";\n\n//Props \nconst props = defineProps({\n  podcast: { default: undefined, type: Object as () => Podcast },\n  emission: { default: undefined, type: Object as () => Emission },\n  playlist: { default: undefined, type: Object as () => Playlist },\n  iFrameModel: { default: \"default\", type: String },\n  typeCustomPlayer: { default: \"\", type: String },\n  organisationId: { default: undefined, type: String },\n  isLive: { default: false, type: Boolean },\n})\n\n//Emits\nconst emit = defineEmits([\"update:iFrameModel\", \"update:typeCustomPlayer\"]);\n\n//Data \nconst customPlayers: Ref<Array<CustomPlayer>> = ref([]);\n\n//Composables\nconst { t } = useI18n();\nconst authStore = useAuthStore();\n\n//Computed\nconst isCustomPlayer = computed(() => 1<=customPlayersDisplay.value.length);\nconst isVideoPodcast = computed(() => undefined !== props.podcast?.video?.videoId);\nconst optionsSelectLive = computed(() => {\n  return [\n    { name: t(\"Large version\"), value: \"large\", condition: true },\n    {\n      name: t(\"High version\"),\n      value: \"videoLive\",\n      condition: props.podcast?.podcastId,\n    },\n  ];\n});\nconst optionsSelect = computed(() => {\n  if (props.isLive) {\n    return optionsSelectLive.value;\n  }\n  return [\n    {\n      name: t(\"Video Version\"),\n      value: \"video\",\n      condition: isVideoPodcast.value,\n    },\n    { name: t(\"Default version\"), value: \"default\", condition: true },\n    { name: t(\"Large version\"), value: \"largeMore\", condition: props.podcast?.podcastId, },\n    {\n      name: props.podcast?.podcastId ? t(\"Minimalist length version\"): t(\"Large version\"),\n      value: \"large\",\n      condition: true,\n    },\n    {\n      name: t(\"Emission version\"),\n      value: \"emission\",\n      condition: props.podcast?.podcastId,\n    },\n    {\n      name: t(\"Large emission version\"),\n      value: \"emissionLarge\",\n      condition: props.podcast?.podcastId,\n    },\n  ];\n});\nconst customPlayersDisplay = computed(() => {\n  return customPlayers.value.filter((player: CustomPlayer) => {\n    return (\n      ((\"EPISODE\" === player.typePlayer) &&\n        props.podcast?.podcastId) ||\n      (\"EMISSION\" === player.typePlayer &&\n      props.emission &&\n        !props.podcast) ||\n      (\"PLAYLIST\" === player.typePlayer && props.playlist)\n    );\n  }).sort((a,b) => {\n    if(a.name > b.name){\n      return 1;\n    }\n    return (b.name > a.name) ? -1 : 0;\n  });\n});\n\n\nonBeforeMount(()=>{\n  if (props.isLive) {\n    return;\n  }\n  initCustomPlayers();\n})\nonMounted(()=>{\n  if (isVideoPodcast.value) {\n    emit(\"update:iFrameModel\", \"video\");\n  }\n})\n \n\n//Methods\nfunction isNumeric(value: string): boolean {\n  return /^-?\\d+$/.test(value);\n}\nfunction selectChange($event: Event) {\n  const val = $event.target.value;\n  if (!val) {\n    return;\n  }\n  if (isNumeric(val)) {\n    const customPlayer = customPlayersDisplay.value.find((p) => {\n      return p.customId.toString() === val;\n    });\n    if (customPlayer) {\n      selectCustomPlayer(customPlayer);\n    }\n  } else {\n    emit(\"update:iFrameModel\", val);\n  }\n}\nasync function fetchPlayerPaginate(type: string): Promise<CustomPlayer[]> {\n  let players = await classicApi.fetchData<InterfacePageable<CustomPlayer>>(\n    {\n      api: 6,\n      path: \"customPlayer/type/\" + props.organisationId + \"/\" + type,\n      isNotAuth: true,\n    },\n  );\n  let playersContent = players.content;\n  const totalCount = players.totalElements;\n  let index = 1;\n  while (totalCount > playersContent.length) {\n    players = await classicApi.fetchData<InterfacePageable<CustomPlayer>>({\n      api: 6,\n      path:\n        \"customPlayer/type/\" +\n        props.organisationId +\n        \"/\" +\n        type +\n        \"?start=\" +\n        index,\n      isNotAuth: true,\n    });\n    playersContent = playersContent.concat(players.content);\n    ++index;\n  }\n  return playersContent;\n}\nfunction selectCustomPlayer(customPlayer: CustomPlayer) {\n  emit(\"update:typeCustomPlayer\", customPlayer.typePlayer);\n  emit(\"update:iFrameModel\", customPlayer.customId.toString());\n}\n\nasync function fetchCustomPlayers(\n  type: string,\n  selectIfPossible = true,\n): Promise<boolean> {\n  const customPlayersForType = await fetchPlayerPaginate(type);\n  customPlayers.value = customPlayers.value.concat(customPlayersForType);\n  if (\n    !isVideoPodcast.value &&\n    selectIfPossible &&\n    customPlayersForType?.[0]?.selected\n  ) {\n    selectCustomPlayer(customPlayers.value[0]);\n    return true;\n  }\n  return false;\n}\nasync function initCustomPlayers(): Promise<void> {\n  if (undefined === authStore.authOrgaId) return;\n  if (props.playlist) {\n    fetchCustomPlayers(\"PLAYLIST\");\n  } else if (props.emission && !props.podcast) {\n    fetchCustomPlayers(\"EMISSION\");\n  } else {\n    const episodeSelected = await fetchCustomPlayers(\"EPISODE\");\n    await fetchCustomPlayers(\n      \"EMISSION\",\n      !episodeSelected,\n    );\n  }\n}\n</script>\n","<template>\n  <label for=\"iframe-select\" title=\"select miniplayer\" >\n    <select\n      id=\"iframe-select\"\n      :value=\"iFrameModel\"\n      @change=\"selectChange($event)\"\n    >\n      <optgroup v-show=\"isCustomPlayer\" id=\"player-default-opt-group\" :label=\"t('Default version')\"></optgroup>\n      <Teleport defer :disabled=\"!isCustomPlayer\" to=\"#player-default-opt-group\">\n        <template v-for=\"option in optionsSelect\" :key=\"option.value\">\n          <option v-if=\"option.condition\" :value=\"option.value\">\n            {{ option.name }}\n          </option>\n        </template>\n      </Teleport>\n      \n      <optgroup v-if=\"isCustomPlayer\" :label=\"t('Custom version')\">\n        <option\n          v-for=\"player in customPlayersDisplay\"\n          :key=\"player.customId\"\n          :value=\"player.customId\"\n        >\n          {{ t(\"Custom version\") + \" «\" + player.name + \"»\" }}\n        </option>\n      </optgroup>\n    </select>\n  </label>\n</template>\n\n<script setup lang=\"ts\">\nimport classicApi from \"../../../api/classicApi\";\nimport { useAuthStore } from \"../../../stores/AuthStore\";\nimport { Podcast } from \"@/stores/class/general/podcast\";\nimport { CustomPlayer } from \"@/stores/class/general/customPlayer\";\nimport { computed, onBeforeMount, onMounted, Ref, ref } from \"vue\";\nimport { Emission } from \"@/stores/class/general/emission\";\nimport { Playlist } from \"@/stores/class/general/playlist\";\nimport { InterfacePageable } from \"@/stores/class/general/interfacePageable\";\nimport { useI18n } from \"vue-i18n\";\n\n//Props \nconst props = defineProps({\n  podcast: { default: undefined, type: Object as () => Podcast },\n  emission: { default: undefined, type: Object as () => Emission },\n  playlist: { default: undefined, type: Object as () => Playlist },\n  iFrameModel: { default: \"default\", type: String },\n  typeCustomPlayer: { default: \"\", type: String },\n  organisationId: { default: undefined, type: String },\n  isLive: { default: false, type: Boolean },\n})\n\n//Emits\nconst emit = defineEmits([\"update:iFrameModel\", \"update:typeCustomPlayer\"]);\n\n//Data \nconst customPlayers: Ref<Array<CustomPlayer>> = ref([]);\n\n//Composables\nconst { t } = useI18n();\nconst authStore = useAuthStore();\n\n//Computed\nconst isCustomPlayer = computed(() => 1<=customPlayersDisplay.value.length);\nconst isVideoPodcast = computed(() => undefined !== props.podcast?.video?.videoId);\nconst optionsSelectLive = computed(() => {\n  return [\n    { name: t(\"Large version\"), value: \"large\", condition: true },\n    {\n      name: t(\"High version\"),\n      value: \"videoLive\",\n      condition: props.podcast?.podcastId,\n    },\n  ];\n});\nconst optionsSelect = computed(() => {\n  if (props.isLive) {\n    return optionsSelectLive.value;\n  }\n  return [\n    {\n      name: t(\"Video Version\"),\n      value: \"video\",\n      condition: isVideoPodcast.value,\n    },\n    { name: t(\"Default version\"), value: \"default\", condition: true },\n    { name: t(\"Large version\"), value: \"largeMore\", condition: props.podcast?.podcastId, },\n    {\n      name: props.podcast?.podcastId ? t(\"Minimalist length version\"): t(\"Large version\"),\n      value: \"large\",\n      condition: true,\n    },\n    {\n      name: t(\"Emission version\"),\n      value: \"emission\",\n      condition: props.podcast?.podcastId,\n    },\n    {\n      name: t(\"Large emission version\"),\n      value: \"emissionLarge\",\n      condition: props.podcast?.podcastId,\n    },\n  ];\n});\nconst customPlayersDisplay = computed(() => {\n  return customPlayers.value.filter((player: CustomPlayer) => {\n    return (\n      ((\"EPISODE\" === player.typePlayer) &&\n        props.podcast?.podcastId) ||\n      (\"EMISSION\" === player.typePlayer &&\n      props.emission &&\n        !props.podcast) ||\n      (\"PLAYLIST\" === player.typePlayer && props.playlist)\n    );\n  }).sort((a,b) => {\n    if(a.name > b.name){\n      return 1;\n    }\n    return (b.name > a.name) ? -1 : 0;\n  });\n});\n\n\nonBeforeMount(()=>{\n  if (props.isLive) {\n    return;\n  }\n  initCustomPlayers();\n})\nonMounted(()=>{\n  if (isVideoPodcast.value) {\n    emit(\"update:iFrameModel\", \"video\");\n  }\n})\n \n\n//Methods\nfunction isNumeric(value: string): boolean {\n  return /^-?\\d+$/.test(value);\n}\nfunction selectChange($event: Event) {\n  const val = $event.target.value;\n  if (!val) {\n    return;\n  }\n  if (isNumeric(val)) {\n    const customPlayer = customPlayersDisplay.value.find((p) => {\n      return p.customId.toString() === val;\n    });\n    if (customPlayer) {\n      selectCustomPlayer(customPlayer);\n    }\n  } else {\n    emit(\"update:iFrameModel\", val);\n  }\n}\nasync function fetchPlayerPaginate(type: string): Promise<CustomPlayer[]> {\n  let players = await classicApi.fetchData<InterfacePageable<CustomPlayer>>(\n    {\n      api: 6,\n      path: \"customPlayer/type/\" + props.organisationId + \"/\" + type,\n      isNotAuth: true,\n    },\n  );\n  let playersContent = players.content;\n  const totalCount = players.totalElements;\n  let index = 1;\n  while (totalCount > playersContent.length) {\n    players = await classicApi.fetchData<InterfacePageable<CustomPlayer>>({\n      api: 6,\n      path:\n        \"customPlayer/type/\" +\n        props.organisationId +\n        \"/\" +\n        type +\n        \"?start=\" +\n        index,\n      isNotAuth: true,\n    });\n    playersContent = playersContent.concat(players.content);\n    ++index;\n  }\n  return playersContent;\n}\nfunction selectCustomPlayer(customPlayer: CustomPlayer) {\n  emit(\"update:typeCustomPlayer\", customPlayer.typePlayer);\n  emit(\"update:iFrameModel\", customPlayer.customId.toString());\n}\n\nasync function fetchCustomPlayers(\n  type: string,\n  selectIfPossible = true,\n): Promise<boolean> {\n  const customPlayersForType = await fetchPlayerPaginate(type);\n  customPlayers.value = customPlayers.value.concat(customPlayersForType);\n  if (\n    !isVideoPodcast.value &&\n    selectIfPossible &&\n    customPlayersForType?.[0]?.selected\n  ) {\n    selectCustomPlayer(customPlayers.value[0]);\n    return true;\n  }\n  return false;\n}\nasync function initCustomPlayers(): Promise<void> {\n  if (undefined === authStore.authOrgaId) return;\n  if (props.playlist) {\n    fetchCustomPlayers(\"PLAYLIST\");\n  } else if (props.emission && !props.podcast) {\n    fetchCustomPlayers(\"EMISSION\");\n  } else {\n    const episodeSelected = await fetchCustomPlayers(\"EPISODE\");\n    await fetchCustomPlayers(\n      \"EMISSION\",\n      !episodeSelected,\n    );\n  }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