import { i as useForm, n as head_default, o as vue_exports } from "../ssr.js";
import { n as server_renderer_exports, t } from "./i18n-CXLOYfyq.js";
import { t as AppLayout_default } from "./AppLayout-DbhjYK6s.js";
//#region resources/js/Pages/Invite.vue?vue&type=script&setup=true&lang.ts
var Invite_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_exports.defineComponent)({
	__name: "Invite",
	__ssrInlineRender: true,
	props: {
		link: {},
		code: {},
		joined: {},
		sent: {}
	},
	setup(__props) {
		const props = __props;
		const copied = (0, vue_exports.ref)(false);
		async function copyLink() {
			try {
				await navigator.clipboard.writeText(props.link);
				copied.value = true;
				setTimeout(() => copied.value = false, 1800);
			} catch {}
		}
		const raw = (0, vue_exports.ref)("");
		const form = useForm({
			emails: [],
			message: ""
		});
		const parsedEmails = (0, vue_exports.computed)(() => raw.value.split(/[\s,;]+/).map((s) => s.trim()).filter((s) => /.+@.+\..+/.test(s)));
		function send() {
			form.emails = parsedEmails.value;
			if (!form.emails.length) return;
			form.post("/invite/send", {
				preserveScroll: true,
				onSuccess: () => {
					raw.value = "";
					form.reset("message");
				}
			});
		}
		return (_ctx, _push, _parent, _attrs) => {
			_push(`<!--[-->`);
			_push((0, server_renderer_exports.ssrRenderComponent)((0, vue_exports.unref)(head_default), { title: (0, vue_exports.unref)(t)("Invite friends") }, null, _parent));
			_push((0, server_renderer_exports.ssrRenderComponent)(AppLayout_default, null, {
				default: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`<div class="mx-auto max-w-2xl px-4 py-8"${_scopeId}><h1 class="text-2xl font-extrabold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Invite your friends"))}</h1><p class="mt-1.5 text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Share your personal link or send invites by email. When someone joins through you, they’ll show up here."))}</p><section class="mt-6 rounded-2xl border border-line bg-surface p-5"${_scopeId}><h2 class="text-sm font-bold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Your invite link"))}</h2><p class="mt-1 text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Anyone who signs up with this link is credited to you."))}</p><div class="mt-3 flex flex-col gap-2 sm:flex-row"${_scopeId}><input${(0, server_renderer_exports.ssrRenderAttr)("value", __props.link)} readonly class="w-full truncate rounded-lg border-line bg-appbg text-sm text-ink-2"${_scopeId}><button class="shrink-0 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(copied.value ? (0, vue_exports.unref)(t)("Copied!") : (0, vue_exports.unref)(t)("Copy link"))}</button></div></section><section class="mt-5 rounded-2xl border border-line bg-surface p-5"${_scopeId}><h2 class="text-sm font-bold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Invite by email"))}</h2><p class="mt-1 text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Enter up to 10 email addresses, separated by commas or new lines."))}</p><textarea rows="3"${(0, server_renderer_exports.ssrRenderAttr)("placeholder", (0, vue_exports.unref)(t)("friend@example.com, another@example.com"))} class="mt-3 w-full rounded-lg border-line bg-appbg text-sm text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(raw.value)}</textarea><textarea rows="2"${(0, server_renderer_exports.ssrRenderAttr)("maxlength", 500)}${(0, server_renderer_exports.ssrRenderAttr)("placeholder", (0, vue_exports.unref)(t)("Add a personal note (optional)"))} class="mt-2 w-full rounded-lg border-line bg-appbg text-sm text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(form).message)}</textarea><div class="mt-3 flex items-center gap-3"${_scopeId}><button${(0, server_renderer_exports.ssrIncludeBooleanAttr)(!parsedEmails.value.length || (0, vue_exports.unref)(form).processing) ? " disabled" : ""} class="rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600 disabled:opacity-50"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(form).processing ? (0, vue_exports.unref)(t)("Sending…") : parsedEmails.value.length === 1 ? (0, vue_exports.unref)(t)("Send 1 invite") : (0, vue_exports.unref)(t)("Send {n} invites", { n: parsedEmails.value.length || 0 }))}</button>`);
						if (parsedEmails.value.length) _push(`<span class="text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(parsedEmails.value.length)} ${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("valid"))}</span>`);
						else _push(`<!---->`);
						_push(`</div></section><section class="mt-5 grid grid-cols-2 gap-3"${_scopeId}><div class="rounded-2xl border border-line bg-surface p-5 text-center"${_scopeId}><div class="text-3xl font-black text-primary"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(__props.joined)}</div><div class="mt-1 text-xs font-semibold text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("joined through you"))}</div></div><div class="rounded-2xl border border-line bg-surface p-5 text-center"${_scopeId}><div class="text-3xl font-black text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(__props.sent.length)}</div><div class="mt-1 text-xs font-semibold text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("email invites sent"))}</div></div></section>`);
						if (__props.sent.length) {
							_push(`<section class="mt-5 rounded-2xl border border-line bg-surface p-5"${_scopeId}><h2 class="mb-2 text-sm font-bold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Sent invitations"))}</h2><ul class="divide-y divide-line"${_scopeId}><!--[-->`);
							(0, server_renderer_exports.ssrRenderList)(__props.sent, (s, i) => {
								_push(`<li class="flex items-center justify-between py-2.5 text-sm"${_scopeId}><span class="truncate text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(s.email)}</span>`);
								if (s.joined) _push(`<span class="shrink-0 rounded-full bg-emerald-500/15 px-2 py-0.5 text-xs font-bold text-emerald-600 dark:text-emerald-400"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Joined"))}</span>`);
								else _push(`<span class="shrink-0 text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Pending"))} · ${(0, server_renderer_exports.ssrInterpolate)(s.sentAt)}</span>`);
								_push(`</li>`);
							});
							_push(`<!--]--></ul></section>`);
						} else _push(`<!---->`);
						_push(`</div>`);
					} else return [(0, vue_exports.createVNode)("div", { class: "mx-auto max-w-2xl px-4 py-8" }, [
						(0, vue_exports.createVNode)("h1", { class: "text-2xl font-extrabold text-ink" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Invite your friends")), 1),
						(0, vue_exports.createVNode)("p", { class: "mt-1.5 text-ink-2" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Share your personal link or send invites by email. When someone joins through you, they’ll show up here.")), 1),
						(0, vue_exports.createVNode)("section", { class: "mt-6 rounded-2xl border border-line bg-surface p-5" }, [
							(0, vue_exports.createVNode)("h2", { class: "text-sm font-bold text-ink" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Your invite link")), 1),
							(0, vue_exports.createVNode)("p", { class: "mt-1 text-xs text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Anyone who signs up with this link is credited to you.")), 1),
							(0, vue_exports.createVNode)("div", { class: "mt-3 flex flex-col gap-2 sm:flex-row" }, [(0, vue_exports.createVNode)("input", {
								value: __props.link,
								readonly: "",
								class: "w-full truncate rounded-lg border-line bg-appbg text-sm text-ink-2",
								onFocus: ($event) => $event.target.select()
							}, null, 40, ["value", "onFocus"]), (0, vue_exports.createVNode)("button", {
								class: "shrink-0 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600",
								onClick: copyLink
							}, (0, vue_exports.toDisplayString)(copied.value ? (0, vue_exports.unref)(t)("Copied!") : (0, vue_exports.unref)(t)("Copy link")), 1)])
						]),
						(0, vue_exports.createVNode)("section", { class: "mt-5 rounded-2xl border border-line bg-surface p-5" }, [
							(0, vue_exports.createVNode)("h2", { class: "text-sm font-bold text-ink" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Invite by email")), 1),
							(0, vue_exports.createVNode)("p", { class: "mt-1 text-xs text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Enter up to 10 email addresses, separated by commas or new lines.")), 1),
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("textarea", {
								"onUpdate:modelValue": ($event) => raw.value = $event,
								rows: "3",
								placeholder: (0, vue_exports.unref)(t)("friend@example.com, another@example.com"),
								class: "mt-3 w-full rounded-lg border-line bg-appbg text-sm text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary"
							}, null, 8, ["onUpdate:modelValue", "placeholder"]), [[vue_exports.vModelText, raw.value]]),
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("textarea", {
								"onUpdate:modelValue": ($event) => (0, vue_exports.unref)(form).message = $event,
								rows: "2",
								maxlength: 500,
								placeholder: (0, vue_exports.unref)(t)("Add a personal note (optional)"),
								class: "mt-2 w-full rounded-lg border-line bg-appbg text-sm text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary"
							}, null, 8, ["onUpdate:modelValue", "placeholder"]), [[vue_exports.vModelText, (0, vue_exports.unref)(form).message]]),
							(0, vue_exports.createVNode)("div", { class: "mt-3 flex items-center gap-3" }, [(0, vue_exports.createVNode)("button", {
								disabled: !parsedEmails.value.length || (0, vue_exports.unref)(form).processing,
								class: "rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600 disabled:opacity-50",
								onClick: send
							}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(form).processing ? (0, vue_exports.unref)(t)("Sending…") : parsedEmails.value.length === 1 ? (0, vue_exports.unref)(t)("Send 1 invite") : (0, vue_exports.unref)(t)("Send {n} invites", { n: parsedEmails.value.length || 0 })), 9, ["disabled"]), parsedEmails.value.length ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
								key: 0,
								class: "text-xs text-ink-muted"
							}, (0, vue_exports.toDisplayString)(parsedEmails.value.length) + " " + (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("valid")), 1)) : (0, vue_exports.createCommentVNode)("", true)])
						]),
						(0, vue_exports.createVNode)("section", { class: "mt-5 grid grid-cols-2 gap-3" }, [(0, vue_exports.createVNode)("div", { class: "rounded-2xl border border-line bg-surface p-5 text-center" }, [(0, vue_exports.createVNode)("div", { class: "text-3xl font-black text-primary" }, (0, vue_exports.toDisplayString)(__props.joined), 1), (0, vue_exports.createVNode)("div", { class: "mt-1 text-xs font-semibold text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("joined through you")), 1)]), (0, vue_exports.createVNode)("div", { class: "rounded-2xl border border-line bg-surface p-5 text-center" }, [(0, vue_exports.createVNode)("div", { class: "text-3xl font-black text-ink" }, (0, vue_exports.toDisplayString)(__props.sent.length), 1), (0, vue_exports.createVNode)("div", { class: "mt-1 text-xs font-semibold text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("email invites sent")), 1)])]),
						__props.sent.length ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("section", {
							key: 0,
							class: "mt-5 rounded-2xl border border-line bg-surface p-5"
						}, [(0, vue_exports.createVNode)("h2", { class: "mb-2 text-sm font-bold text-ink" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Sent invitations")), 1), (0, vue_exports.createVNode)("ul", { class: "divide-y divide-line" }, [((0, vue_exports.openBlock)(true), (0, vue_exports.createBlock)(vue_exports.Fragment, null, (0, vue_exports.renderList)(__props.sent, (s, i) => {
							return (0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("li", {
								key: i,
								class: "flex items-center justify-between py-2.5 text-sm"
							}, [(0, vue_exports.createVNode)("span", { class: "truncate text-ink-2" }, (0, vue_exports.toDisplayString)(s.email), 1), s.joined ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
								key: 0,
								class: "shrink-0 rounded-full bg-emerald-500/15 px-2 py-0.5 text-xs font-bold text-emerald-600 dark:text-emerald-400"
							}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Joined")), 1)) : ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
								key: 1,
								class: "shrink-0 text-xs text-ink-muted"
							}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Pending")) + " · " + (0, vue_exports.toDisplayString)(s.sentAt), 1))]);
						}), 128))])])) : (0, vue_exports.createCommentVNode)("", true)
					])];
				}),
				_: 1
			}, _parent));
			_push(`<!--]-->`);
		};
	}
});
//#endregion
//#region resources/js/Pages/Invite.vue
var _sfc_setup = Invite_vue_vue_type_script_setup_true_lang_default.setup;
Invite_vue_vue_type_script_setup_true_lang_default.setup = (props, ctx) => {
	const ssrContext = (0, vue_exports.useSSRContext)();
	(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/Invite.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
var Invite_default = Invite_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { Invite_default as default };
