import { c as create_ssr_component, v as validate_component, e as escape, a as each, s as spread, d as escape_attribute_value, f as escape_object } from './ssr-DX6yy04n.js'; import { I as Icon$1 } from './Icon-DFquJFK5.js'; import { A as ArrowUpRight } from './arrow-up-right-BhevyjSf.js'; import { i as is_void } from './index3-TIAgGdNz.js'; import 'clsx'; import { c as compute_rest_props } from './lifecycle-CPZ0ouVO.js'; import { B as Button, c as cn } from './button-DV8DKkH_.js'; import { T as Table, a as Table_header, b as Table_row, c as Table_head, d as Table_body, e as Table_cell } from './table-row-D2UDVzmh.js'; import 'tailwind-variants'; import './index2-CkEewRlU.js'; import './ssr2-BVSPLo1E.js'; import 'tailwind-merge'; var EN_US = ['second', 'minute', 'hour', 'day', 'week', 'month', 'year']; function en_US (diff, idx) { if (idx === 0) return ['just now', 'right now']; var unit = EN_US[Math.floor(idx / 2)]; if (diff > 1) unit += 's'; return [diff + " " + unit + " ago", "in " + diff + " " + unit]; } var ZH_CN = ['秒', '分钟', '小时', '天', '周', '个月', '年']; function zh_CN (diff, idx) { if (idx === 0) return ['刚刚', '片刻后']; var unit = ZH_CN[~~(idx / 2)]; return [diff + " " + unit + "\u524D", diff + " " + unit + "\u540E"]; } /** * Created by hustcc on 18/5/20. * Contract: i@hust.cc */ /** * All supported locales */ var Locales = {}; /** * register a locale * @param locale * @param func */ var register = function (locale, func) { Locales[locale] = func; }; /** * get a locale, default is en_US * @param locale * @returns {*} */ var getLocale = function (locale) { return Locales[locale] || Locales['en_US']; }; /** * Created by hustcc on 18/5/20. * Contract: i@hust.cc */ var SEC_ARRAY = [ 60, 60, 24, 7, 365 / 7 / 12, 12, ]; /** * format Date / string / timestamp to timestamp * @param input * @returns {*} */ function toDate(input) { if (input instanceof Date) return input; // @ts-ignore if (!isNaN(input) || /^\d+$/.test(input)) return new Date(parseInt(input)); input = (input || '') // @ts-ignore .trim() .replace(/\.\d+/, '') // remove milliseconds .replace(/-/, '/') .replace(/-/, '/') .replace(/(\d)T(\d)/, '$1 $2') .replace(/Z/, ' UTC') // 2017-2-5T3:57:52Z -> 2017-2-5 3:57:52UTC .replace(/([+-]\d\d):?(\d\d)/, ' $1$2'); // -04:00 -> -0400 return new Date(input); } /** * format the diff second to *** time ago, with setting locale * @param diff * @param localeFunc * @returns */ function formatDiff(diff, localeFunc) { /** * if locale is not exist, use defaultLocale. * if defaultLocale is not exist, use build-in `en`. * be sure of no error when locale is not exist. * * If `time in`, then 1 * If `time ago`, then 0 */ var agoIn = diff < 0 ? 1 : 0; /** * Get absolute value of number (|diff| is non-negative) value of x * |diff| = diff if diff is positive * |diff| = -diff if diff is negative * |0| = 0 */ diff = Math.abs(diff); /** * Time in seconds */ var totalSec = diff; /** * Unit of time */ var idx = 0; for (; diff >= SEC_ARRAY[idx] && idx < SEC_ARRAY.length; idx++) { diff /= SEC_ARRAY[idx]; } /** * Math.floor() is alternative of ~~ * * The differences and bugs: * Math.floor(3.7) -> 4 but ~~3.7 -> 3 * Math.floor(1559125440000.6) -> 1559125440000 but ~~1559125440000.6 -> 52311552 * * More information about the performance of algebraic: * https://www.youtube.com/watch?v=65-RbBwZQdU */ diff = Math.floor(diff); idx *= 2; if (diff > (idx === 0 ? 9 : 1)) idx += 1; return localeFunc(diff, idx, totalSec)[agoIn].replace('%s', diff.toString()); } /** * calculate the diff second between date to be formatted an now date. * @param date * @param relativeDate * @returns {number} */ function diffSec(date, relativeDate) { var relDate = relativeDate ? toDate(relativeDate) : new Date(); return (+relDate - +toDate(date)) / 1000; } /** * format a TDate into string * @param date * @param locale * @param opts */ var format = function (date, locale, opts) { // diff seconds var sec = diffSec(date, opts && opts.relativeDate); // format it with locale return formatDiff(sec, getLocale(locale)); }; /** * Created by hustcc on 18/5/20. * Contract: i@hust.cc */ register('en_US', en_US); register('zh_CN', zh_CN); const Activity = create_ssr_component(($$result, $$props, $$bindings, slots) => { const iconNode = [["path", { "d": "M22 12h-4l-3 9L9 3l-3 9H2" }]]; return `${validate_component(Icon$1, "Icon").$$render($$result, Object.assign({}, { name: "activity" }, $$props, { iconNode }), {}, { default: () => { return `${slots.default ? slots.default({}) : ``}`; } })}`; }); const Activity$1 = Activity; const Credit_card = create_ssr_component(($$result, $$props, $$bindings, slots) => { const iconNode = [ [ "rect", { "width": "20", "height": "14", "x": "2", "y": "5", "rx": "2" } ], [ "line", { "x1": "2", "x2": "22", "y1": "10", "y2": "10" } ] ]; return `${validate_component(Icon$1, "Icon").$$render($$result, Object.assign({}, { name: "credit-card" }, $$props, { iconNode }), {}, { default: () => { return `${slots.default ? slots.default({}) : ``}`; } })}`; }); const CreditCard = Credit_card; const Dollar_sign = create_ssr_component(($$result, $$props, $$bindings, slots) => { const iconNode = [ [ "line", { "x1": "12", "x2": "12", "y1": "2", "y2": "22" } ], [ "path", { "d": "M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" } ] ]; return `${validate_component(Icon$1, "Icon").$$render($$result, Object.assign({}, { name: "dollar-sign" }, $$props, { iconNode }), {}, { default: () => { return `${slots.default ? slots.default({}) : ``}`; } })}`; }); const DollarSign = Dollar_sign; const Card = create_ssr_component(($$result, $$props, $$bindings, slots) => { let $$restProps = compute_rest_props($$props, ["class"]); let { class: className = void 0 } = $$props; if ($$props.class === void 0 && $$bindings.class && className !== void 0) $$bindings.class(className); return `${slots.default ? slots.default({}) : ``}`; }); const Card_content = create_ssr_component(($$result, $$props, $$bindings, slots) => { let $$restProps = compute_rest_props($$props, ["class"]); let { class: className = void 0 } = $$props; if ($$props.class === void 0 && $$bindings.class && className !== void 0) $$bindings.class(className); return `${slots.default ? slots.default({}) : ``}`; }); const Card_description = create_ssr_component(($$result, $$props, $$bindings, slots) => { let $$restProps = compute_rest_props($$props, ["class"]); let { class: className = void 0 } = $$props; if ($$props.class === void 0 && $$bindings.class && className !== void 0) $$bindings.class(className); return `${slots.default ? slots.default({}) : ``}

`; }); const Card_header = create_ssr_component(($$result, $$props, $$bindings, slots) => { let $$restProps = compute_rest_props($$props, ["class"]); let { class: className = void 0 } = $$props; if ($$props.class === void 0 && $$bindings.class && className !== void 0) $$bindings.class(className); return `${slots.default ? slots.default({}) : ``}`; }); const Card_title = create_ssr_component(($$result, $$props, $$bindings, slots) => { let $$restProps = compute_rest_props($$props, ["class", "tag"]); let { class: className = void 0 } = $$props; let { tag = "h3" } = $$props; if ($$props.class === void 0 && $$bindings.class && className !== void 0) $$bindings.class(className); if ($$props.tag === void 0 && $$bindings.tag && tag !== void 0) $$bindings.tag(tag); return `${((tag$1) => { return tag$1 ? `<${tag}${spread( [ { class: escape_attribute_value(cn("text-lg font-semibold leading-none tracking-tight", className)) }, escape_object($$restProps) ], {} )}>${is_void(tag$1) ? "" : `${slots.default ? slots.default({}) : ``}`}${is_void(tag$1) ? "" : ``}` : ""; })(tag)}`; }); const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => { let { data } = $$props; if ($$props.data === void 0 && $$bindings.data && data !== void 0) $$bindings.data(data); return `
${validate_component(Card, "Card.Root").$$render($$result, {}, {}, { default: () => { return `${validate_component(Card_header, "Card.Header").$$render( $$result, { class: "flex flex-row items-center justify-between space-y-0 pb-2" }, {}, { default: () => { return `${validate_component(Card_title, "Card.Title").$$render($$result, { class: "text-sm font-medium" }, {}, { default: () => { return `Total Articles`; } })} ${validate_component(DollarSign, "DollarSign").$$render($$result, { class: "h-4 w-4 text-muted-foreground" }, {}, {})}`; } } )} ${validate_component(Card_content, "Card.Content").$$render($$result, {}, {}, { default: () => { return `
${escape(data.dashboard_info.totalArticles)}
`; } })}`; } })} ${validate_component(Card, "Card.Root").$$render($$result, {}, {}, { default: () => { return `${validate_component(Card_header, "Card.Header").$$render( $$result, { class: "flex flex-row items-center justify-between space-y-0 pb-2" }, {}, { default: () => { return `${validate_component(Card_title, "Card.Title").$$render($$result, { class: "text-sm font-medium" }, {}, { default: () => { return `Emails collected`; } })} ${validate_component(CreditCard, "CreditCard").$$render($$result, { class: "h-4 w-4 text-muted-foreground" }, {}, {})}`; } } )} ${validate_component(Card_content, "Card.Content").$$render($$result, {}, {}, { default: () => { return `
${escape(data.dashboard_info.totalEmails)}
`; } })}`; } })} ${validate_component(Card, "Card.Root").$$render($$result, {}, {}, { default: () => { return `${validate_component(Card_header, "Card.Header").$$render( $$result, { class: "flex flex-row items-center justify-between space-y-0 pb-2" }, {}, { default: () => { return `${validate_component(Card_title, "Card.Title").$$render($$result, { class: "text-sm font-medium" }, {}, { default: () => { return `Reads`; } })} ${validate_component(Activity$1, "Activity").$$render($$result, { class: "h-4 w-4 text-muted-foreground" }, {}, {})}`; } } )} ${validate_component(Card_content, "Card.Content").$$render($$result, {}, {}, { default: () => { return `
${escape(data.dashboard_info.totalViews)}
`; } })}`; } })}
${validate_component(Card, "Card.Root").$$render( $$result, { class: "xl:col-span-2", style: "height: min-content" }, {}, { default: () => { return `${validate_component(Card_header, "Card.Header").$$render($$result, { class: "flex flex-row items-center" }, {}, { default: () => { return `
${validate_component(Card_title, "Card.Title").$$render($$result, {}, {}, { default: () => { return `Articles`; } })} ${validate_component(Card_description, "Card.Description").$$render($$result, {}, {}, { default: () => { return `Recent articles written from your youtube videos.`; } })}
${validate_component(Button, "Button").$$render( $$result, { href: "/articles", size: "sm", class: "ml-auto gap-1" }, {}, { default: () => { return `View All ${validate_component(ArrowUpRight, "ArrowUpRight").$$render($$result, { class: "h-4 w-4" }, {}, {})}`; } } )}`; } })} ${validate_component(Card_content, "Card.Content").$$render($$result, {}, {}, { default: () => { return `${validate_component(Table, "Table.Root").$$render($$result, {}, {}, { default: () => { return `${validate_component(Table_header, "Table.Header").$$render($$result, {}, {}, { default: () => { return `${validate_component(Table_row, "Table.Row").$$render($$result, {}, {}, { default: () => { return `${validate_component(Table_head, "Table.Head").$$render($$result, {}, {}, { default: () => { return `Title`; } })} ${validate_component(Table_head, "Table.Head").$$render($$result, { class: "xl:table.-column text-right" }, {}, { default: () => { return `Date`; } })} ${validate_component(Table_head, "Table.Head").$$render($$result, { class: "xl:table.-column text-right" }, {}, { default: () => { return `Views`; } })}`; } })}`; } })} ${validate_component(Table_body, "Table.Body").$$render($$result, {}, {}, { default: () => { return `${each(data.dashboard_info.recentArticles, (article) => { return `${validate_component(Table_row, "Table.Row").$$render($$result, {}, {}, { default: () => { return `${validate_component(Table_cell, "Table.Cell").$$render($$result, {}, {}, { default: () => { return `
${escape(article.title)}
`; } })} ${validate_component(Table_cell, "Table.Cell").$$render($$result, { class: "text-right" }, {}, { default: () => { return `${escape(new Date(article.created_at).toLocaleDateString())}`; } })} ${validate_component(Table_cell, "Table.Cell").$$render($$result, { class: "text-right" }, {}, { default: () => { return `${escape(article.views)}`; } })} `; } })}`; })}`; } })}`; } })}`; } })}`; } } )} ${validate_component(Card, "Card.Root").$$render($$result, {}, {}, { default: () => { return `${validate_component(Card_header, "Card.Header").$$render($$result, { class: "flex flex-row items-center" }, {}, { default: () => { return `
${validate_component(Card_title, "Card.Title").$$render($$result, {}, {}, { default: () => { return `Recent Signups`; } })}
${validate_component(Button, "Button").$$render( $$result, { href: "/emails", size: "sm", class: "ml-auto gap-1" }, {}, { default: () => { return `View All ${validate_component(ArrowUpRight, "ArrowUpRight").$$render($$result, { class: "h-4 w-4" }, {}, {})}`; } } )}`; } })} ${validate_component(Card_content, "Card.Content").$$render($$result, { class: "grid gap-8" }, {}, { default: () => { return `${each(data.dashboard_info.recentSignups, (signup) => { return `

${escape(signup.email)}

${escape(signup.created_at > 1e3 * 60 * 60 * 24 * 7 ? new Date(signup.created_at).toLocaleDateString() : format(new Date(signup.created_at)))}
`; })}`; } })}`; } })}
`; }); export { Page as default }; //# sourceMappingURL=_page.svelte-C_GxIhkp.js.map