@times-components/article-comments 0.29.0 → 0.30.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.30.1](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.30.0...@times-components/article-comments@0.30.1) (2022-09-01)
7
+
8
+ **Note:** Version bump only for package @times-components/article-comments
9
+
10
+
11
+
12
+
13
+
14
+ # [0.30.0](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.29.1...@times-components/article-comments@0.30.0) (2022-08-25)
15
+
16
+
17
+ ### Features
18
+
19
+ * **TDP-2203:** Reauthenticate users to real name commenting ([2f0f215](https://github.com/newsuk/times-components/commit/2f0f21517edeef9f469eb3690b5c2b915966c29e))
20
+
21
+
22
+
23
+
24
+
25
+ ## [0.29.1](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.29.0...@times-components/article-comments@0.29.1) (2022-08-20)
26
+
27
+ **Note:** Version bump only for package @times-components/article-comments
28
+
29
+
30
+
31
+
32
+
6
33
  # [0.29.0](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.28.1...@times-components/article-comments@0.29.0) (2022-08-18)
7
34
 
8
35
 
@@ -23,6 +23,7 @@ var _joinTheConversationDialog = _interopRequireDefault(require("./join-the-conv
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
26
+ /* eslint-env browser */
26
27
  const ArticleComments = _ref => {
27
28
  let articleId = _ref.articleId,
28
29
  publishedTime = _ref.publishedTime,
@@ -26,10 +26,19 @@ const ssoCallback = (codeA, completeSSOCallback) => loginRequest("/api/comments/
26
26
 
27
27
  exports.ssoCallback = ssoCallback;
28
28
 
29
+ const setNewUserToken = () => {
30
+ window.localStorage.setItem("isUsingRealNameCommenting", true);
31
+ };
32
+
29
33
  const executeSSOtransaction = callback => {
30
34
  if (window.SPOTIM && window.SPOTIM.startSSO) {
31
35
  window.SPOTIM.startSSO(ssoCallback);
32
36
  callback();
37
+ const isFeatureFlagEnabled = window.location.search.includes("enableRealNameCommenting");
38
+
39
+ if (isFeatureFlagEnabled) {
40
+ setNewUserToken();
41
+ }
33
42
  }
34
43
  };
35
44
 
package/dist/comments.js CHANGED
@@ -149,6 +149,10 @@ class Comments extends _react.Component {
149
149
  (0, _commentLogin.default)(() => {});
150
150
  } else {
151
151
  document.addEventListener("spot-im-api-ready", () => {
152
+ if (isFeatureFlagEnabled) {
153
+ (0, _utils.shouldReauthenticateUser)();
154
+ }
155
+
152
156
  (0, _commentLogin.default)(() => {});
153
157
  });
154
158
  }
package/dist/utils.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.getDisplayNameFromLocalStorage = exports.userShouldUpdateName = void 0;
6
+ exports.default = exports.getDisplayNameFromLocalStorage = exports.shouldReauthenticateUser = exports.userShouldUpdateName = void 0;
7
7
 
8
8
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
9
 
@@ -42,6 +42,18 @@ const userShouldUpdateName = /*#__PURE__*/function () {
42
42
 
43
43
  exports.userShouldUpdateName = userShouldUpdateName;
44
44
 
45
+ const shouldReauthenticateUser = () => {
46
+ const isUsingRealNameCommenting = window.localStorage.getItem("isUsingRealNameCommenting");
47
+ if (isUsingRealNameCommenting) return;
48
+ window.localStorage.removeItem("SPOTIM_DEVICE_V2");
49
+ window.localStorage.removeItem("SPOTIM_CURRENT_USER");
50
+ window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN");
51
+ window.localStorage.removeItem("SPOT_AB");
52
+ window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2");
53
+ };
54
+
55
+ exports.shouldReauthenticateUser = shouldReauthenticateUser;
56
+
45
57
  const getDisplayNameFromLocalStorage = () => {
46
58
  const spotimUserDetails = window.localStorage.getItem("SPOTIM_CURRENT_USER");
47
59
  if (!spotimUserDetails) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@times-components/article-comments",
3
- "version": "0.29.0",
3
+ "version": "0.30.1",
4
4
  "description": "Article Comments",
5
5
  "main": "dist/article-comments",
6
6
  "dev": "src/article-comments",
@@ -32,8 +32,8 @@
32
32
  "homepage": "https://github.com/newsuk/times-components#readme",
33
33
  "dependencies": {
34
34
  "@times-components/link": "3.11.0",
35
- "@times-components/tracking": "2.12.0",
36
- "@times-components/ts-components": "1.52.0",
35
+ "@times-components/tracking": "2.12.1",
36
+ "@times-components/ts-components": "1.52.2",
37
37
  "@times-components/ts-styleguide": "1.37.0",
38
38
  "@times-components/user-state": "0.4.0",
39
39
  "prop-types": "15.7.2",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "fe2f12b7448a88662c53f840772282cd97756c5c"
71
+ "gitHead": "2f60d14323cb512be25187a509d33ab3693d63a1"
72
72
  }
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("@times-components/ts-components/rnw")},function(e,t){e.exports=require("prop-types")},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(5),n(2)),a=n.n(r),m=n(4),c=n(3),s=n.n(c),l=n(0);const u=s.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%;}"],l.breakpoints.medium,l.breakpoints.wide),d=(s.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:",";"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(-2),Object(l.spacing)(6)),s.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;"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(6),Object(l.spacing)(1))),p=s.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;"],l.colours.functional.primary,l.fonts.headline,l.fontSizes.commentsHeadline,Object(l.spacing)(1),Object(l.spacing)(6)),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=e=>{window.SPOTIM&&window.SPOTIM.startSSO&&(window.SPOTIM.startSSO(f),e())},C=n(6);function b(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}const h={gb:"https://thetimes.co.uk/subscribe/digital?ILC=GB-TNL_The_Times-Conversion_Page-Homepage-2020",ie:"https://store.thetimes.ie/?ILC=IE-TNL_The_Times-Conversion_Page-Homepage-2020",global:"https://globalstore.thetimes.co.uk/?ILC=INTL-TNL_The_Times-Conversion_Page-Homepage-2020"},v=function(){var e,t=(e=function*(e){if(!e)return!1;const t="/api/comments/display-names-pseudonyms?username=".concat(e),n=fetch(t).then(e=>e.json()).then(e=>e),o=(yield n).isPseudonym;return o||!1},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){b(r,o,i,a,m,"next",e)}function m(e){b(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}();function y(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}class w 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.publishedTime,i=e.commentingConfig,r=e.onCommentStart,a=e.onCommentPost,m=e.onCommentNotification,c=e.onCommentFilterNewest,s=e.onCommentFilterMostRecommended,l=e.onCommentFilterOldest,u=e.onCommentReplyClick,d=e.onCommentShareLink,p=e.onCommentShareTwitter,f=e.onCommentShareEmail,C=e.onCommentShareFacebook,b=e.onCommentRecommend,h=e.onCommentNotificationClicked,w=e.onCommentUsernameClicked,k=e.onCommentSettingsClicked;if(!this.container||!t||!i)return;let O=i.account.readOnly;if(i&&i.switchOver){o>i.switchOver&&(O=i.account.current)}const N=window.location.search.includes("enableRealNameCommenting");document.addEventListener("spot-im-current-user-typing-start",function(){var e,t=(e=function*(e){if(r(e),N){const e=(()=>{const e=window.localStorage.getItem("SPOTIM_CURRENT_USER");return e&&(e&&JSON.parse(e)).data.displayName||!1})();if(!e)return;(yield v(e))&&window.dispatchEvent(new CustomEvent("SHOW_REAL_NAME_COMMENTING_BANNER",{}))}},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){y(r,o,i,a,m,"next",e)}function m(e){y(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}(),{once:!0}),document.addEventListener("spot-im-current-user-sent-message",a),document.addEventListener("spot-im-notification-drop-down-link",m),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 s(e);case"oldest":return l(e);case"newest":return c(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",u),document.addEventListener("spot-im-clicked-settings",k),document.addEventListener("spot-im-user-notifications-click",h),document.addEventListener("spot-im-open-user-profile",w),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return d(e);case"email":return f(e);case"twitter":return p(e);case"facebook":return C(e);default:return null}})(e)),n||(window.SPOTIM&&window.SPOTIM.startSSO?g(()=>{}):document.addEventListener("spot-im-api-ready",()=>{g(()=>{})}));const S=document.createElement("script");S.setAttribute("async","async"),S.setAttribute("src","https://launcher.spot.im/spot/".concat(O)),S.setAttribute("data-spotim-module","spotim-launcher"),S.setAttribute("data-post-id",t),S.setAttribute("data-post-url","https://www.thetimes.co.uk/article/".concat(t)),S.setAttribute("data-seo-enabled",!0),S.setAttribute("data-livefyre-url",t),this.container.appendChild(S)}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,m=e.onCommentFilterOldest,c=e.onCommentReplyClick,s=e.onCommentShareLink,l=e.onCommentShareTwitter,d=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(u,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:l,onCommentShareEmail:d,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}w.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var k,O=(k=w,Object(C.withTrackEvents)(k,{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=n(7);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 E(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}var P={button:{marginBottom:Object(l.spacing)(0),marginTop:Object(l.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:l.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(l.spacing)(10),width:"100%"},headline:E(E({color:l.colours.functional.primary},Object(l.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(l.spacing)(2),paddingTop:Object(l.spacing)(6),textAlign:"center"}),link:{color:l.colours.functional.action},supporting:E(E({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function T(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 x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){L(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function L(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=x(x({},P),{},{link:x(x({},P.link),{},{fontFamily:l.fonts.supporting,fontSize:l.fontSizes.commentsGuidelines})});var R=()=>i.a.createElement(u,null,i.a.createElement(p,null,"Comments for this article have been turned off"),i.a.createElement(d,null,"Comments are subject to our community guidelines, which can be viewed"," ",i.a.createElement(N.TextLink,{style:_.link,url:"https://www.thetimes.co.uk/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),"."));function F(){const e=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,t=e?null:(()=>{const e="undefined"!=typeof window&&window.nuk&&window.nuk.region;return h[e]||h.gb})(),n=e?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(m.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:t,onClick:n},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")}const I=e=>{let t=e.articleId,n=e.publishedTime,o=e.isEnabled,r=e.isReadOnly,c=e.commentingConfig;return o?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.metered},i.a.createElement(F,null)),i.a.createElement(a.a,{state:a.a.subscriber},i.a.createElement(u,null,i.a.createElement(m.HiddenDiv,{className:"comment-banner"})),i.a.createElement(O,{articleId:t,publishedTime:n,isReadOnly:r,commentingConfig:c}))):i.a.createElement(R,null)};I.defaultProps={isReadOnly:!1};t.default=I}]);
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("@times-components/ts-components/rnw")},function(e,t){e.exports=require("prop-types")},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(5),n(2)),a=n.n(r),m=n(4),c=n(3),s=n.n(c),l=n(0);const d=s.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%;}"],l.breakpoints.medium,l.breakpoints.wide),u=(s.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:",";"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(-2),Object(l.spacing)(6)),s.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;"],l.colours.functional.secondary,l.fonts.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(6),Object(l.spacing)(1))),p=s.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;"],l.colours.functional.primary,l.fonts.headline,l.fontSizes.commentsHeadline,Object(l.spacing)(1),Object(l.spacing)(6)),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=e=>{if(window.SPOTIM&&window.SPOTIM.startSSO){window.SPOTIM.startSSO(f),e();window.location.search.includes("enableRealNameCommenting")&&window.localStorage.setItem("isUsingRealNameCommenting",!0)}},C=n(6);function b(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}const v={gb:"https://thetimes.co.uk/subscribe/digital?ILC=GB-TNL_The_Times-Conversion_Page-Homepage-2020",ie:"https://store.thetimes.ie/?ILC=IE-TNL_The_Times-Conversion_Page-Homepage-2020",global:"https://globalstore.thetimes.co.uk/?ILC=INTL-TNL_The_Times-Conversion_Page-Homepage-2020"},h=function(){var e,t=(e=function*(e){if(!e)return!1;const t="/api/comments/display-names-pseudonyms?username=".concat(e),n=fetch(t).then(e=>e.json()).then(e=>e),o=(yield n).isPseudonym;return o||!1},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){b(r,o,i,a,m,"next",e)}function m(e){b(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}();function w(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}class y 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.publishedTime,i=e.commentingConfig,r=e.onCommentStart,a=e.onCommentPost,m=e.onCommentNotification,c=e.onCommentFilterNewest,s=e.onCommentFilterMostRecommended,l=e.onCommentFilterOldest,d=e.onCommentReplyClick,u=e.onCommentShareLink,p=e.onCommentShareTwitter,f=e.onCommentShareEmail,C=e.onCommentShareFacebook,b=e.onCommentRecommend,v=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,O=e.onCommentSettingsClicked;if(!this.container||!t||!i)return;let k=i.account.readOnly;if(i&&i.switchOver){o>i.switchOver&&(k=i.account.current)}const N=window.location.search.includes("enableRealNameCommenting");document.addEventListener("spot-im-current-user-typing-start",function(){var e,t=(e=function*(e){if(r(e),N){const e=(()=>{const e=window.localStorage.getItem("SPOTIM_CURRENT_USER");return e&&(e&&JSON.parse(e)).data.displayName||!1})();if(!e)return;(yield h(e))&&window.dispatchEvent(new CustomEvent("SHOW_REAL_NAME_COMMENTING_BANNER",{}))}},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){w(r,o,i,a,m,"next",e)}function m(e){w(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(e){return t.apply(this,arguments)}}(),{once:!0}),document.addEventListener("spot-im-current-user-sent-message",a),document.addEventListener("spot-im-notification-drop-down-link",m),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 s(e);case"oldest":return l(e);case"newest":return c(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",d),document.addEventListener("spot-im-clicked-settings",O),document.addEventListener("spot-im-user-notifications-click",v),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 f(e);case"twitter":return p(e);case"facebook":return C(e);default:return null}})(e)),n||(window.SPOTIM&&window.SPOTIM.startSSO?g(()=>{}):document.addEventListener("spot-im-api-ready",()=>{N&&(window.localStorage.getItem("isUsingRealNameCommenting")||(window.localStorage.removeItem("SPOTIM_DEVICE_V2"),window.localStorage.removeItem("SPOTIM_CURRENT_USER"),window.localStorage.removeItem("SPOTIM_ACCESS_TOKEN"),window.localStorage.removeItem("SPOT_AB"),window.localStorage.removeItem("SPOTIM_DEVICE_UUID_V2"))),g(()=>{})}));const S=document.createElement("script");S.setAttribute("async","async"),S.setAttribute("src","https://launcher.spot.im/spot/".concat(k)),S.setAttribute("data-spotim-module","spotim-launcher"),S.setAttribute("data-post-id",t),S.setAttribute("data-post-url","https://www.thetimes.co.uk/article/".concat(t)),S.setAttribute("data-seo-enabled",!0),S.setAttribute("data-livefyre-url",t),this.container.appendChild(S)}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,m=e.onCommentFilterOldest,c=e.onCommentReplyClick,s=e.onCommentShareLink,l=e.onCommentShareTwitter,u=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(d,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:l,onCommentShareEmail:u,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}y.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var O,k=(O=y,Object(C.withTrackEvents)(O,{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=n(7);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 E(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}var P={button:{marginBottom:Object(l.spacing)(0),marginTop:Object(l.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:l.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(l.spacing)(10),width:"100%"},headline:E(E({color:l.colours.functional.primary},Object(l.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(l.spacing)(2),paddingTop:Object(l.spacing)(6),textAlign:"center"}),link:{color:l.colours.functional.action},supporting:E(E({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function T(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 _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var R=_(_({},P),{},{link:_(_({},P.link),{},{fontFamily:l.fonts.supporting,fontSize:l.fontSizes.commentsGuidelines})});var x=()=>i.a.createElement(d,null,i.a.createElement(p,null,"Comments for this article have been turned off"),i.a.createElement(u,null,"Comments are subject to our community guidelines, which can be viewed"," ",i.a.createElement(N.TextLink,{style:R.link,url:"https://www.thetimes.co.uk/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),"."));function L(){const e=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,t=e?null:(()=>{const e="undefined"!=typeof window&&window.nuk&&window.nuk.region;return v[e]||v.gb})(),n=e?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(m.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:t,onClick:n},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")}const M=e=>{let t=e.articleId,n=e.publishedTime,o=e.isEnabled,r=e.isReadOnly,c=e.commentingConfig;return o?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.metered},i.a.createElement(L,null)),i.a.createElement(a.a,{state:a.a.subscriber},i.a.createElement(d,null,i.a.createElement(m.HiddenDiv,{className:"comment-banner"})),i.a.createElement(k,{articleId:t,publishedTime:n,isReadOnly:r,commentingConfig:c}))):i.a.createElement(x,null)};M.defaultProps={isReadOnly:!1};t.default=M}]);