@articles-media/articles-dev-box 1.0.12 → 1.0.13

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.
Files changed (42) hide show
  1. package/package.json +5 -1
  2. package/dist/Ad.cjs +0 -1
  3. package/dist/Ad.js +0 -600
  4. package/dist/AdConfirmExitModal-CKkMAvBK.js +0 -72
  5. package/dist/AdConfirmExitModal-CcSxmXKT.cjs +0 -1
  6. package/dist/AdDetailsModal-Bp5hZm9N.js +0 -83
  7. package/dist/AdDetailsModal-k840vrS2.cjs +0 -1
  8. package/dist/ArticlesAd.cjs +0 -1
  9. package/dist/ArticlesAd.js +0 -16
  10. package/dist/Button-0ZK0NKiK.cjs +0 -1
  11. package/dist/Button-_Quon8UV.js +0 -54
  12. package/dist/GameScoreboard.cjs +0 -1
  13. package/dist/GameScoreboard.js +0 -182
  14. package/dist/GlobalBody-BQ2qC81K.cjs +0 -33
  15. package/dist/GlobalBody-tmIC_GWn.js +0 -123
  16. package/dist/GlobalBody.cjs +0 -1
  17. package/dist/GlobalBody.js +0 -7
  18. package/dist/GlobalHead.cjs +0 -1
  19. package/dist/GlobalHead.js +0 -13
  20. package/dist/Modal-C9oYRgI1.js +0 -2073
  21. package/dist/Modal-Wmqy9fOm.cjs +0 -2
  22. package/dist/ReturnToLauncherButton.cjs +0 -1
  23. package/dist/ReturnToLauncherButton.js +0 -50
  24. package/dist/StatusModal-BlwaI-2B.cjs +0 -1
  25. package/dist/StatusModal-CAVxWCUq.js +0 -71
  26. package/dist/ViewUserModal.cjs +0 -1
  27. package/dist/ViewUserModal.js +0 -3189
  28. package/dist/articles-dev-box.css +0 -1
  29. package/dist/index-BlP2-uOi.cjs +0 -1
  30. package/dist/index-DLYx67wi.js +0 -2394
  31. package/dist/index-Ddv_TnxK.cjs +0 -6
  32. package/dist/index-YnD2EP-S.js +0 -43
  33. package/dist/index.cjs +0 -1
  34. package/dist/index.js +0 -20
  35. package/dist/jsx-runtime-nZSsnGb7.cjs +0 -6
  36. package/dist/jsx-runtime-tc70JA_2.js +0 -264
  37. package/dist/numberWithCommas-CRgrb58X.cjs +0 -1
  38. package/dist/numberWithCommas-DnAkiOFL.js +0 -1256
  39. package/dist/useUserDetails.cjs +0 -1
  40. package/dist/useUserDetails.js +0 -33
  41. package/dist/useUserToken.cjs +0 -1
  42. package/dist/useUserToken.js +0 -22
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@articles-media/articles-dev-box",
3
3
  "description": "Shared code, functions, and components for different Articles Media projects.",
4
- "version": "1.0.12",
4
+ "version": "1.0.13",
5
5
  "type": "module",
6
6
  "imports": {
7
7
  "#root/src/*": "./src/*"
@@ -48,6 +48,10 @@
48
48
  "import": "./dist/ViewUserModal.js",
49
49
  "require": "./dist/ViewUserModal.cjs"
50
50
  },
51
+ "./FriendsList": {
52
+ "import": "./dist/FriendsList.js",
53
+ "require": "./dist/FriendsList.cjs"
54
+ },
51
55
  "./useUserDetails": {
52
56
  "import": "./dist/useUserDetails.js",
53
57
  "require": "./dist/useUserDetails.cjs"
package/dist/Ad.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";const e=require("./jsx-runtime-nZSsnGb7.cjs"),o=require("react"),v=require("./numberWithCommas-CRgrb58X.cjs"),E=require("./index-Ddv_TnxK.cjs"),Q=require("./Button-0ZK0NKiK.cjs"),Y=require("./index-BlP2-uOi.cjs");function Z(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 _=Z(o);var P=new Map,S=new WeakMap,B=0,ee;function se(s){return s?(S.has(s)||(B+=1,S.set(s,B.toString())),S.get(s)):"0"}function te(s){return Object.keys(s).sort().filter(t=>s[t]!==void 0).map(t=>`${t}_${t==="root"?se(s.root):s[t]}`).toString()}function ne(s){const t=te(s);let i=P.get(t);if(!i){const r=new Map;let a;const x=new IntersectionObserver(p=>{p.forEach(c=>{var u;const R=c.isIntersecting&&a.some(f=>c.intersectionRatio>=f);s.trackVisibility&&typeof c.isVisible>"u"&&(c.isVisible=R),(u=r.get(c.target))==null||u.forEach(f=>{f(R,c)})})},s);a=x.thresholds||(Array.isArray(s.threshold)?s.threshold:[s.threshold||0]),i={id:t,observer:x,elements:r},P.set(t,i)}return i}function re(s,t,i={},r=ee){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const u=s.getBoundingClientRect();return t(r,{isIntersecting:r,target:s,intersectionRatio:typeof i.threshold=="number"?i.threshold:0,time:0,boundingClientRect:u,intersectionRect:u,rootBounds:u}),()=>{}}const{id:a,observer:x,elements:p}=ne(i),c=p.get(s)||[];return p.has(s)||p.set(s,c),c.push(t),x.observe(s),function(){c.splice(c.indexOf(t),1),c.length===0&&(p.delete(s),x.unobserve(s)),p.size===0&&(x.disconnect(),P.delete(a))}}function ie({threshold:s,delay:t,trackVisibility:i,rootMargin:r,root:a,triggerOnce:x,skip:p,initialInView:c,fallbackInView:u,onChange:R}={}){var f;const[n,d]=_.useState(null),k=_.useRef(R),N=_.useRef(c),[y,I]=_.useState({inView:!!c,entry:void 0});k.current=R,_.useEffect(()=>{if(N.current===void 0&&(N.current=c),p||!n)return;let j;return j=re(n,(w,A)=>{const D=N.current;N.current=w,!(D===void 0&&!w)&&(I({inView:w,entry:A}),k.current&&k.current(w,A),A.isIntersecting&&x&&j&&(j(),j=void 0))},{root:a,rootMargin:r,threshold:s,trackVisibility:i,delay:t},u),()=>{j&&j()}},[Array.isArray(s)?s.toString():s,n,a,r,x,p,i,u,t]);const g=(f=y.entry)==null?void 0:f.target,M=_.useRef(void 0);!n&&g&&!x&&!p&&M.current!==g&&(M.current=g,I({inView:!!c,entry:void 0}),N.current=c);const m=[d,y.inView,y.entry];return m.ref=m[0],m.inView=m[1],m.entry=m[2],m}const oe=async s=>{if(process.env.NODE_ENV==="development")try{return(await E.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 E.axios.get(s.url,{params:{ad_id:s.ad_id}}).then(t=>t.data.result)},ae=60,ce={dedupingInterval:1e3*60*ae},le=(s,t)=>{const{data:i,error:r,isLoading:a,mutate:x}=E.useSWR(s?{url:`https://articles.media/api/ads/${s}`,ad_id:s,user_ad_token:t}:null,oe,ce);return{data:i,error:r,isLoading:a,mutate:x}};function de(s){return t=>{const r=(s?Math[s]:Math.trunc)(t);return r===0?0:r}}function ue(s,t){return+v.toDate(s)-+v.toDate(t)}function W(s,t,i){const r=ue(s,t)/v.millisecondsInMinute;return de(i?.roundingMethod)(r)}function z(s){return Math.trunc(s*v.millisecondsInMinute)}const xe=async s=>{if(process.env.NODE_ENV==="development")try{return(await E.axios.get("http://localhost:3001/api/ads",{params:{}})).data}catch{}return E.axios.get(s.url,{params:{}}).then(t=>t.data)},U=60,me={dedupingInterval:z(U),focusThrottleInterval:z(U)},pe=s=>{const{data:t,error:i,isLoading:r,mutate:a}=E.useSWR(s?.loading||s?.disabled?null:{url:"https://articles.media/api/ads"},xe,me);return{data:t,error:i,isLoading:r,mutate:a}},fe=o.lazy(()=>Promise.resolve().then(()=>require("./AdDetailsModal-k840vrS2.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./AdConfirmExitModal-CcSxmXKT.cjs")));function he(s,t){return Math.floor(Math.random()*(t-s+1))+s}function ve(s){let{previewMode:t,darkMode:i,user_ad_token:r,userDetails:a,userDetailsLoading:x}=s;const p=!1,c=[],[u,R]=o.useState(null),{data:f}=pe({loading:x,disabled:a?.articles_membership?.status=="Active"}),{data:n}=le(u,r);let d=s.previewData||{};const[k,N]=o.useState(null),[y,I]=o.useState(null),[g,M]=o.useState(null),[m,j]=o.useState(0),[w,A]=o.useState(!1),[D,$]=o.useState(!1),[X,L]=o.useState(!1),[Ee,Re]=o.useState(new Date),[O,K]=o.useState([]);o.useEffect(()=>{f&&f?.length>0&&!u&&(console.log("Ad Mounted or reduxAds changed"),R(s.ad_id||f[he(0,f?.length-1)]?._id))},[f]),o.useEffect(()=>{},[n]),o.useEffect(()=>{n?.populated_promos&&m>=0&&M(n?.populated_promos[m])},[m,n]);function F(){$(!D)}const{ref:G,inView:b}=ie({threshold:0,triggerOnce:!0});function V(l){if(t&&console.log("Preventing this event from being logged as this ad is being shown in preview mode."),O.find(h=>h==l)){console.log("Already logged this event");return}E.axios.get("/api/ads/event",{params:{ad_id:n?._id,event:l}}).then(function(h){K([...O,l]),console.log(h.data)}).catch(function(h){console.log(h)})}o.useEffect(()=>{if(!t&&(console.log("inView",b),b&&u)){let l=[{ad_id:u,date:new Date().toString()},...c.filter(h=>{if(console.log(W(new Date,new Date(h.date))),W(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",l)}},[b,u]);const[T,H]=o.useState(null),[J,C]=o.useState(!1);function q(){C(!0),console.log("logAdAvoided called",r),E.axios.get(process.env.NODE_ENV==="development"?"http://localhost:3001/api/user/advertising/avoided":"https://articles.media/api/user/advertising/avoided",{params:{user_id:a?._id},headers:{"x-articles-api-key":r}}).then(function(l){C(!1),H(l.data.avoided_count),console.log(l.data)}).catch(function(l){console.log(l),C(!1)})}return o.useEffect(()=>{t||(console.log("inView",b),a?.articles_membership?.status=="Active"&&b&&q())},[b,a]),x?null:e.jsxRuntimeExports.jsxs("div",{ref:G,className:Y.classNames("ad-wrap",{"active-member":a?.articles_membership?.status=="Active"}),style:{"--articles-ad-background-color":d.background_color||n?.background_color,"--articles-ad-font-color":d.font_color||n?.font_color,"--articles-ad-border-color":d.border_color||n?.border_color},children:[D&&e.jsxRuntimeExports.jsx(fe,{setModalShow:$,ad:n,previewData:d}),X&&e.jsxRuntimeExports.jsx(je,{setModalShow:L,ad:n,previewData:d}),e.jsxRuntimeExports.jsxs("div",{className:"ad",children:[a?.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:(d.logo?.location||n?.logo?.location)&&e.jsxRuntimeExports.jsx("img",{src:d?.logo?.key?`${process.env.NEXT_PUBLIC_CDN}${d?.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:d?.background?.key?`${process.env.NEXT_PUBLIC_CDN}${d.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:d?.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:d?.description||n?.description})]})]}),p?.roles?.isDev&&n?.populated_promos?.length>0&&e.jsxRuntimeExports.jsxs("div",{children:[g&&e.jsxRuntimeExports.jsx("div",{className:"promos-wrap",children:g&&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:g.title}),e.jsxRuntimeExports.jsx("div",{className:"small",children:e.jsxRuntimeExports.jsx("div",{className:"small",children:g.details})})]}),e.jsxRuntimeExports.jsx(Q.ArticlesButton,{className:"px-3",small:!0,onClick:()=>{console.log("Load Save Modal"),A(!0)},children:"Save"})]},g._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:()=>{m==0?j(n?.populated_promos?.length-1):j(l=>l-1)}}),n?.populated_promos?.map((l,h)=>e.jsxRuntimeExports.jsx("i",{className:`fa-square ${h==m?"fad":"fas"}`},l._id)),e.jsxRuntimeExports.jsx("i",{className:"fad fa-arrow-circle-right",type:"button",onClick:()=>{m==n?.populated_promos?.length-1?j(0):j(l=>l+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:()=>{F(),V("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:l=>{l.preventDefault(),L(!0),V("Confirm Exit Modal Opened")},children:e.jsxRuntimeExports.jsx("div",{children:"Website"})})]})]}),a?.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:J?e.jsxRuntimeExports.jsx("i",{className:"fas fa-spinner fa-spin me-0"}):T?v.numberWithCommas(T):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:a?.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:()=>{q()},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."]})]})]})]})]})})]}),!t&&e.jsxRuntimeExports.jsx("div",{className:"advertise-with-us p-1",style:{backgroundColor:d.background_color||n?.background_color,color:d.font_color||n?.font_color,borderColor:d.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 ge=o.memo(ve);module.exports=ge;
package/dist/Ad.js DELETED
@@ -1,600 +0,0 @@
1
- import { j as e } from "./jsx-runtime-tc70JA_2.js";
2
- import * as _ from "react";
3
- import { lazy as F, memo as te, useState as p, useEffect as y } from "react";
4
- import { t as U, m as G, n as ae, A as re, L as C } from "./numberWithCommas-DnAkiOFL.js";
5
- import { u as H, a as w } from "./index-DLYx67wi.js";
6
- import { A as ne } from "./Button-_Quon8UV.js";
7
- import { c as ie } from "./index-YnD2EP-S.js";
8
- var $ = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new WeakMap(), X = 0, oe;
9
- function le(s) {
10
- return s ? (R.has(s) || (X += 1, R.set(s, X.toString())), R.get(s)) : "0";
11
- }
12
- function de(s) {
13
- return Object.keys(s).sort().filter(
14
- (t) => s[t] !== void 0
15
- ).map((t) => `${t}_${t === "root" ? le(s.root) : s[t]}`).toString();
16
- }
17
- function ce(s) {
18
- const t = de(s);
19
- let o = $.get(t);
20
- if (!o) {
21
- const r = /* @__PURE__ */ new Map();
22
- let n;
23
- const u = new IntersectionObserver((f) => {
24
- f.forEach((i) => {
25
- var c;
26
- const j = i.isIntersecting && n.some((h) => i.intersectionRatio >= h);
27
- s.trackVisibility && typeof i.isVisible > "u" && (i.isVisible = j), (c = r.get(i.target)) == null || c.forEach((h) => {
28
- h(j, i);
29
- });
30
- });
31
- }, s);
32
- n = u.thresholds || (Array.isArray(s.threshold) ? s.threshold : [s.threshold || 0]), o = {
33
- id: t,
34
- observer: u,
35
- elements: r
36
- }, $.set(t, o);
37
- }
38
- return o;
39
- }
40
- function ue(s, t, o = {}, r = oe) {
41
- if (typeof window.IntersectionObserver > "u" && r !== void 0) {
42
- const c = s.getBoundingClientRect();
43
- return t(r, {
44
- isIntersecting: r,
45
- target: s,
46
- intersectionRatio: typeof o.threshold == "number" ? o.threshold : 0,
47
- time: 0,
48
- boundingClientRect: c,
49
- intersectionRect: c,
50
- rootBounds: c
51
- }), () => {
52
- };
53
- }
54
- const { id: n, observer: u, elements: f } = ce(o), i = f.get(s) || [];
55
- return f.has(s) || f.set(s, i), i.push(t), u.observe(s), function() {
56
- i.splice(i.indexOf(t), 1), i.length === 0 && (f.delete(s), u.unobserve(s)), f.size === 0 && (u.disconnect(), $.delete(n));
57
- };
58
- }
59
- function me({
60
- threshold: s,
61
- delay: t,
62
- trackVisibility: o,
63
- rootMargin: r,
64
- root: n,
65
- triggerOnce: u,
66
- skip: f,
67
- initialInView: i,
68
- fallbackInView: c,
69
- onChange: j
70
- } = {}) {
71
- var h;
72
- const [a, d] = _.useState(null), M = _.useRef(j), N = _.useRef(i), [D, P] = _.useState({
73
- inView: !!i,
74
- entry: void 0
75
- });
76
- M.current = j, _.useEffect(
77
- () => {
78
- if (N.current === void 0 && (N.current = i), f || !a) return;
79
- let v;
80
- return v = ue(
81
- a,
82
- (A, k) => {
83
- const I = N.current;
84
- N.current = A, !(I === void 0 && !A) && (P({
85
- inView: A,
86
- entry: k
87
- }), M.current && M.current(A, k), k.isIntersecting && u && v && (v(), v = void 0));
88
- },
89
- {
90
- root: n,
91
- rootMargin: r,
92
- threshold: s,
93
- // @ts-expect-error
94
- trackVisibility: o,
95
- delay: t
96
- },
97
- c
98
- ), () => {
99
- v && v();
100
- };
101
- },
102
- // We break the rule here, because we aren't including the actual `threshold` variable
103
- // eslint-disable-next-line react-hooks/exhaustive-deps
104
- [
105
- // If the threshold is an array, convert it to a string, so it won't change between renders.
106
- Array.isArray(s) ? s.toString() : s,
107
- a,
108
- n,
109
- r,
110
- u,
111
- f,
112
- o,
113
- c,
114
- t
115
- ]
116
- );
117
- const x = (h = D.entry) == null ? void 0 : h.target, E = _.useRef(void 0);
118
- !a && x && !u && !f && E.current !== x && (E.current = x, P({
119
- inView: !!i,
120
- entry: void 0
121
- }), N.current = i);
122
- const m = [d, D.inView, D.entry];
123
- return m.ref = m[0], m.inView = m[1], m.entry = m[2], m;
124
- }
125
- const fe = async (s) => {
126
- if (process.env.NODE_ENV === "development")
127
- try {
128
- return (await w.get(`http://localhost:3001/api/ads/${s.ad_id}`, {
129
- params: {
130
- ad_id: s.ad_id,
131
- user_ad_token: s.user_ad_token
132
- }
133
- })).data.result;
134
- } catch {
135
- }
136
- return w.get(s.url, {
137
- params: {
138
- ad_id: s.ad_id
139
- }
140
- }).then((t) => t.data.result);
141
- }, he = 60, pe = {
142
- dedupingInterval: 1e3 * 60 * he
143
- // keepPreviousData: true,
144
- // fallbackData: []
145
- }, ve = (s, t) => {
146
- const { data: o, error: r, isLoading: n, mutate: u } = H(
147
- s ? {
148
- url: `https://articles.media/api/ads/${s}`,
149
- ad_id: s,
150
- user_ad_token: t
151
- } : null,
152
- fe,
153
- pe
154
- );
155
- return {
156
- data: o,
157
- error: r,
158
- isLoading: n,
159
- mutate: u
160
- };
161
- };
162
- function ge(s) {
163
- return (t) => {
164
- const r = (s ? Math[s] : Math.trunc)(t);
165
- return r === 0 ? 0 : r;
166
- };
167
- }
168
- function xe(s, t) {
169
- return +U(s) - +U(t);
170
- }
171
- function z(s, t, o) {
172
- const r = xe(s, t) / G;
173
- return ge(o?.roundingMethod)(r);
174
- }
175
- function q(s) {
176
- return Math.trunc(s * G);
177
- }
178
- const je = async (s) => {
179
- if (process.env.NODE_ENV === "development")
180
- try {
181
- return (await w.get("http://localhost:3001/api/ads", {
182
- params: {
183
- // ad_id: data.ad_id
184
- }
185
- })).data;
186
- } catch {
187
- }
188
- return w.get(s.url, {
189
- params: {
190
- // ad_id: data.ad_id
191
- }
192
- }).then((t) => t.data);
193
- }, K = 60, Ne = {
194
- dedupingInterval: q(K),
195
- focusThrottleInterval: q(K)
196
- // keepPreviousData: true,
197
- // fallbackData: []
198
- }, be = (s) => {
199
- const { data: t, error: o, isLoading: r, mutate: n } = H(
200
- s?.loading || s?.disabled ? null : {
201
- url: "https://articles.media/api/ads"
202
- // ad_id
203
- },
204
- je,
205
- Ne
206
- );
207
- return {
208
- data: t,
209
- error: o,
210
- isLoading: r,
211
- mutate: n
212
- };
213
- }, _e = F(() => import("./AdDetailsModal-Bp5hZm9N.js")), we = F(() => import("./AdConfirmExitModal-CKkMAvBK.js"));
214
- function Ae(s, t) {
215
- return Math.floor(Math.random() * (t - s + 1)) + s;
216
- }
217
- function ke(s) {
218
- let {
219
- previewMode: t,
220
- darkMode: o,
221
- user_ad_token: r,
222
- userDetails: n,
223
- userDetailsLoading: u
224
- } = s;
225
- const f = !1, i = [], [c, j] = p(null), {
226
- data: h
227
- } = be(
228
- {
229
- loading: u,
230
- disabled: n?.articles_membership?.status == "Active"
231
- }
232
- ), { data: a } = ve(c, r);
233
- let d = s.previewData || {};
234
- const [M, N] = p(null), [D, P] = p(null), [x, E] = p(null), [m, v] = p(0), [A, k] = p(!1), [I, L] = p(!1), [J, V] = p(!1), [ye, Me] = p(/* @__PURE__ */ new Date()), [O, Q] = p([]);
235
- y(() => {
236
- h && h?.length > 0 && !c && (console.log("Ad Mounted or reduxAds changed"), j(s.ad_id || h[Ae(0, h?.length - 1)]?._id));
237
- }, [h]), y(() => {
238
- }, [a]), y(() => {
239
- a?.populated_promos && m >= 0 && E(a?.populated_promos[m]);
240
- }, [m, a]);
241
- function Y() {
242
- L(!I);
243
- }
244
- const { ref: Z, inView: b } = me({
245
- /* Optional options */
246
- threshold: 0,
247
- triggerOnce: !0
248
- });
249
- function T(l) {
250
- if (t && console.log("Preventing this event from being logged as this ad is being shown in preview mode."), O.find((g) => g == l)) {
251
- console.log("Already logged this event");
252
- return;
253
- }
254
- w.get("/api/ads/event", {
255
- params: {
256
- ad_id: a?._id,
257
- event: l
258
- }
259
- }).then(function(g) {
260
- Q([...O, l]), console.log(g.data);
261
- }).catch(function(g) {
262
- console.log(g);
263
- });
264
- }
265
- y(() => {
266
- if (!t && (console.log("inView", b), b && c)) {
267
- let l = [
268
- {
269
- ad_id: c,
270
- date: (/* @__PURE__ */ new Date()).toString()
271
- },
272
- ...i.filter((g) => {
273
- if (console.log(
274
- z(/* @__PURE__ */ new Date(), new Date(g.date))
275
- ), z(/* @__PURE__ */ new Date(), new Date(g.date)) > 5) {
276
- console.log("adsViewed - Remove Old Ad View Object");
277
- return;
278
- } else
279
- return console.log("adsViewed - Keep Ad View Object"), g;
280
- })
281
- ];
282
- console.log("unexpiredRecentViews", l);
283
- }
284
- }, [b, c]);
285
- const [B, ee] = p(null), [se, S] = p(!1);
286
- function W() {
287
- S(!0), console.log("logAdAvoided called", r), w.get(
288
- process.env.NODE_ENV === "development" ? "http://localhost:3001/api/user/advertising/avoided" : "https://articles.media/api/user/advertising/avoided",
289
- {
290
- params: {
291
- user_id: n?._id
292
- },
293
- headers: {
294
- "x-articles-api-key": r
295
- }
296
- }
297
- ).then(function(l) {
298
- S(!1), ee(l.data.avoided_count), console.log(l.data);
299
- }).catch(function(l) {
300
- console.log(l), S(!1);
301
- });
302
- }
303
- return y(() => {
304
- t || (console.log("inView", b), n?.articles_membership?.status == "Active" && b && W());
305
- }, [b, n]), u ? null : /* @__PURE__ */ e.jsxs(
306
- "div",
307
- {
308
- ref: Z,
309
- className: ie(
310
- "ad-wrap",
311
- {
312
- "active-member": n?.articles_membership?.status == "Active"
313
- }
314
- ),
315
- style: {
316
- "--articles-ad-background-color": d.background_color || a?.background_color,
317
- "--articles-ad-font-color": d.font_color || a?.font_color,
318
- "--articles-ad-border-color": d.border_color || a?.border_color
319
- },
320
- children: [
321
- I && /* @__PURE__ */ e.jsx(
322
- _e,
323
- {
324
- setModalShow: L,
325
- ad: a,
326
- previewData: d
327
- }
328
- ),
329
- J && /* @__PURE__ */ e.jsx(
330
- we,
331
- {
332
- setModalShow: V,
333
- ad: a,
334
- previewData: d
335
- }
336
- ),
337
- /* @__PURE__ */ e.jsxs(
338
- "div",
339
- {
340
- className: "ad",
341
- children: [
342
- n?.articles_membership?.status !== "Active" && /* @__PURE__ */ e.jsxs(
343
- "div",
344
- {
345
- className: "main-panel",
346
- children: [
347
- /* @__PURE__ */ e.jsx("div", { className: "ad-warning flex-header", children: /* @__PURE__ */ e.jsxs("div", { className: "", children: [
348
- a?.city && "Local",
349
- " Advertisement"
350
- ] }) }),
351
- /* @__PURE__ */ e.jsxs("div", { className: "content-wrap", children: [
352
- /* @__PURE__ */ e.jsxs("div", { className: "photo-banner", children: [
353
- /* @__PURE__ */ e.jsx("div", { className: "logo", children: (d.logo?.location || a?.logo?.location) && /* @__PURE__ */ e.jsx(
354
- "img",
355
- {
356
- src: d?.logo?.key ? `${process.env.NEXT_PUBLIC_CDN}${d?.logo?.key}` : `${process.env.NEXT_PUBLIC_CDN}${a?.logo?.key}`,
357
- alt: ""
358
- }
359
- ) }),
360
- /* @__PURE__ */ e.jsx("div", { className: "icon d-none", children: /* @__PURE__ */ e.jsx("i", { className: "fas fa-mug-hot" }) }),
361
- /* @__PURE__ */ e.jsx(
362
- "img",
363
- {
364
- className: "photo",
365
- src: d?.background?.key ? `${process.env.NEXT_PUBLIC_CDN}${d.background?.key}` : `${process.env.NEXT_PUBLIC_CDN}${a?.background?.key}`,
366
- alt: ""
367
- }
368
- )
369
- ] }),
370
- /* @__PURE__ */ e.jsxs("div", { className: "details-wrap", children: [
371
- /* @__PURE__ */ e.jsxs("div", { className: "detail-title", children: [
372
- /* @__PURE__ */ e.jsx("div", { className: "detail", children: /* @__PURE__ */ e.jsx("span", { className: "h4", children: d?.business || a?.business }) }),
373
- /* @__PURE__ */ e.jsxs("div", { className: "flex flex-column d-none", children: [
374
- /* @__PURE__ */ e.jsxs("div", { className: "detail", children: [
375
- /* @__PURE__ */ e.jsx("span", { className: "icon", children: /* @__PURE__ */ e.jsx("i", { className: "fas fa-search-location" }) }),
376
- /* @__PURE__ */ e.jsxs("span", { children: [
377
- a?.city,
378
- ", ",
379
- a?.state
380
- ] })
381
- ] }),
382
- /* @__PURE__ */ e.jsxs("div", { className: "detail", children: [
383
- /* @__PURE__ */ e.jsx("span", { className: "icon", children: /* @__PURE__ */ e.jsx("i", { className: "fas fa-clock me-2" }) }),
384
- /* @__PURE__ */ e.jsx("span", { children: "6:30AM–8PM" })
385
- ] })
386
- ] })
387
- ] }),
388
- a?.city && /* @__PURE__ */ e.jsx("div", { className: "details mb-3 d-none" }),
389
- /* @__PURE__ */ e.jsx("div", { className: "short-description", children: d?.description || a?.description })
390
- ] })
391
- ] }),
392
- f?.roles?.isDev && a?.populated_promos?.length > 0 && /* @__PURE__ */ e.jsxs("div", { children: [
393
- x && /* @__PURE__ */ e.jsx("div", { className: "promos-wrap", children: x && /* @__PURE__ */ e.jsxs(
394
- "div",
395
- {
396
- className: "promo-wrap d-flex justify-content-between align-items-center mx-2 p-1 px-2 border border-2 border-light mb-0",
397
- children: [
398
- /* @__PURE__ */ e.jsxs("div", { className: "", children: [
399
- /* @__PURE__ */ e.jsx("div", { children: x.title }),
400
- /* @__PURE__ */ e.jsx("div", { className: "small", children: /* @__PURE__ */ e.jsx("div", { className: "small", children: x.details }) })
401
- ] }),
402
- /* @__PURE__ */ e.jsx(
403
- ne,
404
- {
405
- className: "px-3",
406
- small: !0,
407
- onClick: () => {
408
- console.log("Load Save Modal"), k(!0);
409
- },
410
- children: "Save"
411
- }
412
- )
413
- ]
414
- },
415
- x._id
416
- ) }),
417
- /* @__PURE__ */ e.jsxs("div", { className: "d-flex justify-content-between", children: [
418
- /* @__PURE__ */ e.jsxs("div", { className: "px-2", children: [
419
- a?.populated_promos?.length,
420
- " Promos Active"
421
- ] }),
422
- /* @__PURE__ */ e.jsxs("div", { className: "controls", children: [
423
- /* @__PURE__ */ e.jsx(
424
- "i",
425
- {
426
- className: "fad fa-arrow-circle-left",
427
- type: "button",
428
- onClick: () => {
429
- m == 0 ? v(a?.populated_promos?.length - 1) : v((l) => l - 1);
430
- }
431
- }
432
- ),
433
- a?.populated_promos?.map(
434
- (l, g) => /* @__PURE__ */ e.jsx(
435
- "i",
436
- {
437
- className: `fa-square ${g == m ? "fad" : "fas"}`
438
- },
439
- l._id
440
- )
441
- ),
442
- /* @__PURE__ */ e.jsx(
443
- "i",
444
- {
445
- className: "fad fa-arrow-circle-right",
446
- type: "button",
447
- onClick: () => {
448
- m == a?.populated_promos?.length - 1 ? v(0) : v((l) => l + 1);
449
- }
450
- }
451
- )
452
- ] })
453
- ] })
454
- ] }),
455
- /* @__PURE__ */ e.jsx("hr", { style: { borderColor: "white" }, className: "mt-auto mb-0" }),
456
- /* @__PURE__ */ e.jsxs("div", { className: "action-wrap d-flex justify-content-lg-between px-3 py-2", children: [
457
- /* @__PURE__ */ e.jsx(
458
- "div",
459
- {
460
- onClick: () => {
461
- Y(), T("Details");
462
- },
463
- className: "action flex-grow-1 flex-shrink-0",
464
- children: "Details"
465
- }
466
- ),
467
- /* @__PURE__ */ e.jsx("span", { className: "px-4" }),
468
- /* @__PURE__ */ e.jsx(
469
- "a",
470
- {
471
- className: "action flex-grow-1 flex-shrink-0",
472
- href: a?.website,
473
- target: "_blank",
474
- rel: "noreferrer",
475
- onClick: (l) => {
476
- l.preventDefault(), V(!0), T("Confirm Exit Modal Opened");
477
- },
478
- children: /* @__PURE__ */ e.jsx("div", { children: "Website" })
479
- }
480
- )
481
- ] })
482
- ]
483
- }
484
- ),
485
- n?.articles_membership?.status == "Active" && /* @__PURE__ */ e.jsx(
486
- "div",
487
- {
488
- className: "main-panel",
489
- children: /* @__PURE__ */ e.jsxs("div", { className: "content-wrap", children: [
490
- /* @__PURE__ */ e.jsxs("div", { className: "photo-banner", children: [
491
- /* @__PURE__ */ e.jsx("div", { className: "logo" }),
492
- /* @__PURE__ */ e.jsxs("div", { className: "splash", children: [
493
- /* @__PURE__ */ e.jsx("i", { className: "fas fa-broadcast-tower" }),
494
- /* @__PURE__ */ e.jsxs("div", { className: "text", children: [
495
- /* @__PURE__ */ e.jsx(
496
- "div",
497
- {
498
- className: "count",
499
- children: se ? /* @__PURE__ */ e.jsx("i", { className: "fas fa-spinner fa-spin me-0" }) : B ? ae(B) : 0
500
- }
501
- ),
502
- /* @__PURE__ */ e.jsx("div", { className: "label", children: "ads avoided." })
503
- ] })
504
- ] }),
505
- /* @__PURE__ */ e.jsxs(
506
- "div",
507
- {
508
- className: "member-since",
509
- children: [
510
- "Member since: ",
511
- /* @__PURE__ */ e.jsx(re, { format: "PP", date: n?.articles_membership?.membership_started })
512
- ]
513
- }
514
- )
515
- ] }),
516
- /* @__PURE__ */ e.jsxs("div", { className: "details-wrap", children: [
517
- /* @__PURE__ */ e.jsx("div", { className: "detail-title", children: /* @__PURE__ */ e.jsx("div", { className: "detail", children: /* @__PURE__ */ e.jsx("span", { className: "h4", children: "Thanks for the support!" }) }) }),
518
- /* @__PURE__ */ e.jsxs("div", { className: "short-description", children: [
519
- /* @__PURE__ */ e.jsx("div", { className: "mb-2", children: "Without support from users like you, we wouldn't be here." }),
520
- /* @__PURE__ */ e.jsxs("div", { className: "links-list", children: [
521
- /* @__PURE__ */ e.jsxs(
522
- C,
523
- {
524
- newPage: !0,
525
- className: "link-item",
526
- href: "https://articles.media/messages",
527
- children: [
528
- /* @__PURE__ */ e.jsx("i", { className: "fas fa-comments-alt" }),
529
- "0 unread messages."
530
- ]
531
- }
532
- ),
533
- /* @__PURE__ */ e.jsxs(
534
- C,
535
- {
536
- newPage: !0,
537
- className: "link-item",
538
- href: "https://articles.media/settings/notifications",
539
- onClick: () => {
540
- W();
541
- },
542
- children: [
543
- /* @__PURE__ */ e.jsx("i", { className: "fas fa-bell" }),
544
- "0 notifications."
545
- ]
546
- }
547
- ),
548
- /* @__PURE__ */ e.jsxs(
549
- C,
550
- {
551
- newPage: !0,
552
- className: "link-item",
553
- href: "https://articles.media/settings/account",
554
- children: [
555
- /* @__PURE__ */ e.jsx("i", { className: "fas fa-cog" }),
556
- "Manage account settings."
557
- ]
558
- }
559
- )
560
- ] })
561
- ] })
562
- ] })
563
- ] })
564
- }
565
- )
566
- ]
567
- }
568
- ),
569
- !t && /* @__PURE__ */ e.jsx(
570
- "div",
571
- {
572
- className: "advertise-with-us p-1",
573
- style: {
574
- // ...(props.previewData ? props.previewData.background_color : ad?.background_color),
575
- backgroundColor: d.background_color || a?.background_color,
576
- color: d.font_color || a?.font_color,
577
- borderColor: d.border_color || a?.border_color
578
- },
579
- children: /* @__PURE__ */ e.jsxs(
580
- C,
581
- {
582
- className: "small d-block w-100 text-center",
583
- href: "https://articles.media/advertising",
584
- newPage: !0,
585
- children: [
586
- /* @__PURE__ */ e.jsx("i", { className: "fas fa-share me-1" }),
587
- "Advertise with Articles Media!"
588
- ]
589
- }
590
- )
591
- }
592
- )
593
- ]
594
- }
595
- );
596
- }
597
- const Se = te(ke);
598
- export {
599
- Se as default
600
- };