513 lines
18 KiB
JavaScript
513 lines
18 KiB
JavaScript
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-CuupvqYU.js';
|
|
import { A as ArrowUpRight } from './arrow-up-right-DJbSpoIi.js';
|
|
import { i as is_void } from './index3-SQiErCxY.js';
|
|
import 'clsx';
|
|
import { c as compute_rest_props } from './lifecycle-CPZ0ouVO.js';
|
|
import { B as Button, c as cn } from './button-B4Y4m1ML.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-RSbyCJ0O.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 `<div${spread(
|
|
[
|
|
{
|
|
class: escape_attribute_value(cn("rounded-lg border bg-card text-card-foreground shadow-sm", className))
|
|
},
|
|
escape_object($$restProps)
|
|
],
|
|
{}
|
|
)}>${slots.default ? slots.default({}) : ``}</div>`;
|
|
});
|
|
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 `<div${spread(
|
|
[
|
|
{
|
|
class: escape_attribute_value(cn("p-6 pt-0", className))
|
|
},
|
|
escape_object($$restProps)
|
|
],
|
|
{}
|
|
)}>${slots.default ? slots.default({}) : ``}</div>`;
|
|
});
|
|
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 `<p${spread(
|
|
[
|
|
{
|
|
class: escape_attribute_value(cn("text-sm text-muted-foreground", className))
|
|
},
|
|
escape_object($$restProps)
|
|
],
|
|
{}
|
|
)}>${slots.default ? slots.default({}) : ``}</p>`;
|
|
});
|
|
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 `<div${spread(
|
|
[
|
|
{
|
|
class: escape_attribute_value(cn("flex flex-col space-y-1.5 p-6", className))
|
|
},
|
|
escape_object($$restProps)
|
|
],
|
|
{}
|
|
)}>${slots.default ? slots.default({}) : ``}</div>`;
|
|
});
|
|
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$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 `<div class="grid gap-4 md:grid-cols-2 md:gap-8 lg:grid-cols-3">${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 `<div class="text-2xl font-bold">${escape(data.dashboard_info.totalArticles)}</div> `;
|
|
}
|
|
})}`;
|
|
}
|
|
})} ${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 `<div class="text-2xl font-bold">${escape(data.dashboard_info.totalEmails)}</div> `;
|
|
}
|
|
})}`;
|
|
}
|
|
})} ${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 `<div class="text-2xl font-bold">${escape(data.dashboard_info.totalViews)}</div> `;
|
|
}
|
|
})}`;
|
|
}
|
|
})}</div> <div class="grid gap-4 md:gap-8 lg:grid-cols-2 xl:grid-cols-3">${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 `<div class="grid gap-2">${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.`;
|
|
}
|
|
})}</div> ${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 `<div class="overflow-ellipsis font-medium">${escape(article.title)}</div> `;
|
|
}
|
|
})} ${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 `<div class="grid gap-2">${validate_component(Card_title, "Card.Title").$$render($$result, {}, {}, {
|
|
default: () => {
|
|
return `Recent Signups`;
|
|
}
|
|
})} </div> ${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 `<div class="flex items-center gap-4"> <div class="grid gap-1"> <p class="text-sm">${escape(signup.email)}</p></div> <div class="ml-auto font-medium">${escape(signup.created_at > 1e3 * 60 * 60 * 24 * 7 ? new Date(signup.created_at).toLocaleDateString() : format(new Date(signup.created_at)))}</div> </div>`;
|
|
})}`;
|
|
}
|
|
})}`;
|
|
}
|
|
})}</div> `;
|
|
});
|
|
|
|
export { Page as default };
|
|
//# sourceMappingURL=_page.svelte-ChkNLoNc.js.map
|