@articles-media/articles-dev-box 1.0.16 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/dist/Ad-Ck5UdTq3.js +387 -0
- package/dist/Ad-DYtftKNV.cjs +1 -0
- package/dist/Ad.cjs +1 -1
- package/dist/Ad.js +2 -604
- package/dist/AdConfirmExitModal-CJ-HtcVC.js +56 -0
- package/dist/AdConfirmExitModal-CRCnzYQM.cjs +1 -0
- package/dist/AdDetailsModal-DRNRTL2W.js +108 -0
- package/dist/AdDetailsModal-g0n7LiV6.cjs +1 -0
- package/dist/ArticlesAd.cjs +1 -1
- package/dist/ArticlesAd.js +16 -15
- package/dist/Button-BlAdEbSd.js +30 -0
- package/dist/Button-CbpRj01E.cjs +1 -0
- package/dist/CreditsModal.cjs +1 -0
- package/dist/CreditsModal.js +56 -0
- package/dist/DarkModeHandler.cjs +1 -0
- package/dist/DarkModeHandler.js +18 -0
- package/dist/FriendsList.cjs +1 -1
- package/dist/FriendsList.js +77 -121
- package/dist/GameScoreboard-CBY3JsFa.js +165 -0
- package/dist/GameScoreboard-DdOCRxON.cjs +1 -0
- package/dist/GameScoreboard.cjs +1 -1
- package/dist/GameScoreboard.js +2 -190
- package/dist/GlobalBody.cjs +33 -1
- package/dist/GlobalBody.js +36 -7
- package/dist/GlobalHead.cjs +1 -1
- package/dist/GlobalHead.js +10 -12
- package/dist/Link-MFZblBb4.js +17 -0
- package/dist/Link-c7exNCJ3.cjs +1 -0
- package/dist/Modal-BX1s6CCU.js +1631 -0
- package/dist/Modal-DP9CeAVD.cjs +3 -0
- package/dist/ReturnToLauncherButton.cjs +1 -1
- package/dist/ReturnToLauncherButton.js +39 -54
- package/dist/SettingsModal--sWLmLGp.cjs +1 -0
- package/dist/SettingsModal-XI2dMI09.js +247 -0
- package/dist/SettingsModal.cjs +1 -0
- package/dist/SettingsModal.js +2 -0
- package/dist/StatusModal-D7WDDR9P.cjs +1 -0
- package/dist/StatusModal-elrPJvX1.js +70 -0
- package/dist/ViewUserModal-DDjWLpyM.js +3094 -0
- package/dist/ViewUserModal-DPVcjXNU.cjs +1 -0
- package/dist/ViewUserModal.cjs +1 -1
- package/dist/ViewUserModal.js +3 -3189
- package/dist/articles-dev-box.css +2 -1
- package/dist/chunk-350yNsax.cjs +1 -0
- package/dist/classnames-DP6dWde5.js +31 -0
- package/dist/classnames-pS64X3rL.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +16 -24
- package/dist/jsx-runtime-VZk6y-ec.js +191 -0
- package/dist/jsx-runtime-hCcDh67y.cjs +6 -0
- package/dist/numberWithCommas-BSKBdR-e.js +18 -0
- package/dist/numberWithCommas-D9tgiUnq.cjs +1 -0
- package/dist/useAuthSiteStatus-1rHjYC4N.js +29 -0
- package/dist/useAuthSiteStatus-P5kHc_Bz.cjs +1 -0
- package/dist/useFullscreen.cjs +1 -0
- package/dist/useFullscreen.js +24 -0
- package/dist/useUserDetails.cjs +1 -1
- package/dist/useUserDetails.js +22 -32
- package/dist/useUserFriends.cjs +1 -1
- package/dist/useUserFriends.js +29 -51
- package/dist/useUserToken.cjs +1 -1
- package/dist/useUserToken.js +16 -21
- package/package.json +25 -10
- package/dist/AdConfirmExitModal-CKkMAvBK.js +0 -72
- package/dist/AdConfirmExitModal-CcSxmXKT.cjs +0 -1
- package/dist/AdDetailsModal-Bp5hZm9N.js +0 -83
- package/dist/AdDetailsModal-k840vrS2.cjs +0 -1
- package/dist/Button-0ZK0NKiK.cjs +0 -1
- package/dist/Button-_Quon8UV.js +0 -54
- package/dist/GlobalBody-BQ2qC81K.cjs +0 -33
- package/dist/GlobalBody-tmIC_GWn.js +0 -123
- package/dist/Modal-C9oYRgI1.js +0 -2073
- package/dist/Modal-Wmqy9fOm.cjs +0 -2
- package/dist/StatusModal-BlwaI-2B.cjs +0 -1
- package/dist/StatusModal-CAVxWCUq.js +0 -71
- package/dist/index-BlP2-uOi.cjs +0 -1
- package/dist/index-DLYx67wi.js +0 -2394
- package/dist/index-Ddv_TnxK.cjs +0 -6
- package/dist/index-YnD2EP-S.js +0 -43
- package/dist/jsx-runtime-nZSsnGb7.cjs +0 -6
- package/dist/jsx-runtime-tc70JA_2.js +0 -264
- package/dist/numberWithCommas-CRgrb58X.cjs +0 -1
- package/dist/numberWithCommas-DnAkiOFL.js +0 -1256
package/README.md
CHANGED
|
@@ -47,18 +47,23 @@ npm run dev
|
|
|
47
47
|
- Easy way to add future logic and components to all projects with ease. For now handling the font awesome script. Also shows connection status to required servers in development. Will ping the main and auth server as they are needed for some dev-box features.
|
|
48
48
|
- ViewUserModal
|
|
49
49
|
- View user profile data and recent activity.
|
|
50
|
+
- SettingsModal
|
|
51
|
+
- All in one component to handle game settings UI across multiple games.
|
|
52
|
+
- CreditsModal
|
|
53
|
+
- All in one component to handle game credits UI across multiple games.
|
|
54
|
+
- DarkModeHandler
|
|
55
|
+
- Consumes a Zustand store, detects prefers-color-scheme, sets data-bs-theme on body element.
|
|
50
56
|
- useUserToken
|
|
51
57
|
- Hook for getting the subdomain auth token.
|
|
52
58
|
- useUserDetails
|
|
53
59
|
- Hook for getting the details of the current user if a valid user token is found.
|
|
60
|
+
- useFullscreen
|
|
61
|
+
- Hook for going fullscreen on the body or provided element
|
|
54
62
|
|
|
55
63
|
# Roadmap
|
|
56
64
|
⏹️ Remove Bootstrap reliance
|
|
57
|
-
⏹️
|
|
58
|
-
⏹️ Automatic GitHub Action for NPM are done but need to figure out how to show verified build badge on NPM.
|
|
59
|
-
⏹️ Figure out why this package does not work outside webpack, on Turbopack for example it fails.
|
|
60
|
-
|
|
65
|
+
⏹️ Figure out why this package does not work outside webpack, on Turbopack for example it fails. Bootstrap SASS related I think.
|
|
61
66
|
|
|
62
67
|
# TODO
|
|
63
|
-
- Bundle SCSS on a component level instead of a project level.
|
|
68
|
+
- Bundle SCSS on a component level instead of a project level.
|
|
64
69
|
- Verify I am exporting components the most efficient way.
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { r as e, t } from "./jsx-runtime-VZk6y-ec.js";
|
|
2
|
+
import { t as n } from "./classnames-DP6dWde5.js";
|
|
3
|
+
import { t as r } from "./Button-BlAdEbSd.js";
|
|
4
|
+
import { t as i } from "./Link-MFZblBb4.js";
|
|
5
|
+
import { n as a, t as o } from "./numberWithCommas-BSKBdR-e.js";
|
|
6
|
+
import { lazy as s, memo as c, useEffect as l, useState as u } from "react";
|
|
7
|
+
import { useInView as d } from "react-intersection-observer";
|
|
8
|
+
import f from "swr";
|
|
9
|
+
import { differenceInMinutes as p, minutesToMilliseconds as m } from "date-fns";
|
|
10
|
+
//#region src/hooks/Ads/useAd.js
|
|
11
|
+
var h = async (e) => {
|
|
12
|
+
if (process.env.NODE_ENV === "development") try {
|
|
13
|
+
let t = new URLSearchParams({
|
|
14
|
+
ad_id: e.ad_id,
|
|
15
|
+
user_ad_token: e.user_ad_token
|
|
16
|
+
}).toString();
|
|
17
|
+
return (await (await fetch(`http://localhost:3001/api/ads/${e.ad_id}?${t}`)).json()).result;
|
|
18
|
+
} catch {}
|
|
19
|
+
let t = new URLSearchParams({ ad_id: e.ad_id }).toString();
|
|
20
|
+
return fetch(`${e.url}?${t}`).then((e) => e.json()).then((e) => e.result);
|
|
21
|
+
}, g = { dedupingInterval: 1e3 * 60 * 60 }, _ = (e, t) => {
|
|
22
|
+
let { data: n, error: r, isLoading: i, mutate: a } = f(e ? {
|
|
23
|
+
url: `https://articles.media/api/ads/${e}`,
|
|
24
|
+
ad_id: e,
|
|
25
|
+
user_ad_token: t
|
|
26
|
+
} : null, h, g);
|
|
27
|
+
return {
|
|
28
|
+
data: n,
|
|
29
|
+
error: r,
|
|
30
|
+
isLoading: i,
|
|
31
|
+
mutate: a
|
|
32
|
+
};
|
|
33
|
+
}, v = async (e) => {
|
|
34
|
+
if (process.env.NODE_ENV === "development") try {
|
|
35
|
+
return await (await fetch("http://localhost:3001/api/ads")).json();
|
|
36
|
+
} catch {}
|
|
37
|
+
return fetch(e.url).then((e) => e.json());
|
|
38
|
+
}, y = 60, b = {
|
|
39
|
+
dedupingInterval: m(y),
|
|
40
|
+
focusThrottleInterval: m(y)
|
|
41
|
+
}, x = (e) => {
|
|
42
|
+
let { data: t, error: n, isLoading: r, mutate: i } = f(e?.loading || e?.disabled ? null : { url: "https://articles.media/api/ads" }, v, b);
|
|
43
|
+
return {
|
|
44
|
+
data: t,
|
|
45
|
+
error: n,
|
|
46
|
+
isLoading: r,
|
|
47
|
+
mutate: i
|
|
48
|
+
};
|
|
49
|
+
}, S = t(), C = /* @__PURE__ */ e(n(), 1), w = s(() => import("./AdDetailsModal-DRNRTL2W.js")), T = s(() => import("./AdConfirmExitModal-CJ-HtcVC.js"));
|
|
50
|
+
function E(e, t) {
|
|
51
|
+
return Math.floor(Math.random() * (t - e + 1)) + e;
|
|
52
|
+
}
|
|
53
|
+
function D(e) {
|
|
54
|
+
let { previewMode: t, darkMode: n, user_ad_token: s, userDetails: c, userDetailsLoading: f, prepend: m, append: h } = e, g = [], [v, y] = u(null), { data: b, isLoading: D, mutate: O } = x({
|
|
55
|
+
loading: f,
|
|
56
|
+
disabled: c?.articles_membership?.status == "Active"
|
|
57
|
+
}), { data: k, isLoading: ee } = _(v, s), A = e.previewData || {}, [te, ne] = u(null), [j, M] = u(null), [N, P] = u(null), [F, I] = u(0), [L, R] = u(!1), [z, B] = u(!1), [V, H] = u(!1), [re, ie] = u(/* @__PURE__ */ new Date()), [U, W] = u([]);
|
|
58
|
+
l(() => {
|
|
59
|
+
b && b?.length > 0 && !v && (console.log("Ad Mounted or reduxAds changed"), y(e.ad_id || b[E(0, b?.length - 1)]?._id));
|
|
60
|
+
}, [b]), l(() => {}, [k]), l(() => {
|
|
61
|
+
k?.populated_promos && F >= 0 && P(k?.populated_promos[F]);
|
|
62
|
+
}, [F, k]);
|
|
63
|
+
function G() {
|
|
64
|
+
B(!z);
|
|
65
|
+
}
|
|
66
|
+
let { ref: K, inView: q, entry: ae } = d({
|
|
67
|
+
threshold: 0,
|
|
68
|
+
triggerOnce: !0
|
|
69
|
+
});
|
|
70
|
+
function J(e) {
|
|
71
|
+
if (t && console.log("Preventing this event from being logged as this ad is being shown in preview mode."), U.find((t) => t == e)) {
|
|
72
|
+
console.log("Already logged this event");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
let n = new URLSearchParams({
|
|
76
|
+
ad_id: k?._id,
|
|
77
|
+
event: e
|
|
78
|
+
}).toString();
|
|
79
|
+
fetch(`/api/ads/event?${n}`).then(function(e) {
|
|
80
|
+
return e.json();
|
|
81
|
+
}).then(function(t) {
|
|
82
|
+
W([...U, e]), console.log(t);
|
|
83
|
+
}).catch(function(e) {
|
|
84
|
+
console.log(e);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
l(() => {
|
|
88
|
+
if (!t && (console.log("inView", q), q && v)) {
|
|
89
|
+
let e = [{
|
|
90
|
+
ad_id: v,
|
|
91
|
+
date: (/* @__PURE__ */ new Date()).toString()
|
|
92
|
+
}, ...g.filter((e) => {
|
|
93
|
+
if (console.log(p(/* @__PURE__ */ new Date(), new Date(e.date))), p(/* @__PURE__ */ new Date(), new Date(e.date)) > 5) {
|
|
94
|
+
console.log("adsViewed - Remove Old Ad View Object");
|
|
95
|
+
return;
|
|
96
|
+
} else return console.log("adsViewed - Keep Ad View Object"), e;
|
|
97
|
+
})];
|
|
98
|
+
console.log("unexpiredRecentViews", e);
|
|
99
|
+
}
|
|
100
|
+
}, [q, v]);
|
|
101
|
+
let [Y, X] = u(null), [Z, Q] = u(!1);
|
|
102
|
+
function $() {
|
|
103
|
+
Q(!0), console.log("logAdAvoided called", s);
|
|
104
|
+
let e = process.env.NODE_ENV === "development" ? "http://localhost:3001/api/user/advertising/avoided" : "https://articles.media/api/user/advertising/avoided", t = new URLSearchParams({ user_id: c?._id }).toString();
|
|
105
|
+
fetch(`${e}?${t}`, { headers: { "x-articles-api-key": s } }).then(function(e) {
|
|
106
|
+
return e.json();
|
|
107
|
+
}).then(function(e) {
|
|
108
|
+
Q(!1), X(e.avoided_count), console.log(e);
|
|
109
|
+
}).catch(function(e) {
|
|
110
|
+
console.log(e), Q(!1);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return l(() => {
|
|
114
|
+
t || (console.log("inView", q), c?.articles_membership?.status == "Active" && q && $("Ad Avoided"));
|
|
115
|
+
}, [q, c]), f ? null : /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
116
|
+
ref: K,
|
|
117
|
+
className: (0, C.default)("ad-wrap", { "active-member": c?.articles_membership?.status == "Active" }),
|
|
118
|
+
style: {
|
|
119
|
+
"--articles-ad-background-color": A.background_color || k?.background_color,
|
|
120
|
+
"--articles-ad-font-color": A.font_color || k?.font_color,
|
|
121
|
+
"--articles-ad-border-color": A.border_color || k?.border_color
|
|
122
|
+
},
|
|
123
|
+
children: [
|
|
124
|
+
z && /* @__PURE__ */ (0, S.jsx)(w, {
|
|
125
|
+
setModalShow: B,
|
|
126
|
+
ad: k,
|
|
127
|
+
previewData: A
|
|
128
|
+
}),
|
|
129
|
+
V && /* @__PURE__ */ (0, S.jsx)(T, {
|
|
130
|
+
setModalShow: H,
|
|
131
|
+
ad: k,
|
|
132
|
+
previewData: A
|
|
133
|
+
}),
|
|
134
|
+
m && /* @__PURE__ */ (0, S.jsx)("div", {
|
|
135
|
+
className: "prepend-container",
|
|
136
|
+
children: m
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
139
|
+
className: "ad",
|
|
140
|
+
children: [c?.articles_membership?.status !== "Active" && /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
141
|
+
className: "main-panel",
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ (0, S.jsx)("div", {
|
|
144
|
+
className: "ad-warning flex-header",
|
|
145
|
+
children: /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
146
|
+
className: "",
|
|
147
|
+
children: [k?.city && "Local", " Advertisement"]
|
|
148
|
+
})
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
151
|
+
className: "content-wrap",
|
|
152
|
+
children: [/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
153
|
+
className: "photo-banner",
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ (0, S.jsx)("div", {
|
|
156
|
+
className: "logo",
|
|
157
|
+
children: (A.logo?.location || k?.logo?.location) && /* @__PURE__ */ (0, S.jsx)("img", {
|
|
158
|
+
src: A?.logo?.key ? `${process.env.NEXT_PUBLIC_CDN}${A?.logo?.key}` : `${process.env.NEXT_PUBLIC_CDN}${k?.logo?.key}`,
|
|
159
|
+
alt: ""
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ (0, S.jsx)("div", {
|
|
163
|
+
className: "icon d-none",
|
|
164
|
+
children: /* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-mug-hot" })
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ (0, S.jsx)("img", {
|
|
167
|
+
className: "photo",
|
|
168
|
+
src: A?.background?.key ? `${process.env.NEXT_PUBLIC_CDN}${A.background?.key}` : `${process.env.NEXT_PUBLIC_CDN}${k?.background?.key}`,
|
|
169
|
+
alt: ""
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
}), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
173
|
+
className: "details-wrap",
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
176
|
+
className: "detail-title",
|
|
177
|
+
children: [/* @__PURE__ */ (0, S.jsx)("div", {
|
|
178
|
+
className: "detail",
|
|
179
|
+
children: /* @__PURE__ */ (0, S.jsx)("span", {
|
|
180
|
+
className: "h4",
|
|
181
|
+
children: A?.business || k?.business
|
|
182
|
+
})
|
|
183
|
+
}), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
184
|
+
className: "flex flex-column d-none",
|
|
185
|
+
children: [/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
186
|
+
className: "detail",
|
|
187
|
+
children: [/* @__PURE__ */ (0, S.jsx)("span", {
|
|
188
|
+
className: "icon",
|
|
189
|
+
children: /* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-search-location" })
|
|
190
|
+
}), /* @__PURE__ */ (0, S.jsxs)("span", { children: [
|
|
191
|
+
k?.city,
|
|
192
|
+
", ",
|
|
193
|
+
k?.state
|
|
194
|
+
] })]
|
|
195
|
+
}), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
196
|
+
className: "detail",
|
|
197
|
+
children: [/* @__PURE__ */ (0, S.jsx)("span", {
|
|
198
|
+
className: "icon",
|
|
199
|
+
children: /* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-clock me-2" })
|
|
200
|
+
}), /* @__PURE__ */ (0, S.jsx)("span", { children: "6:30AM–8PM" })]
|
|
201
|
+
})]
|
|
202
|
+
})]
|
|
203
|
+
}),
|
|
204
|
+
k?.city && /* @__PURE__ */ (0, S.jsx)("div", { className: "details mb-3 d-none" }),
|
|
205
|
+
/* @__PURE__ */ (0, S.jsx)("div", {
|
|
206
|
+
className: "short-description",
|
|
207
|
+
children: A?.description || k?.description
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
})]
|
|
211
|
+
}),
|
|
212
|
+
(!1)?.roles?.isDev && k?.populated_promos?.length > 0 && /* @__PURE__ */ (0, S.jsxs)("div", { children: [N && /* @__PURE__ */ (0, S.jsx)("div", {
|
|
213
|
+
className: "promos-wrap",
|
|
214
|
+
children: N && /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
215
|
+
className: "promo-wrap d-flex justify-content-between align-items-center mx-2 p-1 px-2 border border-2 border-light mb-0",
|
|
216
|
+
children: [/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
217
|
+
className: "",
|
|
218
|
+
children: [/* @__PURE__ */ (0, S.jsx)("div", { children: N.title }), /* @__PURE__ */ (0, S.jsx)("div", {
|
|
219
|
+
className: "small",
|
|
220
|
+
children: /* @__PURE__ */ (0, S.jsx)("div", {
|
|
221
|
+
className: "small",
|
|
222
|
+
children: N.details
|
|
223
|
+
})
|
|
224
|
+
})]
|
|
225
|
+
}), /* @__PURE__ */ (0, S.jsx)(r, {
|
|
226
|
+
className: "px-3",
|
|
227
|
+
small: !0,
|
|
228
|
+
onClick: () => {
|
|
229
|
+
console.log("Load Save Modal"), R(!0);
|
|
230
|
+
},
|
|
231
|
+
children: "Save"
|
|
232
|
+
})]
|
|
233
|
+
}, N._id)
|
|
234
|
+
}), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
235
|
+
className: "d-flex justify-content-between",
|
|
236
|
+
children: [/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
237
|
+
className: "px-2",
|
|
238
|
+
children: [k?.populated_promos?.length, " Promos Active"]
|
|
239
|
+
}), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
240
|
+
className: "controls",
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ (0, S.jsx)("i", {
|
|
243
|
+
className: "fad fa-arrow-circle-left",
|
|
244
|
+
type: "button",
|
|
245
|
+
onClick: () => {
|
|
246
|
+
I(F == 0 ? k?.populated_promos?.length - 1 : (e) => e - 1);
|
|
247
|
+
}
|
|
248
|
+
}),
|
|
249
|
+
k?.populated_promos?.map((e, t) => /* @__PURE__ */ (0, S.jsx)("i", { className: `fa-square ${t == F ? "fad" : "fas"}` }, e._id)),
|
|
250
|
+
/* @__PURE__ */ (0, S.jsx)("i", {
|
|
251
|
+
className: "fad fa-arrow-circle-right",
|
|
252
|
+
type: "button",
|
|
253
|
+
onClick: () => {
|
|
254
|
+
F == k?.populated_promos?.length - 1 ? I(0) : I((e) => e + 1);
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
})]
|
|
259
|
+
})] }),
|
|
260
|
+
/* @__PURE__ */ (0, S.jsx)("hr", {
|
|
261
|
+
style: { borderColor: "white" },
|
|
262
|
+
className: "mt-auto mb-0"
|
|
263
|
+
}),
|
|
264
|
+
/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
265
|
+
className: "action-wrap d-flex justify-content-lg-between px-3 py-2",
|
|
266
|
+
children: [
|
|
267
|
+
/* @__PURE__ */ (0, S.jsx)("div", {
|
|
268
|
+
onClick: () => {
|
|
269
|
+
G(), J("Details");
|
|
270
|
+
},
|
|
271
|
+
className: "action flex-grow-1 flex-shrink-0",
|
|
272
|
+
children: "Details"
|
|
273
|
+
}),
|
|
274
|
+
/* @__PURE__ */ (0, S.jsx)("span", { className: "px-4" }),
|
|
275
|
+
/* @__PURE__ */ (0, S.jsx)("a", {
|
|
276
|
+
className: "action flex-grow-1 flex-shrink-0",
|
|
277
|
+
href: k?.website,
|
|
278
|
+
target: "_blank",
|
|
279
|
+
rel: "noreferrer",
|
|
280
|
+
onClick: (e) => {
|
|
281
|
+
e.preventDefault(), H(!0), J("Confirm Exit Modal Opened");
|
|
282
|
+
},
|
|
283
|
+
children: /* @__PURE__ */ (0, S.jsx)("div", { children: "Website" })
|
|
284
|
+
})
|
|
285
|
+
]
|
|
286
|
+
})
|
|
287
|
+
]
|
|
288
|
+
}), c?.articles_membership?.status == "Active" && /* @__PURE__ */ (0, S.jsx)("div", {
|
|
289
|
+
className: "main-panel",
|
|
290
|
+
children: /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
291
|
+
className: "content-wrap",
|
|
292
|
+
children: [/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
293
|
+
className: "photo-banner",
|
|
294
|
+
children: [
|
|
295
|
+
/* @__PURE__ */ (0, S.jsx)("div", { className: "logo" }),
|
|
296
|
+
/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
297
|
+
className: "splash",
|
|
298
|
+
children: [/* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-broadcast-tower" }), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
299
|
+
className: "text",
|
|
300
|
+
children: [/* @__PURE__ */ (0, S.jsx)("div", {
|
|
301
|
+
className: "count",
|
|
302
|
+
children: Z ? /* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-spinner fa-spin me-0" }) : Y ? o(Y) : 0
|
|
303
|
+
}), /* @__PURE__ */ (0, S.jsx)("div", {
|
|
304
|
+
className: "label",
|
|
305
|
+
children: "ads avoided."
|
|
306
|
+
})]
|
|
307
|
+
})]
|
|
308
|
+
}),
|
|
309
|
+
/* @__PURE__ */ (0, S.jsxs)("div", {
|
|
310
|
+
className: "member-since",
|
|
311
|
+
children: ["Member since: ", /* @__PURE__ */ (0, S.jsx)(a, {
|
|
312
|
+
format: "PP",
|
|
313
|
+
date: c?.articles_membership?.membership_started
|
|
314
|
+
})]
|
|
315
|
+
})
|
|
316
|
+
]
|
|
317
|
+
}), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
318
|
+
className: "details-wrap",
|
|
319
|
+
children: [/* @__PURE__ */ (0, S.jsx)("div", {
|
|
320
|
+
className: "detail-title",
|
|
321
|
+
children: /* @__PURE__ */ (0, S.jsx)("div", {
|
|
322
|
+
className: "detail",
|
|
323
|
+
children: /* @__PURE__ */ (0, S.jsx)("span", {
|
|
324
|
+
className: "h4",
|
|
325
|
+
children: "Thanks for the support!"
|
|
326
|
+
})
|
|
327
|
+
})
|
|
328
|
+
}), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
329
|
+
className: "short-description",
|
|
330
|
+
children: [/* @__PURE__ */ (0, S.jsx)("div", {
|
|
331
|
+
className: "mb-2",
|
|
332
|
+
children: "Without support from users like you, we wouldn't be here."
|
|
333
|
+
}), /* @__PURE__ */ (0, S.jsxs)("div", {
|
|
334
|
+
className: "links-list",
|
|
335
|
+
children: [
|
|
336
|
+
/* @__PURE__ */ (0, S.jsxs)(i, {
|
|
337
|
+
newPage: !0,
|
|
338
|
+
className: "link-item",
|
|
339
|
+
href: "https://articles.media/messages",
|
|
340
|
+
children: [/* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-comments-alt" }), "0 unread messages."]
|
|
341
|
+
}),
|
|
342
|
+
/* @__PURE__ */ (0, S.jsxs)(i, {
|
|
343
|
+
newPage: !0,
|
|
344
|
+
className: "link-item",
|
|
345
|
+
href: "https://articles.media/settings/notifications",
|
|
346
|
+
onClick: () => {
|
|
347
|
+
$();
|
|
348
|
+
},
|
|
349
|
+
children: [/* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-bell" }), "0 notifications."]
|
|
350
|
+
}),
|
|
351
|
+
/* @__PURE__ */ (0, S.jsxs)(i, {
|
|
352
|
+
newPage: !0,
|
|
353
|
+
className: "link-item",
|
|
354
|
+
href: "https://articles.media/settings/account",
|
|
355
|
+
children: [/* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-cog" }), "Manage account settings."]
|
|
356
|
+
})
|
|
357
|
+
]
|
|
358
|
+
})]
|
|
359
|
+
})]
|
|
360
|
+
})]
|
|
361
|
+
})
|
|
362
|
+
})]
|
|
363
|
+
}),
|
|
364
|
+
h && /* @__PURE__ */ (0, S.jsx)("div", {
|
|
365
|
+
className: "append-container",
|
|
366
|
+
children: h
|
|
367
|
+
}),
|
|
368
|
+
!t && /* @__PURE__ */ (0, S.jsx)("div", {
|
|
369
|
+
className: "advertise-with-us p-1",
|
|
370
|
+
style: {
|
|
371
|
+
backgroundColor: A.background_color || k?.background_color,
|
|
372
|
+
color: A.font_color || k?.font_color,
|
|
373
|
+
borderColor: A.border_color || k?.border_color
|
|
374
|
+
},
|
|
375
|
+
children: /* @__PURE__ */ (0, S.jsxs)(i, {
|
|
376
|
+
className: "small d-block w-100 text-center",
|
|
377
|
+
href: "https://articles.media/advertising",
|
|
378
|
+
newPage: !0,
|
|
379
|
+
children: [/* @__PURE__ */ (0, S.jsx)("i", { className: "fas fa-share me-1" }), "Advertise with Articles Media!"]
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
]
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
var O = c(D);
|
|
386
|
+
//#endregion
|
|
387
|
+
export { O as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./chunk-350yNsax.cjs`),t=require(`./classnames-pS64X3rL.cjs`),n=require(`./jsx-runtime-hCcDh67y.cjs`),r=require(`./Button-CbpRj01E.cjs`),i=require(`./Link-c7exNCJ3.cjs`),a=require(`./numberWithCommas-D9tgiUnq.cjs`);let o=require(`react`),s=require(`react-intersection-observer`),c=require(`swr`);c=e.n(c);let l=require(`date-fns`);var u=async e=>{if(process.env.NODE_ENV===`development`)try{let t=new URLSearchParams({ad_id:e.ad_id,user_ad_token:e.user_ad_token}).toString();return(await(await fetch(`http://localhost:3001/api/ads/${e.ad_id}?${t}`)).json()).result}catch{}let t=new URLSearchParams({ad_id:e.ad_id}).toString();return fetch(`${e.url}?${t}`).then(e=>e.json()).then(e=>e.result)},d={dedupingInterval:1e3*60*60},f=(e,t)=>{let{data:n,error:r,isLoading:i,mutate:a}=(0,c.default)(e?{url:`https://articles.media/api/ads/${e}`,ad_id:e,user_ad_token:t}:null,u,d);return{data:n,error:r,isLoading:i,mutate:a}},p=async e=>{if(process.env.NODE_ENV===`development`)try{return await(await fetch(`http://localhost:3001/api/ads`)).json()}catch{}return fetch(e.url).then(e=>e.json())},m=60,h={dedupingInterval:(0,l.minutesToMilliseconds)(m),focusThrottleInterval:(0,l.minutesToMilliseconds)(m)},g=e=>{let{data:t,error:n,isLoading:r,mutate:i}=(0,c.default)(e?.loading||e?.disabled?null:{url:`https://articles.media/api/ads`},p,h);return{data:t,error:n,isLoading:r,mutate:i}},_=n.t(),v=e.n(t.t(),1),y=(0,o.lazy)(()=>Promise.resolve().then(()=>require(`./AdDetailsModal-g0n7LiV6.cjs`))),b=(0,o.lazy)(()=>Promise.resolve().then(()=>require(`./AdConfirmExitModal-CRCnzYQM.cjs`)));function x(e,t){return Math.floor(Math.random()*(t-e+1))+e}function S(e){let{previewMode:t,darkMode:n,user_ad_token:c,userDetails:u,userDetailsLoading:d,prepend:p,append:m}=e,h=[],[S,C]=(0,o.useState)(null),{data:w,isLoading:T,mutate:E}=g({loading:d,disabled:u?.articles_membership?.status==`Active`}),{data:D,isLoading:O}=f(S,c),k=e.previewData||{},[ee,te]=(0,o.useState)(null),[ne,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(null),[N,P]=(0,o.useState)(0),[F,I]=(0,o.useState)(!1),[L,R]=(0,o.useState)(!1),[z,B]=(0,o.useState)(!1),[V,H]=(0,o.useState)(new Date),[U,W]=(0,o.useState)([]);(0,o.useEffect)(()=>{w&&w?.length>0&&!S&&(console.log(`Ad Mounted or reduxAds changed`),C(e.ad_id||w[x(0,w?.length-1)]?._id))},[w]),(0,o.useEffect)(()=>{},[D]),(0,o.useEffect)(()=>{D?.populated_promos&&N>=0&&M(D?.populated_promos[N])},[N,D]);function G(){R(!L)}let{ref:K,inView:q,entry:re}=(0,s.useInView)({threshold:0,triggerOnce:!0});function J(e){if(t&&console.log(`Preventing this event from being logged as this ad is being shown in preview mode.`),U.find(t=>t==e)){console.log(`Already logged this event`);return}let n=new URLSearchParams({ad_id:D?._id,event:e}).toString();fetch(`/api/ads/event?${n}`).then(function(e){return e.json()}).then(function(t){W([...U,e]),console.log(t)}).catch(function(e){console.log(e)})}(0,o.useEffect)(()=>{if(!t&&(console.log(`inView`,q),q&&S)){let e=[{ad_id:S,date:new Date().toString()},...h.filter(e=>{if(console.log((0,l.differenceInMinutes)(new Date,new Date(e.date))),(0,l.differenceInMinutes)(new Date,new Date(e.date))>5){console.log(`adsViewed - Remove Old Ad View Object`);return}else return console.log(`adsViewed - Keep Ad View Object`),e})];console.log(`unexpiredRecentViews`,e)}},[q,S]);let[Y,X]=(0,o.useState)(null),[Z,Q]=(0,o.useState)(!1);function $(){Q(!0),console.log(`logAdAvoided called`,c);let e=process.env.NODE_ENV===`development`?`http://localhost:3001/api/user/advertising/avoided`:`https://articles.media/api/user/advertising/avoided`,t=new URLSearchParams({user_id:u?._id}).toString();fetch(`${e}?${t}`,{headers:{"x-articles-api-key":c}}).then(function(e){return e.json()}).then(function(e){Q(!1),X(e.avoided_count),console.log(e)}).catch(function(e){console.log(e),Q(!1)})}return(0,o.useEffect)(()=>{t||(console.log(`inView`,q),u?.articles_membership?.status==`Active`&&q&&$(`Ad Avoided`))},[q,u]),d?null:(0,_.jsxs)(`div`,{ref:K,className:(0,v.default)(`ad-wrap`,{"active-member":u?.articles_membership?.status==`Active`}),style:{"--articles-ad-background-color":k.background_color||D?.background_color,"--articles-ad-font-color":k.font_color||D?.font_color,"--articles-ad-border-color":k.border_color||D?.border_color},children:[L&&(0,_.jsx)(y,{setModalShow:R,ad:D,previewData:k}),z&&(0,_.jsx)(b,{setModalShow:B,ad:D,previewData:k}),p&&(0,_.jsx)(`div`,{className:`prepend-container`,children:p}),(0,_.jsxs)(`div`,{className:`ad`,children:[u?.articles_membership?.status!==`Active`&&(0,_.jsxs)(`div`,{className:`main-panel`,children:[(0,_.jsx)(`div`,{className:`ad-warning flex-header`,children:(0,_.jsxs)(`div`,{className:``,children:[D?.city&&`Local`,` Advertisement`]})}),(0,_.jsxs)(`div`,{className:`content-wrap`,children:[(0,_.jsxs)(`div`,{className:`photo-banner`,children:[(0,_.jsx)(`div`,{className:`logo`,children:(k.logo?.location||D?.logo?.location)&&(0,_.jsx)(`img`,{src:k?.logo?.key?`${process.env.NEXT_PUBLIC_CDN}${k?.logo?.key}`:`${process.env.NEXT_PUBLIC_CDN}${D?.logo?.key}`,alt:``})}),(0,_.jsx)(`div`,{className:`icon d-none`,children:(0,_.jsx)(`i`,{className:`fas fa-mug-hot`})}),(0,_.jsx)(`img`,{className:`photo`,src:k?.background?.key?`${process.env.NEXT_PUBLIC_CDN}${k.background?.key}`:`${process.env.NEXT_PUBLIC_CDN}${D?.background?.key}`,alt:``})]}),(0,_.jsxs)(`div`,{className:`details-wrap`,children:[(0,_.jsxs)(`div`,{className:`detail-title`,children:[(0,_.jsx)(`div`,{className:`detail`,children:(0,_.jsx)(`span`,{className:`h4`,children:k?.business||D?.business})}),(0,_.jsxs)(`div`,{className:`flex flex-column d-none`,children:[(0,_.jsxs)(`div`,{className:`detail`,children:[(0,_.jsx)(`span`,{className:`icon`,children:(0,_.jsx)(`i`,{className:`fas fa-search-location`})}),(0,_.jsxs)(`span`,{children:[D?.city,`, `,D?.state]})]}),(0,_.jsxs)(`div`,{className:`detail`,children:[(0,_.jsx)(`span`,{className:`icon`,children:(0,_.jsx)(`i`,{className:`fas fa-clock me-2`})}),(0,_.jsx)(`span`,{children:`6:30AM–8PM`})]})]})]}),D?.city&&(0,_.jsx)(`div`,{className:`details mb-3 d-none`}),(0,_.jsx)(`div`,{className:`short-description`,children:k?.description||D?.description})]})]}),(!1)?.roles?.isDev&&D?.populated_promos?.length>0&&(0,_.jsxs)(`div`,{children:[j&&(0,_.jsx)(`div`,{className:`promos-wrap`,children:j&&(0,_.jsxs)(`div`,{className:`promo-wrap d-flex justify-content-between align-items-center mx-2 p-1 px-2 border border-2 border-light mb-0`,children:[(0,_.jsxs)(`div`,{className:``,children:[(0,_.jsx)(`div`,{children:j.title}),(0,_.jsx)(`div`,{className:`small`,children:(0,_.jsx)(`div`,{className:`small`,children:j.details})})]}),(0,_.jsx)(r.t,{className:`px-3`,small:!0,onClick:()=>{console.log(`Load Save Modal`),I(!0)},children:`Save`})]},j._id)}),(0,_.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,_.jsxs)(`div`,{className:`px-2`,children:[D?.populated_promos?.length,` Promos Active`]}),(0,_.jsxs)(`div`,{className:`controls`,children:[(0,_.jsx)(`i`,{className:`fad fa-arrow-circle-left`,type:`button`,onClick:()=>{P(N==0?D?.populated_promos?.length-1:e=>e-1)}}),D?.populated_promos?.map((e,t)=>(0,_.jsx)(`i`,{className:`fa-square ${t==N?`fad`:`fas`}`},e._id)),(0,_.jsx)(`i`,{className:`fad fa-arrow-circle-right`,type:`button`,onClick:()=>{N==D?.populated_promos?.length-1?P(0):P(e=>e+1)}})]})]})]}),(0,_.jsx)(`hr`,{style:{borderColor:`white`},className:`mt-auto mb-0`}),(0,_.jsxs)(`div`,{className:`action-wrap d-flex justify-content-lg-between px-3 py-2`,children:[(0,_.jsx)(`div`,{onClick:()=>{G(),J(`Details`)},className:`action flex-grow-1 flex-shrink-0`,children:`Details`}),(0,_.jsx)(`span`,{className:`px-4`}),(0,_.jsx)(`a`,{className:`action flex-grow-1 flex-shrink-0`,href:D?.website,target:`_blank`,rel:`noreferrer`,onClick:e=>{e.preventDefault(),B(!0),J(`Confirm Exit Modal Opened`)},children:(0,_.jsx)(`div`,{children:`Website`})})]})]}),u?.articles_membership?.status==`Active`&&(0,_.jsx)(`div`,{className:`main-panel`,children:(0,_.jsxs)(`div`,{className:`content-wrap`,children:[(0,_.jsxs)(`div`,{className:`photo-banner`,children:[(0,_.jsx)(`div`,{className:`logo`}),(0,_.jsxs)(`div`,{className:`splash`,children:[(0,_.jsx)(`i`,{className:`fas fa-broadcast-tower`}),(0,_.jsxs)(`div`,{className:`text`,children:[(0,_.jsx)(`div`,{className:`count`,children:Z?(0,_.jsx)(`i`,{className:`fas fa-spinner fa-spin me-0`}):Y?a.t(Y):0}),(0,_.jsx)(`div`,{className:`label`,children:`ads avoided.`})]})]}),(0,_.jsxs)(`div`,{className:`member-since`,children:[`Member since: `,(0,_.jsx)(a.n,{format:`PP`,date:u?.articles_membership?.membership_started})]})]}),(0,_.jsxs)(`div`,{className:`details-wrap`,children:[(0,_.jsx)(`div`,{className:`detail-title`,children:(0,_.jsx)(`div`,{className:`detail`,children:(0,_.jsx)(`span`,{className:`h4`,children:`Thanks for the support!`})})}),(0,_.jsxs)(`div`,{className:`short-description`,children:[(0,_.jsx)(`div`,{className:`mb-2`,children:`Without support from users like you, we wouldn't be here.`}),(0,_.jsxs)(`div`,{className:`links-list`,children:[(0,_.jsxs)(i.t,{newPage:!0,className:`link-item`,href:`https://articles.media/messages`,children:[(0,_.jsx)(`i`,{className:`fas fa-comments-alt`}),`0 unread messages.`]}),(0,_.jsxs)(i.t,{newPage:!0,className:`link-item`,href:`https://articles.media/settings/notifications`,onClick:()=>{$()},children:[(0,_.jsx)(`i`,{className:`fas fa-bell`}),`0 notifications.`]}),(0,_.jsxs)(i.t,{newPage:!0,className:`link-item`,href:`https://articles.media/settings/account`,children:[(0,_.jsx)(`i`,{className:`fas fa-cog`}),`Manage account settings.`]})]})]})]})]})})]}),m&&(0,_.jsx)(`div`,{className:`append-container`,children:m}),!t&&(0,_.jsx)(`div`,{className:`advertise-with-us p-1`,style:{backgroundColor:k.background_color||D?.background_color,color:k.font_color||D?.font_color,borderColor:k.border_color||D?.border_color},children:(0,_.jsxs)(i.t,{className:`small d-block w-100 text-center`,href:`https://articles.media/advertising`,newPage:!0,children:[(0,_.jsx)(`i`,{className:`fas fa-share me-1`}),`Advertise with Articles Media!`]})})]})}var C=(0,o.memo)(S);Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return C}});
|
package/dist/Ad.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./jsx-runtime-nZSsnGb7.cjs"),c=require("react"),v=require("./numberWithCommas-CRgrb58X.cjs"),R=require("./index-Ddv_TnxK.cjs"),Z=require("./Button-0ZK0NKiK.cjs"),ee=require("./index-BlP2-uOi.cjs");function se(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const i in s)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:()=>s[i]})}}return t.default=s,Object.freeze(t)}const A=se(c);var C=new Map,M=new WeakMap,W=0,te;function ne(s){return s?(M.has(s)||(W+=1,M.set(s,W.toString())),M.get(s)):"0"}function re(s){return Object.keys(s).sort().filter(t=>s[t]!==void 0).map(t=>`${t}_${t==="root"?ne(s.root):s[t]}`).toString()}function ie(s){const t=re(s);let i=C.get(t);if(!i){const r=new Map;let l;const u=new IntersectionObserver(x=>{x.forEach(o=>{var p;const N=o.isIntersecting&&l.some(j=>o.intersectionRatio>=j);s.trackVisibility&&typeof o.isVisible>"u"&&(o.isVisible=N),(p=r.get(o.target))==null||p.forEach(j=>{j(N,o)})})},s);l=u.thresholds||(Array.isArray(s.threshold)?s.threshold:[s.threshold||0]),i={id:t,observer:u,elements:r},C.set(t,i)}return i}function oe(s,t,i={},r=te){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const p=s.getBoundingClientRect();return t(r,{isIntersecting:r,target:s,intersectionRatio:typeof i.threshold=="number"?i.threshold:0,time:0,boundingClientRect:p,intersectionRect:p,rootBounds:p}),()=>{}}const{id:l,observer:u,elements:x}=ie(i),o=x.get(s)||[];return x.has(s)||x.set(s,o),o.push(t),u.observe(s),function(){o.splice(o.indexOf(t),1),o.length===0&&(x.delete(s),u.unobserve(s)),x.size===0&&(u.disconnect(),C.delete(l))}}function ae({threshold:s,delay:t,trackVisibility:i,rootMargin:r,root:l,triggerOnce:u,skip:x,initialInView:o,fallbackInView:p,onChange:N}={}){var j;const[_,b]=A.useState(null),n=A.useRef(N),a=A.useRef(o),[k,D]=A.useState({inView:!!o,entry:void 0});n.current=N,A.useEffect(()=>{if(a.current===void 0&&(a.current=o),x||!_)return;let g;return g=oe(_,(f,E)=>{const P=a.current;a.current=f,!(P===void 0&&!f)&&(D({inView:f,entry:E}),n.current&&n.current(f,E),E.isIntersecting&&u&&g&&(g(),g=void 0))},{root:l,rootMargin:r,threshold:s,trackVisibility:i,delay:t},p),()=>{g&&g()}},[Array.isArray(s)?s.toString():s,_,l,r,u,x,i,p,t]);const y=(j=k.entry)==null?void 0:j.target,S=A.useRef(void 0);!_&&y&&!u&&!x&&S.current!==y&&(S.current=y,D({inView:!!o,entry:void 0}),a.current=o);const m=[b,k.inView,k.entry];return m.ref=m[0],m.inView=m[1],m.entry=m[2],m}const ce=async s=>{if(process.env.NODE_ENV==="development")try{return(await R.axios.get(`http://localhost:3001/api/ads/${s.ad_id}`,{params:{ad_id:s.ad_id,user_ad_token:s.user_ad_token}})).data.result}catch{}return R.axios.get(s.url,{params:{ad_id:s.ad_id}}).then(t=>t.data.result)},le=60,de={dedupingInterval:1e3*60*le},ue=(s,t)=>{const{data:i,error:r,isLoading:l,mutate:u}=R.useSWR(s?{url:`https://articles.media/api/ads/${s}`,ad_id:s,user_ad_token:t}:null,ce,de);return{data:i,error:r,isLoading:l,mutate:u}};function xe(s){return t=>{const r=(s?Math[s]:Math.trunc)(t);return r===0?0:r}}function me(s,t){return+v.toDate(s)-+v.toDate(t)}function z(s,t,i){const r=me(s,t)/v.millisecondsInMinute;return xe(i?.roundingMethod)(r)}function U(s){return Math.trunc(s*v.millisecondsInMinute)}const pe=async s=>{if(process.env.NODE_ENV==="development")try{return(await R.axios.get("http://localhost:3001/api/ads",{params:{}})).data}catch{}return R.axios.get(s.url,{params:{}}).then(t=>t.data)},X=60,je={dedupingInterval:U(X),focusThrottleInterval:U(X)},fe=s=>{const{data:t,error:i,isLoading:r,mutate:l}=R.useSWR(s?.loading||s?.disabled?null:{url:"https://articles.media/api/ads"},pe,je);return{data:t,error:i,isLoading:r,mutate:l}},he=c.lazy(()=>Promise.resolve().then(()=>require("./AdDetailsModal-k840vrS2.cjs"))),ve=c.lazy(()=>Promise.resolve().then(()=>require("./AdConfirmExitModal-CcSxmXKT.cjs")));function ge(s,t){return Math.floor(Math.random()*(t-s+1))+s}function Ee(s){let{previewMode:t,darkMode:i,user_ad_token:r,userDetails:l,userDetailsLoading:u,prepend:x,append:o}=s;const p=!1,N=[],[j,_]=c.useState(null),{data:b}=fe({loading:u,disabled:l?.articles_membership?.status=="Active"}),{data:n}=ue(j,r);let a=s.previewData||{};const[k,D]=c.useState(null),[y,S]=c.useState(null),[m,g]=c.useState(null),[f,E]=c.useState(0),[P,K]=c.useState(!1),[$,L]=c.useState(!1),[F,O]=c.useState(!1),[Ne,be]=c.useState(new Date),[V,G]=c.useState([]);c.useEffect(()=>{b&&b?.length>0&&!j&&(console.log("Ad Mounted or reduxAds changed"),_(s.ad_id||b[ge(0,b?.length-1)]?._id))},[b]),c.useEffect(()=>{},[n]),c.useEffect(()=>{n?.populated_promos&&f>=0&&g(n?.populated_promos[f])},[f,n]);function H(){L(!$)}const{ref:J,inView:w}=ae({threshold:0,triggerOnce:!0});function T(d){if(t&&console.log("Preventing this event from being logged as this ad is being shown in preview mode."),V.find(h=>h==d)){console.log("Already logged this event");return}R.axios.get("/api/ads/event",{params:{ad_id:n?._id,event:d}}).then(function(h){G([...V,d]),console.log(h.data)}).catch(function(h){console.log(h)})}c.useEffect(()=>{if(!t&&(console.log("inView",w),w&&j)){let d=[{ad_id:j,date:new Date().toString()},...N.filter(h=>{if(console.log(z(new Date,new Date(h.date))),z(new Date,new Date(h.date))>5){console.log("adsViewed - Remove Old Ad View Object");return}else return console.log("adsViewed - Keep Ad View Object"),h})];console.log("unexpiredRecentViews",d)}},[w,j]);const[q,Q]=c.useState(null),[Y,I]=c.useState(!1);function B(){I(!0),console.log("logAdAvoided called",r),R.axios.get(process.env.NODE_ENV==="development"?"http://localhost:3001/api/user/advertising/avoided":"https://articles.media/api/user/advertising/avoided",{params:{user_id:l?._id},headers:{"x-articles-api-key":r}}).then(function(d){I(!1),Q(d.data.avoided_count),console.log(d.data)}).catch(function(d){console.log(d),I(!1)})}return c.useEffect(()=>{t||(console.log("inView",w),l?.articles_membership?.status=="Active"&&w&&B())},[w,l]),u?null:e.jsxRuntimeExports.jsxs("div",{ref:J,className:ee.classNames("ad-wrap",{"active-member":l?.articles_membership?.status=="Active"}),style:{"--articles-ad-background-color":a.background_color||n?.background_color,"--articles-ad-font-color":a.font_color||n?.font_color,"--articles-ad-border-color":a.border_color||n?.border_color},children:[$&&e.jsxRuntimeExports.jsx(he,{setModalShow:L,ad:n,previewData:a}),F&&e.jsxRuntimeExports.jsx(ve,{setModalShow:O,ad:n,previewData:a}),x&&e.jsxRuntimeExports.jsx("div",{className:"prepend-container",children:x}),e.jsxRuntimeExports.jsxs("div",{className:"ad",children:[l?.articles_membership?.status!=="Active"&&e.jsxRuntimeExports.jsxs("div",{className:"main-panel",children:[e.jsxRuntimeExports.jsx("div",{className:"ad-warning flex-header",children:e.jsxRuntimeExports.jsxs("div",{className:"",children:[n?.city&&"Local"," Advertisement"]})}),e.jsxRuntimeExports.jsxs("div",{className:"content-wrap",children:[e.jsxRuntimeExports.jsxs("div",{className:"photo-banner",children:[e.jsxRuntimeExports.jsx("div",{className:"logo",children:(a.logo?.location||n?.logo?.location)&&e.jsxRuntimeExports.jsx("img",{src:a?.logo?.key?`${process.env.NEXT_PUBLIC_CDN}${a?.logo?.key}`:`${process.env.NEXT_PUBLIC_CDN}${n?.logo?.key}`,alt:""})}),e.jsxRuntimeExports.jsx("div",{className:"icon d-none",children:e.jsxRuntimeExports.jsx("i",{className:"fas fa-mug-hot"})}),e.jsxRuntimeExports.jsx("img",{className:"photo",src:a?.background?.key?`${process.env.NEXT_PUBLIC_CDN}${a.background?.key}`:`${process.env.NEXT_PUBLIC_CDN}${n?.background?.key}`,alt:""})]}),e.jsxRuntimeExports.jsxs("div",{className:"details-wrap",children:[e.jsxRuntimeExports.jsxs("div",{className:"detail-title",children:[e.jsxRuntimeExports.jsx("div",{className:"detail",children:e.jsxRuntimeExports.jsx("span",{className:"h4",children:a?.business||n?.business})}),e.jsxRuntimeExports.jsxs("div",{className:"flex flex-column d-none",children:[e.jsxRuntimeExports.jsxs("div",{className:"detail",children:[e.jsxRuntimeExports.jsx("span",{className:"icon",children:e.jsxRuntimeExports.jsx("i",{className:"fas fa-search-location"})}),e.jsxRuntimeExports.jsxs("span",{children:[n?.city,", ",n?.state]})]}),e.jsxRuntimeExports.jsxs("div",{className:"detail",children:[e.jsxRuntimeExports.jsx("span",{className:"icon",children:e.jsxRuntimeExports.jsx("i",{className:"fas fa-clock me-2"})}),e.jsxRuntimeExports.jsx("span",{children:"6:30AM–8PM"})]})]})]}),n?.city&&e.jsxRuntimeExports.jsx("div",{className:"details mb-3 d-none"}),e.jsxRuntimeExports.jsx("div",{className:"short-description",children:a?.description||n?.description})]})]}),p?.roles?.isDev&&n?.populated_promos?.length>0&&e.jsxRuntimeExports.jsxs("div",{children:[m&&e.jsxRuntimeExports.jsx("div",{className:"promos-wrap",children:m&&e.jsxRuntimeExports.jsxs("div",{className:"promo-wrap d-flex justify-content-between align-items-center mx-2 p-1 px-2 border border-2 border-light mb-0",children:[e.jsxRuntimeExports.jsxs("div",{className:"",children:[e.jsxRuntimeExports.jsx("div",{children:m.title}),e.jsxRuntimeExports.jsx("div",{className:"small",children:e.jsxRuntimeExports.jsx("div",{className:"small",children:m.details})})]}),e.jsxRuntimeExports.jsx(Z.ArticlesButton,{className:"px-3",small:!0,onClick:()=>{console.log("Load Save Modal"),K(!0)},children:"Save"})]},m._id)}),e.jsxRuntimeExports.jsxs("div",{className:"d-flex justify-content-between",children:[e.jsxRuntimeExports.jsxs("div",{className:"px-2",children:[n?.populated_promos?.length," Promos Active"]}),e.jsxRuntimeExports.jsxs("div",{className:"controls",children:[e.jsxRuntimeExports.jsx("i",{className:"fad fa-arrow-circle-left",type:"button",onClick:()=>{f==0?E(n?.populated_promos?.length-1):E(d=>d-1)}}),n?.populated_promos?.map((d,h)=>e.jsxRuntimeExports.jsx("i",{className:`fa-square ${h==f?"fad":"fas"}`},d._id)),e.jsxRuntimeExports.jsx("i",{className:"fad fa-arrow-circle-right",type:"button",onClick:()=>{f==n?.populated_promos?.length-1?E(0):E(d=>d+1)}})]})]})]}),e.jsxRuntimeExports.jsx("hr",{style:{borderColor:"white"},className:"mt-auto mb-0"}),e.jsxRuntimeExports.jsxs("div",{className:"action-wrap d-flex justify-content-lg-between px-3 py-2",children:[e.jsxRuntimeExports.jsx("div",{onClick:()=>{H(),T("Details")},className:"action flex-grow-1 flex-shrink-0",children:"Details"}),e.jsxRuntimeExports.jsx("span",{className:"px-4"}),e.jsxRuntimeExports.jsx("a",{className:"action flex-grow-1 flex-shrink-0",href:n?.website,target:"_blank",rel:"noreferrer",onClick:d=>{d.preventDefault(),O(!0),T("Confirm Exit Modal Opened")},children:e.jsxRuntimeExports.jsx("div",{children:"Website"})})]})]}),l?.articles_membership?.status=="Active"&&e.jsxRuntimeExports.jsx("div",{className:"main-panel",children:e.jsxRuntimeExports.jsxs("div",{className:"content-wrap",children:[e.jsxRuntimeExports.jsxs("div",{className:"photo-banner",children:[e.jsxRuntimeExports.jsx("div",{className:"logo"}),e.jsxRuntimeExports.jsxs("div",{className:"splash",children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-broadcast-tower"}),e.jsxRuntimeExports.jsxs("div",{className:"text",children:[e.jsxRuntimeExports.jsx("div",{className:"count",children:Y?e.jsxRuntimeExports.jsx("i",{className:"fas fa-spinner fa-spin me-0"}):q?v.numberWithCommas(q):0}),e.jsxRuntimeExports.jsx("div",{className:"label",children:"ads avoided."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"member-since",children:["Member since: ",e.jsxRuntimeExports.jsx(v.ArticlesDate,{format:"PP",date:l?.articles_membership?.membership_started})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"details-wrap",children:[e.jsxRuntimeExports.jsx("div",{className:"detail-title",children:e.jsxRuntimeExports.jsx("div",{className:"detail",children:e.jsxRuntimeExports.jsx("span",{className:"h4",children:"Thanks for the support!"})})}),e.jsxRuntimeExports.jsxs("div",{className:"short-description",children:[e.jsxRuntimeExports.jsx("div",{className:"mb-2",children:"Without support from users like you, we wouldn't be here."}),e.jsxRuntimeExports.jsxs("div",{className:"links-list",children:[e.jsxRuntimeExports.jsxs(v.Link,{newPage:!0,className:"link-item",href:"https://articles.media/messages",children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-comments-alt"}),"0 unread messages."]}),e.jsxRuntimeExports.jsxs(v.Link,{newPage:!0,className:"link-item",href:"https://articles.media/settings/notifications",onClick:()=>{B()},children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-bell"}),"0 notifications."]}),e.jsxRuntimeExports.jsxs(v.Link,{newPage:!0,className:"link-item",href:"https://articles.media/settings/account",children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-cog"}),"Manage account settings."]})]})]})]})]})})]}),o&&e.jsxRuntimeExports.jsx("div",{className:"append-container",children:o}),!t&&e.jsxRuntimeExports.jsx("div",{className:"advertise-with-us p-1",style:{backgroundColor:a.background_color||n?.background_color,color:a.font_color||n?.font_color,borderColor:a.border_color||n?.border_color},children:e.jsxRuntimeExports.jsxs(v.Link,{className:"small d-block w-100 text-center",href:"https://articles.media/advertising",newPage:!0,children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-share me-1"}),"Advertise with Articles Media!"]})})]})}const Re=c.memo(Ee);module.exports=Re;
|
|
1
|
+
const e=require(`./Ad-DYtftKNV.cjs`);module.exports=e.t;
|