import { defineComponent, ref, computed, reactive, unref, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderClass, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual } from 'vue/server-renderer'; import { u as useRegionStore } from './region-0mvXqaMM.mjs'; import 'pinia'; function useFormatter() { const regionStore = useRegionStore(); function formatNumber(value, options) { const locale = regionStore.activeLocale || "en-EU"; try { return new Intl.NumberFormat(locale, options).format(value); } catch { return new Intl.NumberFormat("en-EU", options).format(value); } } function formatCurrency(value, currency, options) { const locale = regionStore.activeLocale || "en-EU"; const curr = currency || regionStore.activeCurrency || "EUR"; try { return new Intl.NumberFormat(locale, { style: "currency", currency: curr, minimumFractionDigits: 2, maximumFractionDigits: 2, ...options }).format(value); } catch { return `${value.toFixed(2)} ${curr}`; } } function formatDate(date, options) { const locale = regionStore.activeLocale || "en-EU"; const timezone = regionStore.activeTimezone || "Europe/Brussels"; const d = typeof date === "string" || typeof date === "number" ? new Date(date) : date; try { return new Intl.DateTimeFormat(locale, { timezone, year: "numeric", month: "2-digit", day: "2-digit", ...options }).format(d); } catch { return d.toLocaleDateString("en-GB"); } } function formatDateTime(date, options) { const locale = regionStore.activeLocale || "en-EU"; const timezone = regionStore.activeTimezone || "Europe/Brussels"; const d = typeof date === "string" || typeof date === "number" ? new Date(date) : date; try { return new Intl.DateTimeFormat(locale, { timezone, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", ...options }).format(d); } catch { return d.toLocaleString("en-GB"); } } function formatPercent(value, options) { const locale = regionStore.activeLocale || "en-EU"; try { return new Intl.NumberFormat(locale, { style: "percent", minimumFractionDigits: 0, maximumFractionDigits: 1, ...options }).format(value / 100); } catch { return `${value}%`; } } function calculatePriceWithVat(netPrice, vatRate) { var _a; const rate = (_a = vatRate != null ? vatRate : regionStore.activeVatRate) != null ? _a : 0; const vat = netPrice * (rate / 100); const gross = netPrice + vat; return { net: netPrice, vat, gross, vatRate: rate }; } function formatPriceWithVat(netPrice, vatRate, currency) { const { net, vat, gross, vatRate: rate } = calculatePriceWithVat(netPrice, vatRate); const curr = currency || regionStore.activeCurrency || "EUR"; return `Net: ${formatCurrency(net, curr)} | VAT: ${formatCurrency(vat, curr)} (${rate}%) | Gross: ${formatCurrency(gross, curr)}`; } return { formatNumber, formatCurrency, formatDate, formatDateTime, formatPercent, calculatePriceWithVat, formatPriceWithVat }; } const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "index", __ssrInlineRender: true, setup(__props) { const regionStore = useRegionStore(); const { formatCurrency } = useFormatter(); const tabs = [ { key: "basic", label: "\u{1F4CB} Basic Info" }, { key: "pricing", label: "\u{1F4B0} Pricing" }, { key: "features", label: "\u26A1 Features" } ]; const activeTab = ref("basic"); const activeTabLabel = computed(() => { const tab = tabs.find((t) => t.key === activeTab.value); return tab ? tab.label : ""; }); const packages = ref([]); const loading = ref(true); const error = ref(null); const showModal = ref(false); const showDeleteConfirm = ref(false); const editingPackage = ref(null); const deletingPackage = ref(null); const isCreating = ref(false); const saving = ref(false); const saveNotification = ref(null); const featureCapabilitiesError = ref(null); const calcNetPrice = ref(0); const calcVatRate = ref(27); const calcCurrency = ref("EUR"); const defaultForm = { name: "", display_name: "", type: "private", tier_level: 0, monthly_price: 0, yearly_price: 0, currency: "EUR", max_vehicles: 1, max_garages: 1, monthly_free_credits: 0, subtitle: "", badge: "", is_custom: false, is_default_fallback: false, trial_days_on_signup: 0, feature_capabilities_json: '{\n "ai_analysis": false,\n "priority_support": false,\n "api_access": false\n}', pricing_zones: {} }; const form = reactive({ ...defaultForm }); function getZonePrice(countryCode, period) { const zone = form.pricing_zones[countryCode]; if (!zone) return 0; return period === "monthly" ? zone.monthly_price : zone.yearly_price; } function getZoneCurrency(countryCode) { const zone = form.pricing_zones[countryCode]; if (!zone) return "EUR"; return zone.currency; } function getDisplayName(pkg) { var _a; return ((_a = pkg.rules) == null ? void 0 : _a.display_name) || pkg.name; } function getDescription(pkg) { var _a, _b, _c, _d; return ((_b = (_a = pkg.rules) == null ? void 0 : _a.marketing) == null ? void 0 : _b.subtitle) || ((_d = (_c = pkg.rules) == null ? void 0 : _c.marketing) == null ? void 0 : _d.badge) || ""; } function getFormattedPrice(pkg) { var _a, _b; const zones = (_a = pkg.rules) == null ? void 0 : _a.pricing_zones; const pricing = (_b = pkg.rules) == null ? void 0 : _b.pricing; if (zones && zones["DEFAULT"]) { const p = zones["DEFAULT"]; const currency = p.currency === "HUF" ? "Ft" : "\u20AC"; return `${p.monthly_price} ${currency}`; } if (pricing) { const currency = pricing.currency === "HUF" ? "Ft" : "\u20AC"; return `${pricing.monthly_price} ${currency}`; } return "\u2014"; } function getAllowance(pkg, key) { var _a, _b; const allowances = (_a = pkg.rules) == null ? void 0 : _a.allowances; if (!allowances) return "\u2014"; return (_b = allowances[key]) != null ? _b : "\u2014"; } function getTierColorClass(level) { if (level >= 2) return "bg-purple-500/10 text-purple-400"; if (level >= 1) return "bg-amber-500/10 text-amber-400"; return "bg-slate-500/10 text-slate-400"; } function getTierIcon(level) { if (level >= 2) return "\u{1F3E2}"; if (level >= 1) return "\u2B50"; return "\u{1F513}"; } return (_ctx, _push, _parent, _attrs) => { _push(`
${ssrInterpolate(_ctx.$t("packages.subtitle"))}
${ssrInterpolate(error.value)}
${ssrInterpolate(_ctx.$t("packages.no_packages_desc"))}
${ssrInterpolate(getDescription(pkg))}
${ssrInterpolate(_ctx.$t("packages.form_tier_level_hint"))}
${ssrInterpolate(_ctx.$t("packages.form_trial_days_hint"))}
| Region | ${ssrInterpolate(_ctx.$t("packages.form_monthly_price"))} | ${ssrInterpolate(_ctx.$t("packages.form_yearly_price"))} | ${ssrInterpolate(_ctx.$t("packages.form_currency"))} |
|---|---|---|---|
| ${ssrInterpolate(region.country_code)}(${ssrInterpolate(region.currency)}, ${ssrInterpolate(region.default_vat_rate)}% VAT) |
${ssrInterpolate(_ctx.$t("packages.calc_net"))}
${ssrInterpolate(unref(formatCurrency)(calcNetPrice.value, calcCurrency.value))}
${ssrInterpolate(_ctx.$t("packages.calc_vat"))} (${ssrInterpolate(calcVatRate.value)}%)
${ssrInterpolate(unref(formatCurrency)(calcNetPrice.value * (calcVatRate.value / 100), calcCurrency.value))}
${ssrInterpolate(_ctx.$t("packages.calc_gross"))}
${ssrInterpolate(unref(formatCurrency)(calcNetPrice.value * (1 + calcVatRate.value / 100), calcCurrency.value))}
${ssrInterpolate(_ctx.$t("packages.feature_capabilities_hint"))}
`); if (featureCapabilitiesError.value) { _push(`${ssrInterpolate(featureCapabilitiesError.value)}
`); } else { _push(``); } _push(`${ssrInterpolate(_ctx.$t("packages.delete_confirm", { name: getDisplayName(deletingPackage.value) }))}