@times-components/article-comments 0.43.10-alpha.4 → 0.43.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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
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.43.10](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.43.9...@times-components/article-comments@0.43.10) (2024-05-24)
7
+
8
+ **Note:** Version bump only for package @times-components/article-comments
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.43.9](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.43.8...@times-components/article-comments@0.43.9) (2024-05-20)
7
15
 
8
16
  **Note:** Version bump only for package @times-components/article-comments
package/dist/comments.js CHANGED
@@ -97,61 +97,40 @@ class Comments extends _react.Component {
97
97
  }
98
98
  };
99
99
 
100
- const setupEventListeners = () => {
101
- document.addEventListener("spot-im-current-user-typing-start", onCommentStart);
102
- document.addEventListener("spot-im-current-user-sent-message", onCommentPost);
103
- document.addEventListener("spot-im-notification-drop-down-link", onCommentNotification);
104
- document.addEventListener("spot-im-user-up-vote-click", onCommentRecommend);
105
- document.addEventListener("spot-im-sort-by-select", event => getFilterEvent(event));
106
- document.addEventListener("spot-im-user-clicked-reply", onCommentReplyClick);
107
- document.addEventListener("spot-im-clicked-settings", onCommentSettingsClicked);
108
- document.addEventListener("spot-im-user-notifications-click", onCommentNotificationClicked);
109
- document.addEventListener("spot-im-open-user-profile", onCommentUsernameClicked);
110
- document.addEventListener("spot-im-share-type", event => getShareEvent(event));
111
- };
112
-
113
- const setupSSO = () => {
114
- if (!isReadOnly) {
115
- if (window.SPOTIM && window.SPOTIM.startSSO) {
116
- (0, _commentLogin.default)();
117
- } else {
118
- document.addEventListener("spot-im-api-ready", () => {
119
- (0, _commentLogin.default)();
120
- });
121
- }
122
- } // In case of token expiration we need to renew sso
123
-
124
-
125
- document.addEventListener("spot-im-renew-sso", () => {
100
+ document.addEventListener("spot-im-current-user-typing-start", onCommentStart);
101
+ document.addEventListener("spot-im-current-user-sent-message", onCommentPost);
102
+ document.addEventListener("spot-im-notification-drop-down-link", onCommentNotification);
103
+ document.addEventListener("spot-im-user-up-vote-click", onCommentRecommend);
104
+ document.addEventListener("spot-im-sort-by-select", event => getFilterEvent(event));
105
+ document.addEventListener("spot-im-user-clicked-reply", onCommentReplyClick);
106
+ document.addEventListener("spot-im-clicked-settings", onCommentSettingsClicked);
107
+ document.addEventListener("spot-im-user-notifications-click", onCommentNotificationClicked);
108
+ document.addEventListener("spot-im-open-user-profile", onCommentUsernameClicked);
109
+ document.addEventListener("spot-im-share-type", event => getShareEvent(event));
110
+
111
+ if (!isReadOnly) {
112
+ if (window.SPOTIM && window.SPOTIM.startSSO) {
126
113
  (0, _commentLogin.default)();
127
- });
128
- };
129
-
130
- const appendLauncherScript = () => {
131
- const launcherScript = document.createElement("script");
132
- launcherScript.setAttribute("defer", "defer");
133
- launcherScript.setAttribute("src", "https://launcher.spot.im/spot/".concat(commentingConfig.account));
134
- launcherScript.setAttribute("data-spotim-module", "spotim-launcher");
135
- launcherScript.setAttribute("data-post-id", articleId);
136
- launcherScript.setAttribute("data-post-url", "".concat(domainSpecificUrl, "/article/").concat(articleId));
137
- launcherScript.setAttribute("data-seo-enabled", true);
138
- launcherScript.setAttribute("data-livefyre-url", articleId);
139
- this.container.appendChild(launcherScript); // Ensure script is loaded
140
-
141
- launcherScript.onload = () => {
142
- console.log("SpotIM script loaded successfully");
143
- setupEventListeners();
144
- setupSSO();
145
- };
146
-
147
- launcherScript.onerror = () => {
148
- console.error("Failed to load SpotIM script");
149
- };
150
- }; // Ensure the container is empty before appending
151
-
152
-
153
- this.container.innerHTML = "";
154
- appendLauncherScript();
114
+ } else {
115
+ document.addEventListener("spot-im-api-ready", () => {
116
+ (0, _commentLogin.default)();
117
+ });
118
+ }
119
+ } // In case of token expiration we need to renew sso
120
+
121
+
122
+ document.addEventListener("spot-im-renew-sso", () => {
123
+ (0, _commentLogin.default)();
124
+ });
125
+ const launcherScript = document.createElement("script");
126
+ launcherScript.setAttribute("async", "async");
127
+ launcherScript.setAttribute("src", "https://launcher.spot.im/spot/".concat(commentingConfig.account));
128
+ launcherScript.setAttribute("data-spotim-module", "spotim-launcher");
129
+ launcherScript.setAttribute("data-post-id", articleId);
130
+ launcherScript.setAttribute("data-post-url", "".concat(domainSpecificUrl, "/article/").concat(articleId));
131
+ launcherScript.setAttribute("data-seo-enabled", true);
132
+ launcherScript.setAttribute("data-livefyre-url", articleId);
133
+ this.container.appendChild(launcherScript);
155
134
  }
156
135
 
157
136
  disposeComments() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@times-components/article-comments",
3
- "version": "0.43.10-alpha.4+181d6e7d4d",
3
+ "version": "0.43.10",
4
4
  "description": "Article Comments",
5
5
  "main": "dist/article-comments",
6
6
  "dev": "src/article-comments",
@@ -33,11 +33,11 @@
33
33
  },
34
34
  "homepage": "https://github.com/newsuk/times-components#readme",
35
35
  "dependencies": {
36
- "@times-components/link": "^3.17.18",
37
- "@times-components/tracking": "^2.22.18",
38
- "@times-components/ts-components": "^1.85.2",
39
- "@times-components/ts-styleguide": "^1.50.18",
40
- "@times-components/user-state": "^0.5.35",
36
+ "@times-components/link": "3.17.19",
37
+ "@times-components/tracking": "2.22.19",
38
+ "@times-components/ts-components": "1.85.3",
39
+ "@times-components/ts-styleguide": "1.50.19",
40
+ "@times-components/user-state": "0.5.36",
41
41
  "prop-types": "15.7.2",
42
42
  "styled-components": "4.3.2"
43
43
  },
@@ -45,10 +45,10 @@
45
45
  "@babel/core": "7.4.4",
46
46
  "@testing-library/jest-dom": "^5.12.0",
47
47
  "@testing-library/react": "^12.1.2",
48
- "@times-components/eslint-config-thetimes": "^0.8.18",
49
- "@times-components/jest-configurator-web": "^0.8.2",
50
- "@times-components/storybook": "^4.12.18",
51
- "@times-components/webpack-configurator": "^2.1.1",
48
+ "@times-components/eslint-config-thetimes": "0.8.18",
49
+ "@times-components/jest-configurator-web": "0.8.2",
50
+ "@times-components/storybook": "4.12.19",
51
+ "@times-components/webpack-configurator": "2.1.1",
52
52
  "babel-jest": "24.8.0",
53
53
  "eslint": "5.9.0",
54
54
  "jest": "24.8.0",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "181d6e7d4d1b92d72451cf9e7d4b8f95df87d397"
73
+ "gitHead": "ccc9508ef4a9e37cc23a75c9f73eebd3f79c489d"
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/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t){e.exports=require("@times-components/ts-components/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),m=n(3),c=n.n(m),s=n(0);const l=c.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),d=(c.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)),c.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))),u=c.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 p(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,m=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){m=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(m)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return f(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 f(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 f(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 g=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=p(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;const C=(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 b=()=>{if(window.SPOTIM&&window.SPOTIM.startSSO){const e=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),t="".concat(g(e),"_v2");window.SPOTIM.startSSO({callback:C,userId:t})}},y=n(5);class v 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,m=e.onCommentFilterNewest,c=e.onCommentFilterMostRecommended,s=e.onCommentFilterOldest,l=e.onCommentReplyClick,d=e.onCommentShareLink,u=e.onCommentShareTwitter,p=e.onCommentShareEmail,f=e.onCommentShareFacebook,g=e.onCommentRecommend,C=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,v=e.onCommentSettingsClicked,h=e.domainSpecificUrl;if(!this.container||!t||!o)return;const k=()=>{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",g),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return c(e);case"oldest":return s(e);case"newest":return m(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 d(e);case"email":return p(e);case"twitter":return u(e);case"facebook":return f(e);default:return null}})(e))};this.container.innerHTML="",(()=>{const e=document.createElement("script");e.setAttribute("defer","defer"),e.setAttribute("src","https://launcher.spot.im/spot/".concat(o.account)),e.setAttribute("data-spotim-module","spotim-launcher"),e.setAttribute("data-post-id",t),e.setAttribute("data-post-url","".concat(h,"/article/").concat(t)),e.setAttribute("data-seo-enabled",!0),e.setAttribute("data-livefyre-url",t),this.container.appendChild(e),e.onload=()=>{console.log("SpotIM script loaded successfully"),k(),n||(window.SPOTIM&&window.SPOTIM.startSSO?b():document.addEventListener("spot-im-api-ready",()=>{b()})),document.addEventListener("spot-im-renew-sso",()=>{b()})},e.onerror=()=>{console.error("Failed to load SpotIM script")}})()}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,d=e.onCommentShareTwitter,u=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(l,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:d,onCommentShareEmail:u,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}v.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var h,k=(h=v,Object(y.withTrackEvents)(h,{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"}]})),w=n(6);function O(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 S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(Object(n),!0).forEach((function(t){N(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j={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:S(S({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:S(S({},Object(s.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:s.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function E(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 P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=P(P({},j),{},{link:P(P({},j.link),{},{fontFamily:s.fontsWithFallback.supporting,fontSize:s.fontSizes.commentsGuidelines})});var T=()=>i.a.createElement(l,null,i.a.createElement(u,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(w.TextLink,{style:F.link,url:"/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),".")),L=n(7);var M=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(L.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 I=e=>{let t=e.articleId,n=e.isEnabled,o=e.isReadOnly,r=e.commentingConfig,m=e.isCommentEnabled,c=e.storefrontConfig,s=e.domainSpecificUrl;return n&&m?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.showJoinTheConversationDialog},i.a.createElement(M,{storefrontConfig:c})),i.a.createElement(a.a,{state:a.a.showCommentingModule},i.a.createElement(k,{articleId:t,isReadOnly:o,commentingConfig:r,domainSpecificUrl:s}))):i.a.createElement(T,null)};I.defaultProps={isReadOnly:!1,isCommentEnabled:!0};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("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){e.exports=require("@times-components/ts-components/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),m=n(3),c=n.n(m),s=n(0);const l=c.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),d=(c.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)),c.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))),u=c.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 p(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,m=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){m=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(m)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return f(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 f(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 f(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 g=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=p(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;const C=(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 b=()=>{if(window.SPOTIM&&window.SPOTIM.startSSO){const e=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),t="".concat(g(e),"_v2");window.SPOTIM.startSSO({callback:C,userId:t})}},y=n(5);class v 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,m=e.onCommentFilterNewest,c=e.onCommentFilterMostRecommended,s=e.onCommentFilterOldest,l=e.onCommentReplyClick,d=e.onCommentShareLink,u=e.onCommentShareTwitter,p=e.onCommentShareEmail,f=e.onCommentShareFacebook,g=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",g),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return c(e);case"oldest":return s(e);case"newest":return m(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 d(e);case"email":return p(e);case"twitter":return u(e);case"facebook":return f(e);default:return null}})(e)),n||(window.SPOTIM&&window.SPOTIM.startSSO?b():document.addEventListener("spot-im-api-ready",()=>{b()})),document.addEventListener("spot-im-renew-sso",()=>{b()});const k=document.createElement("script");k.setAttribute("async","async"),k.setAttribute("src","https://launcher.spot.im/spot/".concat(o.account)),k.setAttribute("data-spotim-module","spotim-launcher"),k.setAttribute("data-post-id",t),k.setAttribute("data-post-url","".concat(h,"/article/").concat(t)),k.setAttribute("data-seo-enabled",!0),k.setAttribute("data-livefyre-url",t),this.container.appendChild(k)}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,d=e.onCommentShareTwitter,u=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(l,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:d,onCommentShareEmail:u,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}v.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var h,k=(h=v,Object(y.withTrackEvents)(h,{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"}]})),w=n(6);function O(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 S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(Object(n),!0).forEach((function(t){N(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j={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:S(S({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:S(S({},Object(s.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:s.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function E(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 P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=P(P({},j),{},{link:P(P({},j.link),{},{fontFamily:s.fontsWithFallback.supporting,fontSize:s.fontSizes.commentsGuidelines})});var T=()=>i.a.createElement(l,null,i.a.createElement(u,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(w.TextLink,{style:F.link,url:"/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),".")),L=n(7);var R=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(L.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 I=e=>{let t=e.articleId,n=e.isEnabled,o=e.isReadOnly,r=e.commentingConfig,m=e.isCommentEnabled,c=e.storefrontConfig,s=e.domainSpecificUrl;return n&&m?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.showJoinTheConversationDialog},i.a.createElement(R,{storefrontConfig:c})),i.a.createElement(a.a,{state:a.a.showCommentingModule},i.a.createElement(k,{articleId:t,isReadOnly:o,commentingConfig:r,domainSpecificUrl:s}))):i.a.createElement(T,null)};I.defaultProps={isReadOnly:!1,isCommentEnabled:!0};t.default=I}]);