#!/usr/bin/env bash
set -euo pipefail

VERSION="6.1.20"
OUT_DIR="/root/vereinskalender/public/vendor/fullcalendar"
OUT_FILE="${OUT_DIR}/fullcalendar.css"

mkdir -p "${OUT_DIR}"

urls=(
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/vars.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/mixins.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/page-root.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/calendar-root.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/button.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/button-group.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/toolbar.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/view-harness.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/scrollgrid.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/scroller.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/scroller-harness.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/col-header.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/bg.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/event.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/h-event.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/icons.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/sticky.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/core/src/styles/popover.css"

  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/daygrid/src/styles/vars.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/daygrid/src/styles/daygrid.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/daygrid/src/styles/daygrid-event.css"

  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/timegrid/src/styles/constants.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/timegrid/src/styles/timegrid.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/timegrid/src/styles/timegrid-slots.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/timegrid/src/styles/timegrid-cols.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/timegrid/src/styles/timegrid-event.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/timegrid/src/styles/timegrid-now-indicator.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/timegrid/src/styles/v-event.css"

  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/list/src/styles/vars.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/list/src/styles/list.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/list/src/styles/list-table.css"
  "https://raw.githubusercontent.com/fullcalendar/fullcalendar/v${VERSION}/packages/list/src/styles/list-event.css"
)

: > "${OUT_FILE}"

for url in "${urls[@]}"; do
  echo "/* ${url} */" >> "${OUT_FILE}"
  curl -fsSL "${url}" >> "${OUT_FILE}"
  echo "" >> "${OUT_FILE}"
  echo "" >> "${OUT_FILE}"
done
