@articles-media/articles-dev-box 1.0.8 → 1.0.10
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 +20 -4
- package/dist/Ad.cjs +1 -1
- package/dist/Ad.js +294 -218
- package/dist/{AdConfirmExitModal-CxBj8QjF.js → AdConfirmExitModal-CKkMAvBK.js} +3 -3
- package/dist/AdConfirmExitModal-CcSxmXKT.cjs +1 -0
- package/dist/{AdDetailsModal-CZTFVOLB.js → AdDetailsModal-Bp5hZm9N.js} +3 -3
- package/dist/AdDetailsModal-k840vrS2.cjs +1 -0
- package/dist/Button-0ZK0NKiK.cjs +1 -0
- package/dist/Button-_Quon8UV.js +54 -0
- package/dist/GameScoreboard.cjs +1 -1
- package/dist/GameScoreboard.js +2 -2
- package/dist/GlobalBody-BQ2qC81K.cjs +33 -0
- package/dist/GlobalBody-tmIC_GWn.js +123 -0
- package/dist/GlobalBody.cjs +1 -25
- package/dist/GlobalBody.js +5 -43
- package/dist/GlobalHead.cjs +1 -1
- package/dist/GlobalHead.js +2 -2
- package/dist/{Modal-CZ77qLgM.js → Modal-C9oYRgI1.js} +102 -102
- package/dist/Modal-Wmqy9fOm.cjs +2 -0
- package/dist/ReturnToLauncherButton.cjs +1 -1
- package/dist/ReturnToLauncherButton.js +1 -1
- package/dist/StatusModal-BlwaI-2B.cjs +1 -0
- package/dist/StatusModal-CAVxWCUq.js +71 -0
- package/dist/ViewUserModal.cjs +1 -1
- package/dist/ViewUserModal.js +1930 -2534
- package/dist/articles-dev-box.css +1 -1
- package/dist/index-BlP2-uOi.cjs +1 -0
- package/dist/index-YnD2EP-S.js +43 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +11 -11
- package/dist/numberWithCommas-CRgrb58X.cjs +1 -0
- package/dist/numberWithCommas-DnAkiOFL.js +1256 -0
- package/dist/useUserToken.cjs +1 -1
- package/dist/useUserToken.js +7 -7
- package/package.json +1 -1
- package/dist/AdConfirmExitModal-ZUzQA_M8.cjs +0 -1
- package/dist/AdDetailsModal-Cj0Uwazv.cjs +0 -1
- package/dist/Button-B5nVYPMZ.js +0 -93
- package/dist/Button-BVYvDTtH.cjs +0 -1
- package/dist/Modal-Cr0uB770.cjs +0 -2
- package/dist/toDate-CDU0W0Ek.cjs +0 -1
- package/dist/toDate-DiBqlcLH.js +0 -28
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Articles Dev Box
|
|
2
2
|
|
|
3
|
-
Shared code, functions, and components that are commonly used across Articles Media projects.
|
|
3
|
+
Shared code, functions, and components that are commonly used across Articles Media projects.
|
|
4
|
+
|
|
5
|
+
# Warning
|
|
6
|
+
None of this is meant to work outside the Articles Media frontend React ecosystem. Breaking changes are being made in between patch releases until 1.1.0, when we switch to major release for breaking.
|
|
4
7
|
|
|
5
8
|
## Getting Started
|
|
6
9
|
|
|
@@ -22,6 +25,12 @@ Then go to the consuming project directory and run this command.
|
|
|
22
25
|
npm link @articles-media/articles-dev-box
|
|
23
26
|
```
|
|
24
27
|
|
|
28
|
+
You will need to have a dev script running to watch for changes and build the dist to see local changes
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run dev
|
|
32
|
+
```
|
|
33
|
+
|
|
25
34
|
## Package Exports
|
|
26
35
|
|
|
27
36
|
- ReturnToLauncherButton
|
|
@@ -30,15 +39,22 @@ npm link @articles-media/articles-dev-box
|
|
|
30
39
|
- Scoreboard for registered games that links with a user's Articles Media account.
|
|
31
40
|
- Ad
|
|
32
41
|
- Articles Ad component that connects with user data.
|
|
42
|
+
- GlobalHead
|
|
43
|
+
- Not used at this time, allows for just <head> related tags to be added to site without other logic.
|
|
33
44
|
- GlobalBody
|
|
34
|
-
- Easy way to add future logic and components to all projects with ease. For now handling the font awesome script.
|
|
45
|
+
- 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.
|
|
35
46
|
- ViewUserModal
|
|
36
|
-
- View user profile data and recent activity
|
|
47
|
+
- View user profile data and recent activity.
|
|
48
|
+
- useUserToken
|
|
49
|
+
- Hook for getting the subdomain auth token.
|
|
50
|
+
- useUserDetails
|
|
51
|
+
- Hook for getting the details of the current user if a valid user token is found.
|
|
37
52
|
|
|
38
53
|
# Roadmap
|
|
39
54
|
⏹️ Remove Bootstrap reliance
|
|
40
55
|
⏹️ Look into npm package yalc
|
|
41
|
-
⏹️ Automatic GitHub Action for NPM
|
|
56
|
+
⏹️ Automatic GitHub Action for NPM are done but need to figure out how to show verified build badge on NPM.
|
|
57
|
+
⏹️ Figure out why this package does not work outside webpack, on Turbopack for example it fails.
|
|
42
58
|
|
|
43
59
|
|
|
44
60
|
# TODO
|
package/dist/Ad.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./jsx-runtime-nZSsnGb7.cjs"),c=require("react"),M=require("./toDate-CDU0W0Ek.cjs"),N=require("./index-Ddv_TnxK.cjs"),X=require("./Button-BVYvDTtH.cjs");function K(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const i in s)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:()=>s[i]})}}return t.default=s,Object.freeze(t)}const _=K(c);var C=new Map,S=new WeakMap,V=0,Y;function F(s){return s?(S.has(s)||(V+=1,S.set(s,V.toString())),S.get(s)):"0"}function G(s){return Object.keys(s).sort().filter(t=>s[t]!==void 0).map(t=>`${t}_${t==="root"?F(s.root):s[t]}`).toString()}function H(s){const t=G(s);let i=C.get(t);if(!i){const n=new Map;let l;const d=new IntersectionObserver(u=>{u.forEach(a=>{var o;const m=a.isIntersecting&&l.some(h=>a.intersectionRatio>=h);s.trackVisibility&&typeof a.isVisible>"u"&&(a.isVisible=m),(o=n.get(a.target))==null||o.forEach(h=>{h(m,a)})})},s);l=d.thresholds||(Array.isArray(s.threshold)?s.threshold:[s.threshold||0]),i={id:t,observer:d,elements:n},C.set(t,i)}return i}function J(s,t,i={},n=Y){if(typeof window.IntersectionObserver>"u"&&n!==void 0){const o=s.getBoundingClientRect();return t(n,{isIntersecting:n,target:s,intersectionRatio:typeof i.threshold=="number"?i.threshold:0,time:0,boundingClientRect:o,intersectionRect:o,rootBounds:o}),()=>{}}const{id:l,observer:d,elements:u}=H(i),a=u.get(s)||[];return u.has(s)||u.set(s,a),a.push(t),d.observe(s),function(){a.splice(a.indexOf(t),1),a.length===0&&(u.delete(s),d.unobserve(s)),u.size===0&&(d.disconnect(),C.delete(l))}}function Q({threshold:s,delay:t,trackVisibility:i,rootMargin:n,root:l,triggerOnce:d,skip:u,initialInView:a,fallbackInView:o,onChange:m}={}){var h;const[y,$]=_.useState(null),A=_.useRef(m),b=_.useRef(a),[f,D]=_.useState({inView:!!a,entry:void 0});A.current=m,_.useEffect(()=>{if(b.current===void 0&&(b.current=a),u||!y)return;let g;return g=J(y,(R,w)=>{const k=b.current;b.current=R,!(k===void 0&&!R)&&(D({inView:R,entry:w}),A.current&&A.current(R,w),w.isIntersecting&&d&&g&&(g(),g=void 0))},{root:l,rootMargin:n,threshold:s,trackVisibility:i,delay:t},o),()=>{g&&g()}},[Array.isArray(s)?s.toString():s,y,l,n,d,u,i,o,t]);const j=(h=f.entry)==null?void 0:h.target,E=_.useRef(void 0);!y&&j&&!d&&!u&&E.current!==j&&(E.current=j,D({inView:!!a,entry:void 0}),b.current=a);const v=[$,f.inView,f.entry];return v.ref=v[0],v.inView=v[1],v.entry=v[2],v}const Z=async s=>{if(process.env.NODE_ENV==="development")try{return(await N.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 N.axios.get(s.url,{params:{ad_id:s.ad_id}}).then(t=>t.data.result)},ee=60,se={dedupingInterval:1e3*60*ee},te=(s,t)=>{const{data:i,error:n,isLoading:l,mutate:d}=N.useSWR(s?{url:`https://articles.media/api/ads/${s}`,ad_id:s,user_ad_token:t}:null,Z,se);return{data:i,error:n,isLoading:l,mutate:d}};function re(s){return t=>{const n=(s?Math[s]:Math.trunc)(t);return n===0?0:n}}function ne(s,t){return+M.toDate(s)-+M.toDate(t)}function L(s,t,i){const n=ne(s,t)/M.millisecondsInMinute;return re(i?.roundingMethod)(n)}function q(s){return Math.trunc(s*M.millisecondsInMinute)}const oe=async s=>{if(process.env.NODE_ENV==="development")try{return(await N.axios.get("http://localhost:3001/api/ads",{params:{}})).data}catch{}return N.axios.get(s.url,{params:{}}).then(t=>t.data)},B=60,ie={dedupingInterval:q(B),focusThrottleInterval:q(B)},ae=s=>{const{data:t,error:i,isLoading:n,mutate:l}=N.useSWR({url:"https://articles.media/api/ads"},oe,ie);return{data:t,error:i,isLoading:n,mutate:l}},ce=c.lazy(()=>Promise.resolve().then(()=>require("./AdDetailsModal-Cj0Uwazv.cjs"))),le=c.lazy(()=>Promise.resolve().then(()=>require("./AdConfirmExitModal-ZUzQA_M8.cjs")));function de(s,t){return Math.floor(Math.random()*(t-s+1))+s}function ue(s){const i=[],{data:n}=ae();let{previewMode:l,darkMode:d,user_ad_token:u,userDetails:a}=s,o=s.previewData||{};const[m,h]=c.useState(null),[y,$]=c.useState(null),[A,b]=c.useState(null),[f,D]=c.useState(null),[j,E]=c.useState(0),[v,g]=c.useState(!1),[R,w]=c.useState(!1),[k,O]=c.useState(!1),[me,pe]=c.useState(new Date),[P,W]=c.useState([]),{data:r}=te(m,u);c.useEffect(()=>{n&&n?.length>0&&!m&&(console.log("Ad Mounted or reduxAds changed"),h(s.ad_id||n[de(0,n?.length-1)]?._id))},[n]),c.useEffect(()=>{},[r]),c.useEffect(()=>{r?.populated_promos&&j>=0&&D(r?.populated_promos[j])},[j,r]);function z(){w(!R)}const{ref:U,inView:I}=Q({threshold:0,triggerOnce:!0});function T(x){if(l&&console.log("Preventing this event from being logged as this ad is being shown in preview mode."),P.find(p=>p==x)){console.log("Already logged this event");return}N.axios.get("/api/ads/event",{params:{ad_id:r?._id,event:x}}).then(function(p){W([...P,x]),console.log(p.data)}).catch(function(p){console.log(p)})}return c.useEffect(()=>{if(!l&&(console.log("inView",I),I&&m)){let x=[{ad_id:m,date:new Date().toString()},...i.filter(p=>{if(console.log(L(new Date,new Date(p.date))),L(new Date,new Date(p.date))>5){console.log("adsViewed - Remove Old Ad View Object");return}else return console.log("adsViewed - Keep Ad View Object"),p})];console.log("unexpiredRecentViews",x)}},[I,m]),e.jsxRuntimeExports.jsxs("div",{ref:U,className:"ad-wrap",style:{"--articles-ad-background-color":o.background_color||r?.background_color,"--articles-ad-font-color":o.font_color||r?.font_color,"--articles-ad-border-color":o.border_color||r?.border_color},children:[R&&e.jsxRuntimeExports.jsx(ce,{setModalShow:w,ad:r,previewData:o}),k&&e.jsxRuntimeExports.jsx(le,{setModalShow:O,ad:r,previewData:o}),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:[r?.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:(o.logo?.location||r?.logo?.location)&&e.jsxRuntimeExports.jsx("img",{src:o?.logo?.key?`${process.env.NEXT_PUBLIC_CDN}${o?.logo?.key}`:`${process.env.NEXT_PUBLIC_CDN}${r?.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:o?.background?.key?`${process.env.NEXT_PUBLIC_CDN}${o.background?.key}`:`${process.env.NEXT_PUBLIC_CDN}${r?.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:o?.business||r?.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:[r?.city,", ",r?.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"})]})]})]}),r?.city&&e.jsxRuntimeExports.jsx("div",{className:"details mb-3 d-none"}),e.jsxRuntimeExports.jsx("div",{className:"short-description",children:o?.description||r?.description})]})]}),(!1)?.roles?.isDev&&r?.populated_promos?.length>0&&e.jsxRuntimeExports.jsxs("div",{children:[f&&e.jsxRuntimeExports.jsx("div",{className:"promos-wrap",children:f&&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:f.title}),e.jsxRuntimeExports.jsx("div",{className:"small",children:e.jsxRuntimeExports.jsx("div",{className:"small",children:f.details})})]}),e.jsxRuntimeExports.jsx(X.ArticlesButton,{className:"px-3",small:!0,onClick:()=>{console.log("Load Save Modal"),g(!0)},children:"Save"})]},f._id)}),e.jsxRuntimeExports.jsxs("div",{className:"d-flex justify-content-between",children:[e.jsxRuntimeExports.jsxs("div",{className:"px-2",children:[r?.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:()=>{j==0?E(r?.populated_promos?.length-1):E(x=>x-1)}}),r?.populated_promos?.map((x,p)=>e.jsxRuntimeExports.jsx("i",{className:`fa-square ${p==j?"fad":"fas"}`},x._id)),e.jsxRuntimeExports.jsx("i",{className:"fad fa-arrow-circle-right",type:"button",onClick:()=>{j==r?.populated_promos?.length-1?E(0):E(x=>x+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:()=>{z(),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:r?.website,target:"_blank",rel:"noreferrer",onClick:x=>{x.preventDefault(),O(!0),T("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.jsx("div",{className:"icon d-none",children:e.jsxRuntimeExports.jsx("i",{className:"fas fa-mug-hot"})}),e.jsxRuntimeExports.jsx("img",{className:"photo",alt:""})]}),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:"Thank You So Much!"})})}),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",{children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-comments-alt"}),"3 unread messages."]}),e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-bell"}),"2 notifications."]})]})]})]})})]}),!l&&e.jsxRuntimeExports.jsx("div",{className:"advertise-with-us p-1",style:{backgroundColor:o.background_color||r?.background_color,color:o.font_color||r?.font_color,borderColor:o.border_color||r?.border_color},children:e.jsxRuntimeExports.jsxs(M.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 xe=c.memo(ue);module.exports=xe;
|
|
1
|
+
"use strict";const e=require("./jsx-runtime-nZSsnGb7.cjs"),c=require("react"),v=require("./numberWithCommas-CRgrb58X.cjs"),E=require("./index-Ddv_TnxK.cjs"),H=require("./Button-0ZK0NKiK.cjs"),J=require("./index-BlP2-uOi.cjs");function Q(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 _=Q(c);var C=new Map,S=new WeakMap,q=0,Y;function Z(s){return s?(S.has(s)||(q+=1,S.set(s,q.toString())),S.get(s)):"0"}function ee(s){return Object.keys(s).sort().filter(t=>s[t]!==void 0).map(t=>`${t}_${t==="root"?Z(s.root):s[t]}`).toString()}function se(s){const t=ee(s);let i=C.get(t);if(!i){const r=new Map;let o;const x=new IntersectionObserver(p=>{p.forEach(a=>{var u;const R=a.isIntersecting&&o.some(j=>a.intersectionRatio>=j);s.trackVisibility&&typeof a.isVisible>"u"&&(a.isVisible=R),(u=r.get(a.target))==null||u.forEach(j=>{j(R,a)})})},s);o=x.thresholds||(Array.isArray(s.threshold)?s.threshold:[s.threshold||0]),i={id:t,observer:x,elements:r},C.set(t,i)}return i}function te(s,t,i={},r=Y){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:o,observer:x,elements:p}=se(i),a=p.get(s)||[];return p.has(s)||p.set(s,a),a.push(t),x.observe(s),function(){a.splice(a.indexOf(t),1),a.length===0&&(p.delete(s),x.unobserve(s)),p.size===0&&(x.disconnect(),C.delete(o))}}function ne({threshold:s,delay:t,trackVisibility:i,rootMargin:r,root:o,triggerOnce:x,skip:p,initialInView:a,fallbackInView:u,onChange:R}={}){var j;const[n,d]=_.useState(null),k=_.useRef(R),N=_.useRef(a),[y,I]=_.useState({inView:!!a,entry:void 0});k.current=R,_.useEffect(()=>{if(N.current===void 0&&(N.current=a),p||!n)return;let f;return f=te(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&&f&&(f(),f=void 0))},{root:o,rootMargin:r,threshold:s,trackVisibility:i,delay:t},u),()=>{f&&f()}},[Array.isArray(s)?s.toString():s,n,o,r,x,p,i,u,t]);const g=(j=y.entry)==null?void 0:j.target,M=_.useRef(void 0);!n&&g&&!x&&!p&&M.current!==g&&(M.current=g,I({inView:!!a,entry:void 0}),N.current=a);const m=[d,y.inView,y.entry];return m.ref=m[0],m.inView=m[1],m.entry=m[2],m}const re=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)},ie=60,oe={dedupingInterval:1e3*60*ie},ae=(s,t)=>{const{data:i,error:r,isLoading:o,mutate:x}=E.useSWR(s?{url:`https://articles.media/api/ads/${s}`,ad_id:s,user_ad_token:t}:null,re,oe);return{data:i,error:r,isLoading:o,mutate:x}};function ce(s){return t=>{const r=(s?Math[s]:Math.trunc)(t);return r===0?0:r}}function le(s,t){return+v.toDate(s)-+v.toDate(t)}function B(s,t,i){const r=le(s,t)/v.millisecondsInMinute;return ce(i?.roundingMethod)(r)}function W(s){return Math.trunc(s*v.millisecondsInMinute)}const de=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)},z=60,ue={dedupingInterval:W(z),focusThrottleInterval:W(z)},xe=s=>{const{data:t,error:i,isLoading:r,mutate:o}=E.useSWR(s?.loading||s?.disabled?null:{url:"https://articles.media/api/ads"},de,ue);return{data:t,error:i,isLoading:r,mutate:o}},me=c.lazy(()=>Promise.resolve().then(()=>require("./AdDetailsModal-k840vrS2.cjs"))),pe=c.lazy(()=>Promise.resolve().then(()=>require("./AdConfirmExitModal-CcSxmXKT.cjs")));function je(s,t){return Math.floor(Math.random()*(t-s+1))+s}function fe(s){let{previewMode:t,darkMode:i,user_ad_token:r,userDetails:o,userDetailsLoading:x}=s;const p=!1,a=[],[u,R]=c.useState(null),{data:j}=xe({loading:x,disabled:o?.articles_membership?.status=="Active"}),{data:n}=ae(u,r);let d=s.previewData||{};const[k,N]=c.useState(null),[y,I]=c.useState(null),[g,M]=c.useState(null),[m,f]=c.useState(0),[w,A]=c.useState(!1),[D,P]=c.useState(!1),[U,$]=c.useState(!1),[ve,ge]=c.useState(new Date),[O,X]=c.useState([]);c.useEffect(()=>{j&&j?.length>0&&!u&&(console.log("Ad Mounted or reduxAds changed"),R(s.ad_id||j[je(0,j?.length-1)]?._id))},[j]),c.useEffect(()=>{},[n]),c.useEffect(()=>{n?.populated_promos&&m>=0&&M(n?.populated_promos[m])},[m,n]);function K(){P(!D)}const{ref:F,inView:b}=ne({threshold:0,triggerOnce:!0});function L(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){X([...O,l]),console.log(h.data)}).catch(function(h){console.log(h)})}c.useEffect(()=>{if(!t&&(console.log("inView",b),b&&u)){let l=[{ad_id:u,date:new Date().toString()},...a.filter(h=>{if(console.log(B(new Date,new Date(h.date))),B(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[V,G]=c.useState(null);function T(){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:o?._id},headers:{"x-articles-api-key":r}}).then(function(l){G(l.data.avoided_count),console.log(l.data)}).catch(function(l){console.log(l)})}return c.useEffect(()=>{t||(console.log("inView",b),o?.articles_membership?.status=="Active"&&b&&T())},[b,o]),x?null:e.jsxRuntimeExports.jsxs("div",{ref:F,className:J.classNames("ad-wrap",{"active-member":o?.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(me,{setModalShow:P,ad:n,previewData:d}),U&&e.jsxRuntimeExports.jsx(pe,{setModalShow:$,ad:n,previewData:d}),e.jsxRuntimeExports.jsxs("div",{className:"ad",children:[o?.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(H.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?f(n?.populated_promos?.length-1):f(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?f(0):f(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:()=>{K(),L("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(),$(!0),L("Confirm Exit Modal Opened")},children:e.jsxRuntimeExports.jsx("div",{children:"Website"})})]})]}),o?.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:V?v.numberWithCommas(V):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:o?.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:()=>{T()},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 he=c.memo(fe);module.exports=he;
|