@times-components/article-comments 0.43.28-alpha.33 → 0.43.28-alpha.35
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/dist/article-comments.js +14 -13
- package/dist/user-entitlement-provider.js +1 -1
- package/dist/user-entitlements.js +1 -1
- package/package.json +2 -2
- package/rnw.js +1 -1
package/dist/article-comments.js
CHANGED
|
@@ -51,11 +51,8 @@ const ArticleComments = _ref => {
|
|
|
51
51
|
isCommentEnabled = _ref.isCommentEnabled,
|
|
52
52
|
storefrontConfig = _ref.storefrontConfig,
|
|
53
53
|
domainSpecificUrl = _ref.domainSpecificUrl;
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
// );
|
|
57
|
-
const entitlementFeatureEnable = true;
|
|
58
|
-
console.log('rendering article-comments1234');
|
|
54
|
+
const entitlementFeatureEnable = window && window.sessionStorage && window.sessionStorage.getItem("entitlementFeatureEnable");
|
|
55
|
+
console.log("entitlementFeatureEnable", entitlementFeatureEnable); // console.log("query testing...", window && window.location.search.includes("entitlementFeatureEnable"));
|
|
59
56
|
|
|
60
57
|
const _useState = (0, _react.useState)(undefined),
|
|
61
58
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -63,13 +60,9 @@ const ArticleComments = _ref => {
|
|
|
63
60
|
setUserEntitlements = _useState2[1];
|
|
64
61
|
|
|
65
62
|
(0, _react.useEffect)(() => {
|
|
66
|
-
if (window) {
|
|
67
|
-
console.log('window accessible');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
63
|
const fetchUserEntitlements = /*#__PURE__*/function () {
|
|
71
64
|
var _ref2 = _asyncToGenerator(function* () {
|
|
72
|
-
const response = yield fetch(
|
|
65
|
+
const response = yield fetch("/api/get-user-entitlements");
|
|
73
66
|
const data = yield response.json();
|
|
74
67
|
setUserEntitlements(data);
|
|
75
68
|
});
|
|
@@ -79,7 +72,10 @@ const ArticleComments = _ref => {
|
|
|
79
72
|
};
|
|
80
73
|
}();
|
|
81
74
|
|
|
82
|
-
|
|
75
|
+
if (window && entitlementFeatureEnable) {
|
|
76
|
+
console.log('window object acessible............');
|
|
77
|
+
fetchUserEntitlements();
|
|
78
|
+
}
|
|
83
79
|
}, []);
|
|
84
80
|
return (
|
|
85
81
|
/*#__PURE__*/
|
|
@@ -90,9 +86,14 @@ const ArticleComments = _ref => {
|
|
|
90
86
|
storefrontConfig: storefrontConfig
|
|
91
87
|
})), !entitlementFeatureEnable ? /*#__PURE__*/_react.default.createElement(_userState.default, {
|
|
92
88
|
state: _userState.default.showCommentingModule
|
|
93
|
-
}, /*#__PURE__*/_react.default.createElement("p", null, "inside UserState provider")
|
|
89
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, "inside UserState provider"), /*#__PURE__*/_react.default.createElement(_comments.default, {
|
|
90
|
+
articleId: articleId,
|
|
91
|
+
isReadOnly: isReadOnly,
|
|
92
|
+
commentingConfig: commentingConfig,
|
|
93
|
+
domainSpecificUrl: domainSpecificUrl
|
|
94
|
+
})) : /*#__PURE__*/_react.default.createElement(_userEntitlements.UserEntitlements, {
|
|
94
95
|
userEntitlementsList: userEntitlements
|
|
95
|
-
}, /*#__PURE__*/_react.default.createElement(_comments.default, {
|
|
96
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, "inside UserEntitlements"), /*#__PURE__*/_react.default.createElement(_comments.default, {
|
|
96
97
|
articleId: articleId,
|
|
97
98
|
isReadOnly: isReadOnly,
|
|
98
99
|
commentingConfig: commentingConfig,
|
|
@@ -17,7 +17,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
17
17
|
|
|
18
18
|
const UserEntitlementProvider = _ref => {
|
|
19
19
|
let children = _ref.children;
|
|
20
|
-
console.log(
|
|
20
|
+
console.log("children inside UserEntitlementProvider", children);
|
|
21
21
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null) // <FetchProvider url="/api/get-user-entitlements">
|
|
22
22
|
// <UserEntitlements>{children}</UserEntitlements>
|
|
23
23
|
// </FetchProvider>
|
|
@@ -47,7 +47,7 @@ const UserEntitlements = _ref => {
|
|
|
47
47
|
// console.log('featureDecisions', featureDecisions);
|
|
48
48
|
|
|
49
49
|
const isCommentingEntitlementEnabled = featureDecisions && featureDecisions.some(decision => {
|
|
50
|
-
return decision.code === "fp-752" && decision.outcome.toLowerCase().includes(
|
|
50
|
+
return decision.code === "fp-752" && decision.outcome.toLowerCase().includes("disable");
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
if (userEntitlementsList === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@times-components/article-comments",
|
|
3
|
-
"version": "0.43.28-alpha.
|
|
3
|
+
"version": "0.43.28-alpha.35+059400674c",
|
|
4
4
|
"description": "Article Comments",
|
|
5
5
|
"main": "dist/article-comments",
|
|
6
6
|
"dev": "src/article-comments",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "059400674cf1e64f4925fb216641a6545a73c6e0"
|
|
74
74
|
}
|
package/rnw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t,n){"use strict";n.r(t);var o=n(1),i=n.n(o),r=(n(4),n(2)),a=n.n(r),c=n(3),m=n.n(c),s=n(0);const l=m.a.div.withConfig({displayName:"responsive__CommentContainer",componentId:"sc-2j1dkf-0"})(["margin-left:auto;margin-right:auto;@media (min-width:","px){width:80.8%;}@media (min-width:","px){width:56.2%;}"],s.breakpoints.medium,s.breakpoints.wide);m.a.p.withConfig({displayName:"responsive__CommentEnabledGuidelines",componentId:"sc-2j1dkf-1"})(["color:",";font-family:",";font-size:","px;margin:0 0 "," 0;padding-left:7px;padding-top:",";"],s.colours.functional.secondary,s.fontsWithFallback.supporting,s.fontSizes.commentsGuidelines,Object(s.spacing)(-2),Object(s.spacing)(6)),m.a.p.withConfig({displayName:"responsive__CommentDisabledGuidelines",componentId:"sc-2j1dkf-2"})(["color:",";font-family:",";font-size:","px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],s.colours.functional.secondary,s.fontsWithFallback.supporting,s.fontSizes.commentsGuidelines,Object(s.spacing)(6),Object(s.spacing)(1)),m.a.p.withConfig({displayName:"responsive__CommentDisabledHeadline",componentId:"sc-2j1dkf-3"})(["color:",";font-family:",";font-size:","px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],s.colours.functional.primary,s.fontsWithFallback.headline,s.fontSizes.commentsHeadline,Object(s.spacing)(1),Object(s.spacing)(6));function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,i,r=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var p=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=u(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;const f=(e,t)=>((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const e=(200===n.status?JSON.parse(n.response):{}).spotimCodeB;e&&t(e)}),n.open("GET",e),n.send()})("/api/comments/loginv2?codeA=".concat(encodeURIComponent(e)),t);var g=()=>{if(window.SPOTIM&&window.SPOTIM.startSSO){const e=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),t="".concat(p(e),"_v2");window.SPOTIM.startSSO({callback:f,userId:t})}},b=n(6);class C extends o.Component{constructor(){super(),this.container=null}componentDidMount(){this.initialiseComments()}componentWillUnmount(){this.disposeComments()}initialiseComments(){const e=this.props,t=e.articleId,n=e.isReadOnly,o=e.commentingConfig,i=e.onCommentStart,r=e.onCommentPost,a=e.onCommentNotification,c=e.onCommentFilterNewest,m=e.onCommentFilterMostRecommended,s=e.onCommentFilterOldest,l=e.onCommentReplyClick,u=e.onCommentShareLink,d=e.onCommentShareTwitter,p=e.onCommentShareEmail,f=e.onCommentShareFacebook,b=e.onCommentRecommend,C=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,v=e.onCommentSettingsClicked,h=e.domainSpecificUrl;if(!this.container||!t||!o)return;document.addEventListener("spot-im-current-user-typing-start",i),document.addEventListener("spot-im-current-user-sent-message",r),document.addEventListener("spot-im-notification-drop-down-link",a),document.addEventListener("spot-im-user-up-vote-click",b),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return m(e);case"oldest":return s(e);case"newest":return c(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",l),document.addEventListener("spot-im-clicked-settings",v),document.addEventListener("spot-im-user-notifications-click",C),document.addEventListener("spot-im-open-user-profile",y),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return u(e);case"email":return p(e);case"twitter":return d(e);case"facebook":return f(e);default:return null}})(e)),n||(window.SPOTIM&&window.SPOTIM.startSSO?g():document.addEventListener("spot-im-api-ready",()=>{g()})),document.addEventListener("spot-im-renew-sso",()=>{g()});const w=document.createElement("script");w.setAttribute("async","async"),w.setAttribute("src","https://launcher.spot.im/spot/".concat(o.account)),w.setAttribute("data-spotim-module","spotim-launcher"),w.setAttribute("data-post-id",t),w.setAttribute("data-post-url","".concat(h,"/article/").concat(t)),w.setAttribute("data-seo-enabled",!0),w.setAttribute("data-livefyre-url",t),this.container.appendChild(w)}disposeComments(){this.container&&(this.container.innerHTML="")}render(){const e=this.props,t=e.onCommentStart,n=e.onCommentPost,o=e.onCommentNotification,r=e.onCommentFilterNewest,a=e.onCommentFilterMostRecommended,c=e.onCommentFilterOldest,m=e.onCommentReplyClick,s=e.onCommentShareLink,u=e.onCommentShareTwitter,d=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,b=e.onCommentUsernameClicked,C=e.onCommentSettingsClicked;return i.a.createElement(l,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:m,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:c,onCommentShareLink:s,onCommentShareTwitter:u,onCommentShareEmail:d,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:b,onCommentSettingsClicked:C},i.a.createElement("div",{ref:e=>{this.container=e}}))}}C.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var y,v=(y=C,Object(b.withTrackEvents)(y,{analyticsEvents:[{actionName:"navigation",eventName:"onCommentStart",trackingName:"spot im : comment : start"},{actionName:"navigation",eventName:"onCommentPost",trackingName:"spot im : comment : complete"},{actionName:"navigation",eventName:"onCommentNotification",trackingName:"spot im : notification"},{actionName:"navigation",eventName:"onCommentFilterNewest",trackingName:"spot im : sort : newest"},{actionName:"navigation",eventName:"onCommentFilterMostRecommended",trackingName:"spot im : sort : best"},{actionName:"navigation",eventName:"onCommentFilterOldest",trackingName:"spot im : sort : oldest"},{actionName:"navigation",eventName:"onCommentReplyClick",trackingName:"spot im : reply"},{actionName:"navigation",eventName:"onCommentSettingsClicked",trackingName:"spot im : settings button clicked"},{actionName:"navigation",eventName:"onCommentShareLink",trackingName:"spot im : comment : share : copy link"},{actionName:"navigation",eventName:"onCommentShareEmail",trackingName:"spot im : comment : share : email"},{actionName:"navigation",eventName:"onCommentShareTwitter",trackingName:"spot im : comment : share : twitter"},{actionName:"navigation",eventName:"onCommentShareFacebook",trackingName:"spot im : comment : share : facebook"},{actionName:"navigation",eventName:"onCommentRecommend",trackingName:"spot im : vote up"},{actionName:"navigation",eventName:"onCommentUsernameClicked",trackingName:"spot im : username clicked"},{actionName:"navigation",eventName:"onCommentNotificationClicked",trackingName:"spot im : notification clicked"}]}));n(7);function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O={button:{marginBottom:Object(s.spacing)(0),marginTop:Object(s.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:s.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(s.spacing)(10),width:"100%"},headline:w(w({color:s.colours.functional.primary},Object(s.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(s.spacing)(2),paddingTop:Object(s.spacing)(6),textAlign:"center"}),link:{color:s.colours.functional.action},supporting:w(w({},Object(s.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:s.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}N(N({},O),{},{link:N(N({},O.link),{},{fontFamily:s.fontsWithFallback.supporting,fontSize:s.fontSizes.commentsGuidelines})});var E=n(5);var P=e=>{let t=e.storefrontConfig;const n=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,o=n?null:t,r=n?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(E.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:o,onClick:r},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")};const x=e=>{let t=e.userEntitlementsList,n=e.children;const o=t&&t.user&&t.user.subscriptions&&t.user.subscriptions[0]&&t.user.subscriptions[0].featureDecisions||[],i=o&&o.some(e=>"fp-752"===e.code&&e.outcome.toLowerCase().includes("disable"));return void 0===t?null:i&&n};function F(e,t,n,o,i,r,a){try{var c=e[r](a),m=c.value}catch(e){return void n(e)}c.done?t(m):Promise.resolve(m).then(o,i)}function L(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,i,r=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return T(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return T(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}const A=e=>{let t=e.articleId,n=(e.isEnabled,e.isReadOnly),r=e.commentingConfig,c=(e.isCommentEnabled,e.storefrontConfig),m=e.domainSpecificUrl;console.log("rendering article-comments1234");const s=L(Object(o.useState)(void 0),2),l=s[0],u=s[1];return Object(o.useEffect)(()=>{window&&console.log("window accessible");(function(){var e,t=(e=function*(){const e=yield fetch("/api/get-user-entitlements"),t=yield e.json();u(t)},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){F(r,o,i,a,c,"next",e)}function c(e){F(r,o,i,a,c,"throw",e)}a(void 0)}))});return function(){return t.apply(this,arguments)}})()()},[]),i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.showJoinTheConversationDialog},i.a.createElement(P,{storefrontConfig:c})),i.a.createElement(x,{userEntitlementsList:l},i.a.createElement(v,{articleId:t,isReadOnly:n,commentingConfig:r,domainSpecificUrl:m})))};A.defaultProps={isReadOnly:!1,isCommentEnabled:!0};t.default=A}]);
|
|
1
|
+
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t,n){"use strict";n.r(t);var o=n(1),i=n.n(o),r=(n(4),n(2)),a=n.n(r),c=n(3),m=n.n(c),s=n(0);const l=m.a.div.withConfig({displayName:"responsive__CommentContainer",componentId:"sc-2j1dkf-0"})(["margin-left:auto;margin-right:auto;@media (min-width:","px){width:80.8%;}@media (min-width:","px){width:56.2%;}"],s.breakpoints.medium,s.breakpoints.wide);m.a.p.withConfig({displayName:"responsive__CommentEnabledGuidelines",componentId:"sc-2j1dkf-1"})(["color:",";font-family:",";font-size:","px;margin:0 0 "," 0;padding-left:7px;padding-top:",";"],s.colours.functional.secondary,s.fontsWithFallback.supporting,s.fontSizes.commentsGuidelines,Object(s.spacing)(-2),Object(s.spacing)(6)),m.a.p.withConfig({displayName:"responsive__CommentDisabledGuidelines",componentId:"sc-2j1dkf-2"})(["color:",";font-family:",";font-size:","px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],s.colours.functional.secondary,s.fontsWithFallback.supporting,s.fontSizes.commentsGuidelines,Object(s.spacing)(6),Object(s.spacing)(1)),m.a.p.withConfig({displayName:"responsive__CommentDisabledHeadline",componentId:"sc-2j1dkf-3"})(["color:",";font-family:",";font-size:","px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],s.colours.functional.primary,s.fontsWithFallback.headline,s.fontSizes.commentsHeadline,Object(s.spacing)(1),Object(s.spacing)(6));function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,i,r=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var p=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=u(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;const f=(e,t)=>((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const e=(200===n.status?JSON.parse(n.response):{}).spotimCodeB;e&&t(e)}),n.open("GET",e),n.send()})("/api/comments/loginv2?codeA=".concat(encodeURIComponent(e)),t);var g=()=>{if(window.SPOTIM&&window.SPOTIM.startSSO){const e=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),t="".concat(p(e),"_v2");window.SPOTIM.startSSO({callback:f,userId:t})}},b=n(6);class C extends o.Component{constructor(){super(),this.container=null}componentDidMount(){this.initialiseComments()}componentWillUnmount(){this.disposeComments()}initialiseComments(){const e=this.props,t=e.articleId,n=e.isReadOnly,o=e.commentingConfig,i=e.onCommentStart,r=e.onCommentPost,a=e.onCommentNotification,c=e.onCommentFilterNewest,m=e.onCommentFilterMostRecommended,s=e.onCommentFilterOldest,l=e.onCommentReplyClick,u=e.onCommentShareLink,d=e.onCommentShareTwitter,p=e.onCommentShareEmail,f=e.onCommentShareFacebook,b=e.onCommentRecommend,C=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,v=e.onCommentSettingsClicked,h=e.domainSpecificUrl;if(!this.container||!t||!o)return;document.addEventListener("spot-im-current-user-typing-start",i),document.addEventListener("spot-im-current-user-sent-message",r),document.addEventListener("spot-im-notification-drop-down-link",a),document.addEventListener("spot-im-user-up-vote-click",b),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return m(e);case"oldest":return s(e);case"newest":return c(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",l),document.addEventListener("spot-im-clicked-settings",v),document.addEventListener("spot-im-user-notifications-click",C),document.addEventListener("spot-im-open-user-profile",y),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return u(e);case"email":return p(e);case"twitter":return d(e);case"facebook":return f(e);default:return null}})(e)),n||(window.SPOTIM&&window.SPOTIM.startSSO?g():document.addEventListener("spot-im-api-ready",()=>{g()})),document.addEventListener("spot-im-renew-sso",()=>{g()});const w=document.createElement("script");w.setAttribute("async","async"),w.setAttribute("src","https://launcher.spot.im/spot/".concat(o.account)),w.setAttribute("data-spotim-module","spotim-launcher"),w.setAttribute("data-post-id",t),w.setAttribute("data-post-url","".concat(h,"/article/").concat(t)),w.setAttribute("data-seo-enabled",!0),w.setAttribute("data-livefyre-url",t),this.container.appendChild(w)}disposeComments(){this.container&&(this.container.innerHTML="")}render(){const e=this.props,t=e.onCommentStart,n=e.onCommentPost,o=e.onCommentNotification,r=e.onCommentFilterNewest,a=e.onCommentFilterMostRecommended,c=e.onCommentFilterOldest,m=e.onCommentReplyClick,s=e.onCommentShareLink,u=e.onCommentShareTwitter,d=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,b=e.onCommentUsernameClicked,C=e.onCommentSettingsClicked;return i.a.createElement(l,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:m,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:c,onCommentShareLink:s,onCommentShareTwitter:u,onCommentShareEmail:d,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:b,onCommentSettingsClicked:C},i.a.createElement("div",{ref:e=>{this.container=e}}))}}C.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var y,v=(y=C,Object(b.withTrackEvents)(y,{analyticsEvents:[{actionName:"navigation",eventName:"onCommentStart",trackingName:"spot im : comment : start"},{actionName:"navigation",eventName:"onCommentPost",trackingName:"spot im : comment : complete"},{actionName:"navigation",eventName:"onCommentNotification",trackingName:"spot im : notification"},{actionName:"navigation",eventName:"onCommentFilterNewest",trackingName:"spot im : sort : newest"},{actionName:"navigation",eventName:"onCommentFilterMostRecommended",trackingName:"spot im : sort : best"},{actionName:"navigation",eventName:"onCommentFilterOldest",trackingName:"spot im : sort : oldest"},{actionName:"navigation",eventName:"onCommentReplyClick",trackingName:"spot im : reply"},{actionName:"navigation",eventName:"onCommentSettingsClicked",trackingName:"spot im : settings button clicked"},{actionName:"navigation",eventName:"onCommentShareLink",trackingName:"spot im : comment : share : copy link"},{actionName:"navigation",eventName:"onCommentShareEmail",trackingName:"spot im : comment : share : email"},{actionName:"navigation",eventName:"onCommentShareTwitter",trackingName:"spot im : comment : share : twitter"},{actionName:"navigation",eventName:"onCommentShareFacebook",trackingName:"spot im : comment : share : facebook"},{actionName:"navigation",eventName:"onCommentRecommend",trackingName:"spot im : vote up"},{actionName:"navigation",eventName:"onCommentUsernameClicked",trackingName:"spot im : username clicked"},{actionName:"navigation",eventName:"onCommentNotificationClicked",trackingName:"spot im : notification clicked"}]}));n(7);function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O={button:{marginBottom:Object(s.spacing)(0),marginTop:Object(s.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:s.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(s.spacing)(10),width:"100%"},headline:w(w({color:s.colours.functional.primary},Object(s.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(s.spacing)(2),paddingTop:Object(s.spacing)(6),textAlign:"center"}),link:{color:s.colours.functional.action},supporting:w(w({},Object(s.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:s.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}N(N({},O),{},{link:N(N({},O.link),{},{fontFamily:s.fontsWithFallback.supporting,fontSize:s.fontSizes.commentsGuidelines})});var E=n(5);var P=e=>{let t=e.storefrontConfig;const n=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,o=n?null:t,r=n?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(E.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:o,onClick:r},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")};const x=e=>{let t=e.userEntitlementsList,n=e.children;const o=t&&t.user&&t.user.subscriptions&&t.user.subscriptions[0]&&t.user.subscriptions[0].featureDecisions||[],i=o&&o.some(e=>"fp-752"===e.code&&e.outcome.toLowerCase().includes("disable"));return void 0===t?null:i&&n};function F(e,t,n,o,i,r,a){try{var c=e[r](a),m=c.value}catch(e){return void n(e)}c.done?t(m):Promise.resolve(m).then(o,i)}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,i,r=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return L(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return L(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}const T=e=>{let t=e.articleId,n=(e.isEnabled,e.isReadOnly),r=e.commentingConfig,c=(e.isCommentEnabled,e.storefrontConfig),m=e.domainSpecificUrl;const s=window&&window.sessionStorage&&window.sessionStorage.getItem("entitlementFeatureEnable");console.log("entitlementFeatureEnable",s);const l=I(Object(o.useState)(void 0),2),u=l[0],d=l[1];return Object(o.useEffect)(()=>{const e=function(){var e,t=(e=function*(){const e=yield fetch("/api/get-user-entitlements"),t=yield e.json();d(t)},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){F(r,o,i,a,c,"next",e)}function c(e){F(r,o,i,a,c,"throw",e)}a(void 0)}))});return function(){return t.apply(this,arguments)}}();window&&s&&(console.log("window object acessible............"),e())},[]),i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.showJoinTheConversationDialog},i.a.createElement(P,{storefrontConfig:c})),s?i.a.createElement(x,{userEntitlementsList:u},i.a.createElement("p",null,"inside UserEntitlements"),i.a.createElement(v,{articleId:t,isReadOnly:n,commentingConfig:r,domainSpecificUrl:m})):i.a.createElement(a.a,{state:a.a.showCommentingModule},i.a.createElement("p",null,"inside UserState provider"),i.a.createElement(v,{articleId:t,isReadOnly:n,commentingConfig:r,domainSpecificUrl:m})))};T.defaultProps={isReadOnly:!1,isCommentEnabled:!0};t.default=T}]);
|