import { defineComponent, useSSRContext, ref, computed, watch, mergeProps, reactive, createVNode, resolveDynamicComponent } from "vue";
import { ssrRenderAttrs, ssrRenderClass, ssrIncludeBooleanAttr, ssrInterpolate, ssrRenderList, ssrRenderComponent, ssrRenderAttr, ssrRenderVNode, ssrLooseContain } from "vue/server-renderer";
import "/app/node_modules/klona/dist/index.mjs";
import "/app/node_modules/hookable/dist/index.mjs";
import "../server.mjs";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
import { useRoute, useRouter } from "vue-router";
import "/app/node_modules/ofetch/dist/node.mjs";
import "#internal/nuxt/paths";
import "/app/node_modules/unctx/dist/index.mjs";
import "/app/node_modules/h3/dist/index.mjs";
import "pinia";
import "/app/node_modules/defu/dist/defu.mjs";
import "/app/node_modules/ufo/dist/index.mjs";
import "/app/node_modules/cookie-es/dist/index.mjs";
import "/app/node_modules/destr/dist/index.mjs";
import "/app/node_modules/ohash/dist/index.mjs";
import "/app/node_modules/@unhead/vue/dist/index.mjs";
import "@vue/devtools-api";
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
__name: "TreeNode",
__ssrInlineRender: true,
props: {
node: {},
selectedIds: {},
expandedIds: {}
},
emits: ["toggle", "toggle-expand"],
setup(__props) {
return (_ctx, _push, _parent, _attrs) => {
const _component_TreeNode = _sfc_main$3;
_push(`
`);
if (__props.expandedIds.has(__props.node.id) && __props.node.children?.length) {
_push(`
`);
ssrRenderList(__props.node.children, (child) => {
_push(`
`);
_push(ssrRenderComponent(_component_TreeNode, {
node: child,
"selected-ids": __props.selectedIds,
"expanded-ids": __props.expandedIds,
onToggle: (id) => _ctx.$emit("toggle", id),
onToggleExpand: (id) => _ctx.$emit("toggle-expand", id)
}, null, _parent));
_push(`
`);
});
_push(`
`);
} else {
_push(``);
}
_push(`
`);
};
}
});
const _sfc_setup$3 = _sfc_main$3.setup;
_sfc_main$3.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/TreeNode.vue");
return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
__name: "SmartLocationInput",
__ssrInlineRender: true,
props: {
modelValue: { default: null },
label: { default: "" },
placeholder: { default: "Kezdj el gépelni (irányítószám vagy város)..." },
minChars: { default: 2 },
countryCode: { default: "HU" },
debounceMs: { default: 300 }
},
emits: ["update:modelValue", "select"],
setup(__props, { emit: __emit }) {
const props = __props;
ref(null);
const query = ref("");
const selectedItem = ref(props.modelValue);
const items = ref([]);
const searching = ref(false);
const showDropdown = ref(false);
const highlightedIndex = ref(0);
const displayText = computed(() => {
if (selectedItem.value) {
return `${selectedItem.value.zip_code} ${selectedItem.value.city}`;
}
return query.value;
});
const filteredItems = computed(() => {
if (!query.value || query.value.length < props.minChars) return [];
const q = query.value.toLowerCase();
return items.value.filter(
(item) => item.zip_code.toLowerCase().includes(q) || item.city.toLowerCase().includes(q)
);
});
watch(
() => props.modelValue,
(val) => {
selectedItem.value = val;
}
);
return (_ctx, _push, _parent, _attrs) => {
_push(``);
if (__props.label) {
_push(`
`);
} else {
_push(``);
}
_push(`
`);
if (searching.value) {
_push(`
`);
} else {
_push(``);
}
if (selectedItem.value && !searching.value) {
_push(`
`);
} else {
_push(``);
}
_push(`
`);
if (showDropdown.value && filteredItems.value.length > 0) {
_push(`
`);
ssrRenderList(filteredItems.value, (item, index) => {
_push(``);
});
_push(`
`);
} else {
_push(``);
}
if (showDropdown.value && query.value.length >= __props.minChars && filteredItems.value.length === 0 && !searching.value) {
_push(`
Nincs találat
`);
} else {
_push(``);
}
_push(`
`);
};
}
});
const _sfc_setup$2 = _sfc_main$2.setup;
_sfc_main$2.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/SmartLocationInput.vue");
return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
};
const __nuxt_component_0 = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-b43e13ca"]]);
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
__name: "SharedAddressForm",
__ssrInlineRender: true,
props: {
modelValue: { default: () => ({
zip: null,
city: null,
street_name: null,
street_type: null,
house_number: null,
stairwell: null,
floor: null,
door: null,
parcel_id: null,
full_address_text: null,
latitude: null,
longitude: null
}) }
},
emits: ["update:modelValue"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const selectedLocation = computed(() => {
if (props.modelValue?.zip && props.modelValue?.city) {
return {
id: 0,
// We don't have the DB id here, but SmartLocationInput handles this
zip_code: props.modelValue.zip,
city: props.modelValue.city,
country_code: "HU"
};
}
return null;
});
function onLocationSelected(location) {
const updated = { ...props.modelValue };
if (location) {
updated.zip = location.zip_code;
updated.city = location.city;
} else {
updated.zip = null;
updated.city = null;
}
emit("update:modelValue", updated);
}
return (_ctx, _push, _parent, _attrs) => {
const _component_SmartLocationInput = __nuxt_component_0;
_push(``);
};
}
});
const _sfc_setup$1 = _sfc_main$1.setup;
_sfc_main$1.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/SharedAddressForm.vue");
return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "edit",
__ssrInlineRender: true,
setup(__props) {
const VEHICLE_CLASSES = [
{ key: "car", label: "Személyautó" },
{ key: "motorcycle", label: "Motorkerékpár" },
{ key: "truck", label: "Teherautó" },
{ key: "hgv", label: "Nehézgépjármű (HGV)" },
{ key: "light_commercial", label: "Kishaszonjármű" },
{ key: "personal", label: "Személyes" },
{ key: "boat", label: "Csónak/Vízi" },
{ key: "other", label: "Egyéb" }
];
const route = useRoute();
useRouter();
computed(() => Number(route.params.id));
const loading = ref(true);
const error = ref(false);
const provider = ref(null);
const saveLoading = ref(false);
const toast = ref(null);
const activeTab = ref("basic");
const tabs = [
{ key: "basic", label: "Alapadatok & Kapcsolat", icon: "svg" },
{ key: "matrix", label: "Szolgáltatások & Járművek", icon: "svg" },
{ key: "location", label: "Helyszín & Lokáció", icon: "svg" },
{ key: "hours", label: "Nyitvatartás", icon: "svg" }
];
const categoryTree = ref([]);
const treeLoading = ref(false);
const expandedNodes = ref(/* @__PURE__ */ new Set());
const brandInput = ref("");
const propulsionInput = ref("");
const form = reactive({
name: "",
address: "",
city: "",
address_zip: "",
address_street_name: "",
address_street_type: "",
address_house_number: "",
plus_code: "",
contact_phone: "",
contact_email: "",
website: "",
category: "",
category_ids: [],
supported_vehicle_classes: [],
specializations: {
brands: [],
propulsion: []
},
opening_hours: {},
is_always_open: false,
// Nested address object matching AddressIn schema (used by SharedAddressForm)
address: {
zip: "",
city: "",
street_name: "",
street_type: "",
house_number: "",
stairwell: "",
floor: "",
door: "",
parcel_id: "",
full_address_text: "",
latitude: null,
longitude: null
}
});
const hasChanges = computed(() => {
if (!provider.value) return false;
const p = provider.value;
if (form.name !== (p.name || "")) return true;
if (form.address !== (p.address || "")) return true;
if (form.plus_code !== (p.plus_code || "")) return true;
if (form.address.zip !== (p.address_zip || "")) return true;
if (form.address.city !== (p.city || "")) return true;
if (form.address.street_name !== (p.address_street_name || "")) return true;
if (form.address.street_type !== (p.address_street_type || "")) return true;
if (form.address.house_number !== (p.address_house_number || "")) return true;
if (form.contact_phone !== (p.contact_phone || "")) return true;
if (form.contact_email !== (p.contact_email || "")) return true;
if (form.website !== (p.website || "")) return true;
if (form.category !== (p.category || "")) return true;
const sortedFormCategories = [...form.category_ids].sort();
const sortedOrigCategories = [...p.category_ids || []].sort();
if (JSON.stringify(sortedFormCategories) !== JSON.stringify(sortedOrigCategories)) return true;
const sortedFormClasses = [...form.supported_vehicle_classes].sort();
const sortedOrigClasses = [...p.supported_vehicle_classes || []].sort();
if (JSON.stringify(sortedFormClasses) !== JSON.stringify(sortedOrigClasses)) return true;
const normalizeSpec = (spec) => ({
brands: Array.isArray(spec?.brands) ? [...spec.brands].sort() : [],
propulsion: Array.isArray(spec?.propulsion) ? [...spec.propulsion].sort() : []
});
if (JSON.stringify(normalizeSpec(form.specializations)) !== JSON.stringify(normalizeSpec(p.specializations))) return true;
const DAYS2 = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
const normalizeHours = (hours) => {
const result = {};
const daysSource = hours?.days || hours;
for (const day of DAYS2) {
const slot = daysSource?.[day];
if (slot && typeof slot === "object" && slot.open && slot.close) {
result[day] = { open: slot.open, close: slot.close };
} else {
result[day] = null;
}
}
return result;
};
if (JSON.stringify(normalizeHours(form.opening_hours)) !== JSON.stringify(normalizeHours(p.opening_hours))) return true;
if (form.is_always_open !== (p.opening_hours?.always_open === true)) return true;
return false;
});
function findCategoryById(id, nodes) {
for (const node of nodes) {
if (node.id === id) return node;
if (node.children?.length) {
const found = findCategoryById(id, node.children);
if (found) return found;
}
}
return null;
}
function getCategoryName(id) {
const node = findCategoryById(id, categoryTree.value);
if (!node) return `#${id}`;
return node.name_hu || node.name_en || node.key;
}
function toggleCategory(id) {
const idx = form.category_ids.indexOf(id);
if (idx >= 0) {
form.category_ids.splice(idx, 1);
} else {
form.category_ids.push(id);
}
}
function toggleTreeNode(id) {
const newSet = new Set(expandedNodes.value);
if (newSet.has(id)) {
newSet.delete(id);
} else {
newSet.add(id);
}
expandedNodes.value = newSet;
}
function isCategorySelected(id) {
return form.category_ids.includes(id);
}
const DAYS = [
{ key: "monday", label: "Hétfő" },
{ key: "tuesday", label: "Kedd" },
{ key: "wednesday", label: "Szerda" },
{ key: "thursday", label: "Csütörtök" },
{ key: "friday", label: "Péntek" },
{ key: "saturday", label: "Szombat" },
{ key: "sunday", label: "Vasárnap" }
];
return (_ctx, _push, _parent, _attrs) => {
const _component_TreeNode = _sfc_main$3;
const _component_SharedAddressForm = _sfc_main$1;
_push(`Szolgáltató szerkesztése
Szolgáltató #${ssrInterpolate(_ctx.$route.params.id)}
`);
if (loading.value) {
_push(`
`);
} else if (error.value) {
_push(`
Hiba történt a szolgáltató betöltése közben.
`);
} else if (!provider.value) {
_push(`
A szolgáltató nem található.
`);
} else {
_push(`
`);
if (activeTab.value === "basic") {
_push(`
`);
} else {
_push(``);
}
if (activeTab.value === "matrix") {
_push(`
3D Képesség Mátrix
Állítsd be, hogy a szolgáltató milyen járműosztályokhoz, szolgáltatási kategóriákhoz és specializációkhoz tartozik.
B Szolgáltatási Kategóriák (Expertise Tags)
Válaszd ki a szolgáltatóhoz tartozó kategóriákat a hierarchikus fából.
`);
if (treeLoading.value) {
_push(`
`);
} else {
_push(`
`);
ssrRenderList(categoryTree.value, (node) => {
_push(`
`);
if (expandedNodes.value.has(node.id) && node.children?.length) {
_push(`
`);
ssrRenderList(node.children, (child) => {
_push(`
`);
_push(ssrRenderComponent(_component_TreeNode, {
node: child,
"selected-ids": form.category_ids,
"expanded-ids": expandedNodes.value,
onToggle: toggleCategory,
onToggleExpand: toggleTreeNode
}, null, _parent));
_push(`
`);
});
_push(`
`);
} else {
_push(``);
}
_push(`
`);
});
_push(`
`);
}
if (form.category_ids.length > 0) {
_push(`
`);
ssrRenderList(form.category_ids, (id) => {
_push(`
${ssrInterpolate(getCategoryName(id))} `);
});
_push(`
`);
} else {
_push(``);
}
_push(`
C Specializációk
Adj meg speciális márkákat, hajtáslánc típusokat vagy egyéb címkéket.
`);
ssrRenderList(form.specializations.brands, (brand, idx) => {
_push(`
${ssrInterpolate(brand)} `);
});
_push(`
`);
ssrRenderList(form.specializations.propulsion, (prop, idx) => {
_push(`
${ssrInterpolate(prop)} `);
});
_push(`
`);
} else {
_push(``);
}
if (activeTab.value === "location") {
_push(`
`);
} else {
_push(``);
}
if (activeTab.value === "hours") {
_push(`
Nyitvatartás
Állítsd be a szolgáltató nyitvatartási idejét napokra bontva.
`);
ssrRenderList(DAYS, (day) => {
_push(`
`);
});
_push(`
`);
} else {
_push(``);
}
_push(`
`);
if (hasChanges.value) {
_push(`● Módosítások el nem mentve`);
} else {
_push(`Nincs változás`);
}
_push(`
`);
}
if (toast.value) {
_push(`
${ssrInterpolate(toast.value.message)}
`);
} else {
_push(``);
}
_push(`
`);
};
}
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/providers/[id]/edit.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const edit = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ab22d560"]]);
export {
edit as default
};
//# sourceMappingURL=edit-ZNmjSMhu.js.map