@kompasid/lit-web-components 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.editorconfig +29 -0
  2. package/.github/workflows/npm-publish.yml +35 -0
  3. package/LICENSE +21 -0
  4. package/README.md +62 -0
  5. package/assets/font-awesome.ts +21 -0
  6. package/components.d.ts +4 -0
  7. package/demo/index.html +137 -0
  8. package/dist/assets/font-awesome.d.ts +2 -0
  9. package/dist/assets/font-awesome.js +20 -0
  10. package/dist/assets/font-awesome.js.map +1 -0
  11. package/dist/src/components/kompas-footer/KompasFooter.d.ts +13 -0
  12. package/dist/src/components/kompas-footer/KompasFooter.js +304 -0
  13. package/dist/src/components/kompas-footer/KompasFooter.js.map +1 -0
  14. package/dist/src/components/kompas-footer/types.d.ts +47 -0
  15. package/dist/src/components/kompas-footer/types.js +2 -0
  16. package/dist/src/components/kompas-footer/types.js.map +1 -0
  17. package/dist/src/components/kompas-metered-paywall/KompasMeteredPaywall.d.ts +50 -0
  18. package/dist/src/components/kompas-metered-paywall/KompasMeteredPaywall.js +225 -0
  19. package/dist/src/components/kompas-metered-paywall/KompasMeteredPaywall.js.map +1 -0
  20. package/dist/src/components/kompas-paywall/KompasPaywall.d.ts +73 -0
  21. package/dist/src/components/kompas-paywall/KompasPaywall.js +470 -0
  22. package/dist/src/components/kompas-paywall/KompasPaywall.js.map +1 -0
  23. package/dist/src/components/kompas-paywall/types.d.ts +53 -0
  24. package/dist/src/components/kompas-paywall/types.js +2 -0
  25. package/dist/src/components/kompas-paywall/types.js.map +1 -0
  26. package/dist/src/components/kompas-paywall-banner-registration/KompasPaywallBannerRegistration.d.ts +11 -0
  27. package/dist/src/components/kompas-paywall-banner-registration/KompasPaywallBannerRegistration.js +100 -0
  28. package/dist/src/components/kompas-paywall-banner-registration/KompasPaywallBannerRegistration.js.map +1 -0
  29. package/dist/src/components/kompas-paywall-body/KompasPaywallBody.d.ts +107 -0
  30. package/dist/src/components/kompas-paywall-body/KompasPaywallBody.js +843 -0
  31. package/dist/src/components/kompas-paywall-body/KompasPaywallBody.js.map +1 -0
  32. package/dist/src/components/kompas-paywall-information-header/KompasPaywallInformationHeader.d.ts +8 -0
  33. package/dist/src/components/kompas-paywall-information-header/KompasPaywallInformationHeader.js +39 -0
  34. package/dist/src/components/kompas-paywall-information-header/KompasPaywallInformationHeader.js.map +1 -0
  35. package/dist/src/components/kompas-paywall-video/KompasPaywallVideo.d.ts +53 -0
  36. package/dist/src/components/kompas-paywall-video/KompasPaywallVideo.js +245 -0
  37. package/dist/src/components/kompas-paywall-video/KompasPaywallVideo.js.map +1 -0
  38. package/dist/src/index.d.ts +10 -0
  39. package/dist/src/index.js +5 -0
  40. package/dist/src/index.js.map +1 -0
  41. package/dist/src/utils/deviceType.d.ts +2 -0
  42. package/dist/src/utils/deviceType.js +11 -0
  43. package/dist/src/utils/deviceType.js.map +1 -0
  44. package/dist/src/utils/fontawesome-setup.d.ts +1 -0
  45. package/dist/src/utils/fontawesome-setup.js +25 -0
  46. package/dist/src/utils/fontawesome-setup.js.map +1 -0
  47. package/dist/tailwind/tailwind.d.ts +1 -0
  48. package/dist/tailwind/tailwind.js +1654 -0
  49. package/dist/tailwind/tailwind.js.map +1 -0
  50. package/dist/tsconfig.tsbuildinfo +1 -0
  51. package/package.json +94 -0
  52. package/src/components/kompas-footer/KompasFooter.ts +331 -0
  53. package/src/components/kompas-footer/types.ts +54 -0
  54. package/src/components/kompas-metered-paywall/KompasMeteredPaywall.ts +174 -0
  55. package/src/components/kompas-metered-paywall/readme.md +32 -0
  56. package/src/components/kompas-paywall/KompasPaywall.ts +398 -0
  57. package/src/components/kompas-paywall/readme.md +166 -0
  58. package/src/components/kompas-paywall/types.ts +53 -0
  59. package/src/components/kompas-paywall-banner-registration/KompasPaywallBannerRegistration.ts +92 -0
  60. package/src/components/kompas-paywall-banner-registration/readme.md +31 -0
  61. package/src/components/kompas-paywall-body/KompasPaywallBody.ts +844 -0
  62. package/src/components/kompas-paywall-body/readme.md +54 -0
  63. package/src/components/kompas-paywall-information-header/KompasPaywallInformationHeader.ts +29 -0
  64. package/src/components/kompas-paywall-information-header/readme.md +30 -0
  65. package/src/components/kompas-paywall-video/KompasPaywallVideo.ts +194 -0
  66. package/src/components/kompas-paywall-video/readme.md +46 -0
  67. package/src/index.ts +11 -0
  68. package/src/utils/deviceType.ts +11 -0
  69. package/src/utils/fontawesome-setup.ts +40 -0
  70. package/tailwind/tailwind.css +1635 -0
  71. package/tailwind/tailwind.ts +1654 -0
  72. package/tailwind/tailwindlib.css +3 -0
  73. package/tailwind.config.js +96 -0
  74. package/tsconfig.json +21 -0
  75. package/web-dev-server.config.mjs +27 -0
  76. package/web-test-runner.config.mjs +41 -0
@@ -0,0 +1,843 @@
1
+ /* eslint-disable no-return-assign */
2
+ import { __decorate } from "tslib";
3
+ import { html, css, LitElement } from 'lit';
4
+ import { property, state, customElement } from 'lit/decorators.js';
5
+ import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
6
+ import { TWStyles } from '../../../tailwind/tailwind.js';
7
+ import { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js';
8
+ import { deviceType } from '../../utils/deviceType.js';
9
+ let KompasPaywallBody = class KompasPaywallBody extends LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ /**
13
+ * Props
14
+ */
15
+ /**
16
+ * prop slug untuk menghandle slug
17
+ * prop isLogin untuk menghandle apakah user sudah login atau belum
18
+ * prop type untuk menghandle tipe epaper
19
+ * prop paywallData untuk menghandle data paywall
20
+ * prop userGuid untuk menghandle user Guid
21
+ * prop subscriptionStatus untuk menghandle status subscription user
22
+ * prop countdownArticle untuk menghandle count artikel
23
+ * prop swgEnable untuk menghandle swg apakah di aktifkan atau tidak
24
+ * prop paywall_location = The location where user encounter the paywall
25
+ * prop paywall_subscription_package = The name of the subscription package viewed by user
26
+ * prop paywall_subscription_id = The ID of the subscription package viewed by user
27
+ * prop paywall_subscription_price = The price of the subscriprtion package viewed by user
28
+ * prop paywall_position = The position of the subscription package viewed by user
29
+ * prop tracker_page_type = Type of the page
30
+ * prop tracker_content_id = ID of article (slug)
31
+ * prop tracker_content_type = Whether it's free article or paid article
32
+ * prop tracker_content_title = The title of article
33
+ * prop tracker_content_categories = The category of the content
34
+ * prop tracker_user_type = Type of user based on their subscription
35
+ * prop tracker_subscription_status = Status of their subscription
36
+ * prop tracker_page_domain = Page Domain
37
+ * prop tracker_metered_wall_type = The type of Metered Wall
38
+ * prop tracker_metered_wall_balance = The balance of their metered wall
39
+ * prop tracker_metered_wall_balance = The edition of epaper viewed by user
40
+ * prop theme = The theme of the paywall component
41
+ */
42
+ this.slug = '';
43
+ this.udin = 0;
44
+ this.isLogin = false;
45
+ this.type = 'reguler';
46
+ this.paywallData = undefined;
47
+ this.userGuid = '';
48
+ this.subscriptionStatus = '';
49
+ this.countdownArticle = 0;
50
+ this.swgEnable = false;
51
+ this.paywall_location = '';
52
+ this.paywall_subscription_package = '';
53
+ this.paywall_subscription_id = 0;
54
+ this.paywall_subscription_price = 0;
55
+ this.paywall_position = 0;
56
+ this.tracker_page_type = '';
57
+ this.tracker_content_id = '';
58
+ this.tracker_content_title = '';
59
+ this.tracker_content_categories = '';
60
+ this.tracker_content_type = '';
61
+ this.tracker_user_type = '';
62
+ this.tracker_subscription_status = '';
63
+ this.tracker_page_domain = '';
64
+ this.tracker_metered_wall_type = '';
65
+ this.tracker_metered_wall_balance = 0;
66
+ this.tracker_epaper_edition = '';
67
+ this.theme = '';
68
+ this.isExtensionsOpened = false;
69
+ this.kompasAkunHost = 'https://akun.kompas.id';
70
+ this.kompasApigenHost = 'https://apigen.kompas.id';
71
+ this.kompasApiWcmHost = 'https://apiwcm.kompas.id';
72
+ this.kompasLoginHost = 'https://account.kompas.id/login';
73
+ this.selfHost = 'https://epaper.kompas.id';
74
+ this.swgPublisherName = 'Harian Kompas';
75
+ this.swgPublisherId = 'kompas.id';
76
+ this.swgProductId = 'kompas.id:kompas_digital_premium';
77
+ this.errorFlag = 0;
78
+ this.subscribeWithGoogleButton = () => {
79
+ // @ts-ignore
80
+ // eslint-disable-next-line no-restricted-globals
81
+ ;
82
+ (self.SWG = self.SWG || []).push((subscriptions) => {
83
+ // set entitlement
84
+ subscriptions.setOnEntitlementsResponse(() => {
85
+ // subscriptions attach button
86
+ subscriptions.attachButton(this.buttonElement, { theme: 'light', lang: 'en' }, () => {
87
+ subscriptions.showOffers({ isClosable: true });
88
+ subscriptions.setOnLoginRequest(() => {
89
+ window.location.href = this.redirectToLogin;
90
+ });
91
+ subscriptions.setOnPaymentResponse(async (paymentResponse) => {
92
+ const response = await paymentResponse;
93
+ const raw = JSON.parse(response.purchaseData.raw);
94
+ const { productId, purchaseToken, packageName } = raw;
95
+ const { email } = response.userData.data;
96
+ const payload = {
97
+ subscription_token: purchaseToken,
98
+ products: productId,
99
+ detail: 'test',
100
+ };
101
+ const userToken = await this.getUserToken('google', payload);
102
+ if (userToken) {
103
+ // login and update membership
104
+ const accessToken = await this.getSubscriptionToken('google', {
105
+ token: userToken,
106
+ });
107
+ if (accessToken) {
108
+ const payloadSWG = {
109
+ email,
110
+ package_name: packageName,
111
+ product_id: productId,
112
+ purchase_token: purchaseToken,
113
+ };
114
+ await this.createSwG(payloadSWG, accessToken);
115
+ }
116
+ }
117
+ else {
118
+ // register and login the unknown user
119
+ const payloadRegisterToken = {
120
+ subscription_token: purchaseToken,
121
+ products: productId,
122
+ detail: 'test',
123
+ };
124
+ const token = await this.getRegisterToken('google', payloadRegisterToken);
125
+ if (token) {
126
+ const accessToken = await this.getSubscriptionToken('google', { token });
127
+ const payloadSWRUknown = {
128
+ email,
129
+ package_name: packageName,
130
+ product_id: productId,
131
+ purchase_token: purchaseToken,
132
+ };
133
+ await this.createSwG(payloadSWRUknown, accessToken);
134
+ }
135
+ }
136
+ response.complete().then(() => {
137
+ window.location.href = this.redirectToLogin;
138
+ });
139
+ });
140
+ });
141
+ });
142
+ });
143
+ };
144
+ this.sendDataLayeronPaywallBody = () => {
145
+ const gtmParams = {
146
+ event: 'paywall_viewed',
147
+ impressions: [
148
+ {
149
+ paywall_location: this.paywall_location || '',
150
+ paywall_subscription_package: 'Cash-B2C-Halaman Berlangganan-Reguler_Digital-KDP 12',
151
+ paywall_subscription_id: '9802032',
152
+ paywall_subscription_price: 360000,
153
+ paywall_position: 1,
154
+ user_type: this.tracker_user_type,
155
+ subscription_status: this.tracker_subscription_status,
156
+ page_domain: this.tracker_page_domain || 'Kompas.id',
157
+ metered_wall_type: this.tracker_metered_wall_type || 'HP',
158
+ metered_wall_balance: this.tracker_metered_wall_balance,
159
+ },
160
+ {
161
+ paywall_location: this.paywall_location || '',
162
+ paywall_subscription_package: 'Cash-B2C-Halaman Berlangganan-Reguler_Digital-KDP 1',
163
+ paywall_subscription_id: '9802035',
164
+ paywall_subscription_price: 50000,
165
+ paywall_position: 2,
166
+ user_type: this.tracker_user_type,
167
+ subscription_status: this.tracker_subscription_status,
168
+ page_domain: this.tracker_page_domain || 'Kompas.id',
169
+ metered_wall_type: this.tracker_metered_wall_type || 'HP',
170
+ metered_wall_balance: this.tracker_metered_wall_balance,
171
+ },
172
+ ],
173
+ };
174
+ if (this.type === 'epaper') {
175
+ gtmParams.impressions[0].epaper_edition = this.tracker_epaper_edition;
176
+ gtmParams.impressions[1].epaper_edition = this.tracker_epaper_edition;
177
+ }
178
+ else {
179
+ gtmParams.impressions[0].page_type = this.tracker_page_type;
180
+ gtmParams.impressions[0].content_id = this.tracker_content_id;
181
+ gtmParams.impressions[0].content_title = this.tracker_content_title;
182
+ gtmParams.impressions[0].content_categories =
183
+ this.tracker_content_categories;
184
+ gtmParams.impressions[0].content_type = this.tracker_content_type;
185
+ gtmParams.impressions[1].page_type = this.tracker_page_type;
186
+ gtmParams.impressions[1].content_id = this.tracker_content_id;
187
+ gtmParams.impressions[1].content_title = this.tracker_content_title;
188
+ gtmParams.impressions[1].content_categories =
189
+ this.tracker_content_categories;
190
+ gtmParams.impressions[1].content_type = this.tracker_content_type;
191
+ }
192
+ window.dataLayer.push(gtmParams);
193
+ };
194
+ }
195
+ getRupiahFormat(value) {
196
+ const roundedValue = Math.round(value);
197
+ return `Rp ${roundedValue
198
+ .toString()
199
+ .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.')}`;
200
+ }
201
+ redirectToCheckout(url, name, id, price, position) {
202
+ this.sendDataLayeronButtonBuyPackage(name, id, price, position);
203
+ const originHost = encodeURIComponent(window.location.href);
204
+ const directUrlCheckout = url + originHost;
205
+ window.open(directUrlCheckout);
206
+ }
207
+ redirectToPrevUrl() {
208
+ window.history.back();
209
+ }
210
+ redirectToSubscriber() {
211
+ this.sendDataLayer();
212
+ window.open('https://www.kompas.id/berlangganan');
213
+ }
214
+ redirectToRegister() {
215
+ const loginHost = 'https://account.kompas.id/login';
216
+ const nextParams = encodeURIComponent(window.location.href);
217
+ const directUrlRegister = `${loginHost}?next=${nextParams}?status=sukses_login&status_login=login`;
218
+ window.location.href = directUrlRegister;
219
+ }
220
+ redirectToHelpdesk() {
221
+ this.sendDataLayeronHelpDesk();
222
+ window.open('https://api.whatsapp.com/send/?phone=6281290050800&text=Halo,%20saya%20perlu%20informasi%20mengenai%20kompas.id');
223
+ }
224
+ paymentExtensionHandler() {
225
+ this.isExtensionsOpened = !this.isExtensionsOpened;
226
+ }
227
+ get isDark() {
228
+ return this.theme === 'dark';
229
+ }
230
+ get redirectToLogin() {
231
+ return `${this.kompasLoginHost}?next=${encodeURIComponent(this.selfHost + window.location.pathname)}`;
232
+ }
233
+ async getRegisterToken(path, payload) {
234
+ return fetch(`${this.kompasApigenHost}/v1/user/register/token/${path}`, {
235
+ method: 'POST',
236
+ body: JSON.stringify(payload),
237
+ headers: {
238
+ 'content-type': 'application/json',
239
+ },
240
+ })
241
+ .then(response => response.json())
242
+ .then((data) => data.result.token)
243
+ .catch(error => {
244
+ throw error;
245
+ });
246
+ }
247
+ async getUserToken(path, payload) {
248
+ return fetch(`${this.kompasApigenHost}/v1/user/token/${path}`, {
249
+ method: 'POST',
250
+ body: JSON.stringify(payload),
251
+ headers: {
252
+ 'content-type': 'application/json',
253
+ },
254
+ })
255
+ .then(response => response.json())
256
+ .then((data) => data.result.token)
257
+ .catch(error => {
258
+ throw error;
259
+ });
260
+ }
261
+ async getSubscriptionToken(path, payload) {
262
+ return fetch(`${this.kompasAkunHost}/api/subscription/login/${path}`, {
263
+ method: 'POST',
264
+ body: JSON.stringify(payload),
265
+ headers: {
266
+ 'content-type': 'application/json',
267
+ },
268
+ })
269
+ .then(response => response.json())
270
+ .then((data) => {
271
+ this.errorFlag = 0;
272
+ return data.access_token;
273
+ })
274
+ .catch(async (error) => {
275
+ const errorCode = error.response.status;
276
+ if (errorCode === 500 && this.errorFlag < 5) {
277
+ // eslint-disable-next-line no-plusplus
278
+ this.errorFlag++;
279
+ setTimeout(async () => {
280
+ await this.getSubscriptionToken(path, payload);
281
+ }, 2000);
282
+ }
283
+ else {
284
+ this.errorFlag = 0;
285
+ throw error;
286
+ }
287
+ });
288
+ }
289
+ async createSwG(payload, token) {
290
+ await fetch(`${this.kompasApiWcmHost}/v2/membership/swg/create`, {
291
+ method: 'POST',
292
+ body: JSON.stringify(payload),
293
+ headers: {
294
+ 'content-type': 'application/json',
295
+ Authorization: `Bearer ${token}`,
296
+ },
297
+ })
298
+ .then(response => response.json())
299
+ .catch(error => {
300
+ throw error;
301
+ });
302
+ }
303
+ jsonScript() {
304
+ const jsonData = {
305
+ '@context': 'https://schema.org',
306
+ '@type': ['WebSite', 'WebPage'],
307
+ isAccessibleForFree: false,
308
+ url: this.selfHost + window.location.pathname,
309
+ name: this.swgPublisherName,
310
+ hasPart: {
311
+ '@type': 'WebPageElement',
312
+ },
313
+ isPartOf: {
314
+ '@type': ['CreativeWork', 'Product'],
315
+ name: this.swgPublisherId,
316
+ productID: this.swgProductId,
317
+ },
318
+ };
319
+ const str = JSON.stringify(jsonData);
320
+ const jsonScript = document.createElement('script');
321
+ jsonScript.type = 'application/ld+json';
322
+ jsonScript.text = str;
323
+ jsonScript.defer = true;
324
+ const jsonHead = document.querySelector('head');
325
+ if (jsonHead) {
326
+ jsonHead.appendChild(jsonScript);
327
+ }
328
+ }
329
+ connectedCallback() {
330
+ // eslint-disable-next-line wc/guard-super-call
331
+ super.connectedCallback();
332
+ if (this.swgEnable) {
333
+ this.jsonScript();
334
+ if (this.buttonElement) {
335
+ const head = document.querySelector('head');
336
+ const script = document.createElement('script');
337
+ script.src = 'https://news.google.com/swg/js/v1/swg.js';
338
+ script.defer = true;
339
+ script.onload = this.subscribeWithGoogleButton();
340
+ if (head) {
341
+ head.appendChild(script);
342
+ }
343
+ }
344
+ }
345
+ }
346
+ sendDataLayer() {
347
+ window.dataLayer.push({
348
+ event: 'halamanBerlanggananClick',
349
+ subscriptionStatus: '',
350
+ GUID: '',
351
+ interface: deviceType(),
352
+ });
353
+ }
354
+ sendDataLayeronHelpDesk() {
355
+ window.dataLayer.push({
356
+ event: 'helpOfferClick',
357
+ userType: this.subscriptionStatus,
358
+ GUID: this.userGuid,
359
+ interface: deviceType(),
360
+ });
361
+ }
362
+ sendDataLayeronButtonBuyPackage(name, id, price, position) {
363
+ const gtmParams = {
364
+ event: 'subscribe_button_clicked',
365
+ paywall_location: this.paywall_location,
366
+ paywall_subscription_package: name,
367
+ paywall_subscription_id: id,
368
+ paywall_subscription_price: price,
369
+ paywall_position: position,
370
+ user_type: this.tracker_user_type,
371
+ subscription_status: this.tracker_subscription_status,
372
+ page_domain: this.tracker_page_domain || 'Kompas.id',
373
+ metered_wall_type: this.tracker_metered_wall_type || 'HP',
374
+ metered_wall_balance: this.tracker_metered_wall_balance,
375
+ };
376
+ if (this.type !== 'epaper') {
377
+ gtmParams.content_title = this.tracker_content_title;
378
+ gtmParams.content_id = this.tracker_content_id;
379
+ gtmParams.content_categories = this.tracker_content_categories;
380
+ gtmParams.content_type = this.tracker_content_type;
381
+ gtmParams.page_type = this.tracker_page_type;
382
+ }
383
+ else {
384
+ gtmParams.epaper_edition = this.tracker_epaper_edition;
385
+ }
386
+ window.dataLayer.push(gtmParams);
387
+ }
388
+ headerSection(type) {
389
+ return html `
390
+ <div class="flex w-full items-center">
391
+ ${type === 'epaper'
392
+ ? html `<button
393
+ @click=${() => this.redirectToPrevUrl()}
394
+ class="hidden lg:block w-8 h-8 text-blue-600 pl-4"
395
+ >
396
+ ${unsafeSVG(getFontAwesomeIcon('fas', 'arrow-left'))}
397
+ </button>`
398
+ : ''}
399
+ <h4
400
+ class="text-base md:text-xl ${this.isDark &&
401
+ 'text-white'} text-center font-bold font-serif tracking-wide md:tracking-normal w-full"
402
+ >
403
+ Langganan untuk Lanjut Membaca
404
+ </h4>
405
+ </div>
406
+ `;
407
+ }
408
+ descriptionSection(data) {
409
+ return html `<div class=" flex flex-col items-center">
410
+ <div class="flex flex-col space-y-2 mt-2.5 md:mt-3">
411
+ ${data.map(item => html `
412
+ <div class="flex items-center">
413
+ <div class="text-green-500">
414
+ ${unsafeSVG(getFontAwesomeIcon('fas', 'check', 12, 12))}
415
+ </div>
416
+ <h6
417
+ class="text-xs md:text-base ${this.isDark &&
418
+ 'text-white'} ml-0.5 md:ml-1"
419
+ >
420
+ ${item}
421
+ </h6>
422
+ </div>
423
+ `)}
424
+ </div>
425
+ </div>`;
426
+ }
427
+ informationPackages() {
428
+ return html ` <div class="mt-4 flex justify-center">
429
+ <button
430
+ @click=${() => this.redirectToSubscriber()}
431
+ class="text-sm md:text-base font-bold ${this.isDark
432
+ ? 'text-blue-300'
433
+ : 'text-blue-600'} underline"
434
+ >
435
+ Lihat Paket Lainnya
436
+ </button>
437
+ </div>`;
438
+ }
439
+ separatorLine() {
440
+ return html `
441
+ <div class="flex flex-row w-full justify-center">
442
+ <div
443
+ class="border-b-2 ${this.isDark
444
+ ? 'border-dark-2'
445
+ : 'border-blue-200'} w-1/4 my-4 flex justify-center"
446
+ ></div>
447
+ <p class="px-4 pt-1 ${this.isDark && 'text-dark-1'}">atau</p>
448
+ <div
449
+ class="border-b-2 ${this.isDark
450
+ ? 'border-dark-2'
451
+ : 'border-blue-200'} w-1/4 my-4 flex justify-center"
452
+ ></div>
453
+ </div>
454
+ `;
455
+ }
456
+ paymentDesktopSection(data) {
457
+ return html `
458
+ <div
459
+ class="hidden md:flex w-full md:max-w-sm items-center justify-center flex-wrap"
460
+ >
461
+ ${data.map(item => html `<img
462
+ class="object-cover ${this.isDark ? 'h-9' : 'h-10'}"
463
+ src=${item.link}
464
+ alt="${item.name}-logo-payment"
465
+ />`)}
466
+ </div>
467
+ `;
468
+ }
469
+ paymentMobileSection(data) {
470
+ return html `
471
+ <div
472
+ class="grid md:hidden items-center grid-flow-col grid-cols-auto grid-rows-1 mt-4 mx-4"
473
+ >
474
+ ${data.map(item => html `<img
475
+ class="w-16"
476
+ src=${item.link}
477
+ alt="${item.name}-logo-payment"
478
+ />`)}
479
+ <button
480
+ @click=${() => this.paymentExtensionHandler()}
481
+ class="text-xs md:text-sm ${this.isDark
482
+ ? 'text-blue-300'
483
+ : 'text-blue-600'} font-bold"
484
+ >
485
+ +9 lainnya
486
+ </button>
487
+ </div>
488
+ `;
489
+ }
490
+ paymentMobileExtension(data) {
491
+ return html `
492
+ <div
493
+ class="w-full ${this.isDark
494
+ ? '-bottom-6'
495
+ : 'bottom-0'} max-w-xs mb-1 ml-8 md:hidden absolute px-4"
496
+ >
497
+ <div
498
+ class="w-full ${this.isDark
499
+ ? 'bg-dark-6 border-dark-6'
500
+ : 'bg-white border-white'} rounded p-3 max-w-xs"
501
+ >
502
+ <svg
503
+ class="right-0 ${this.isDark
504
+ ? 'text-dark-6 border-dark-6'
505
+ : 'text-white border-white '} h-4 mr-10 -mt-7 z-0 transform rotate-180 absolute"
506
+ x="0px"
507
+ y="0px"
508
+ viewBox="0 0 255 255"
509
+ >
510
+ <polygon class="fill-current" points="0,0 127.5,127.5 255,0" />
511
+ </svg>
512
+ <div
513
+ class="grid place-items-center items-center grid-flow-row grid-cols-5 grid-rows-2 gap-y-4"
514
+ >
515
+ ${data.map(item => html `<img
516
+ class="object-cover"
517
+ src=${item.link}
518
+ alt="${item.name}-logo-payment"
519
+ />`)}
520
+ </div>
521
+ </div>
522
+ </div>
523
+ `;
524
+ }
525
+ primaryPackages(product) {
526
+ return html `
527
+ <div
528
+ class="flex flex-wrap justify-between items-center ${this.isDark
529
+ ? 'bg-grey-600'
530
+ : 'bg-white'} rounded md:mx-0 w-full max-w-xs md:max-w-sm md:w-3/5 mt-2.5 md:mt-4 border border-yellow-400 relative"
531
+ >
532
+ <div class="flex flex-col py-3 px-4">
533
+ <div class="flex flex-none items-center">
534
+ <h5 class="text-base md:text-lg font-bold text-orange-400">
535
+ ${this.getRupiahFormat(product.price)}
536
+ </h5>
537
+ <h6
538
+ class="text-xs md:text-base ${this.isDark &&
539
+ 'text-white'} font-bold pl-1"
540
+ >
541
+ / ${product.periode}
542
+ </h6>
543
+ </div>
544
+ <div class="flex items-center">
545
+ <p class="text-xs ${this.isDark && 'text-white'}">
546
+ hanya <span class="text-orange-400">Rp 30.000</span> / bulan
547
+ </p>
548
+ </div>
549
+ </div>
550
+ <button
551
+ class="h-auto ${this.isDark
552
+ ? 'bg-green-300 border border-green-400'
553
+ : 'bg-green-500'} rounded mr-4"
554
+ @click=${() => this.redirectToCheckout(product.url, 'Cash-B2C-Halaman Berlangganan-Reguler_Digital-KDP 12', '9802032', 360000, 1)}
555
+ >
556
+ <h6
557
+ class="text-xs md:text-base ${this.isDark
558
+ ? 'text-black'
559
+ : 'text-white'} font-bold py-2 px-4"
560
+ >
561
+ Langganan
562
+ </h6>
563
+ </button>
564
+ <div class="absolute -top-2 left-4">
565
+ <div class="rounded bg-yellow-300 px-2 py-0.5 text-xs">
566
+ <b>Harga Terbaik</b>
567
+ </div>
568
+ </div>
569
+ </div>
570
+ `;
571
+ }
572
+ secondaryPackages(product) {
573
+ return html `
574
+ <div
575
+ class="flex flex-wrap justify-between ${this.isDark
576
+ ? 'bg-grey-600'
577
+ : 'bg-white'} py-3 px-4 rounded md:mx-0 w-full max-w-xs md:max-w-sm md:w-3/5 mt-3 md:mt-4"
578
+ >
579
+ <div class="flex items-center">
580
+ <h5 class="text-base md:text-lg font-bold text-orange-400">
581
+ ${this.getRupiahFormat(product.price)}
582
+ </h5>
583
+ <h6
584
+ class="text-xs md:text-base ${this.isDark &&
585
+ 'text-white'} font-bold pl-1"
586
+ >
587
+ / ${product.periode}
588
+ </h6>
589
+ </div>
590
+ <button
591
+ @click=${() => this.redirectToCheckout(product.url, 'Cash-B2C-Halaman Berlangganan-Reguler_Digital-KDP 1', '9802035', 50000, 2)}
592
+ class="h-auto ${!this.isDark &&
593
+ 'bg-white'} border border-green-500 rounded"
594
+ >
595
+ <h6
596
+ class="text-xs md:text-base ${this.isDark
597
+ ? 'text-green-300'
598
+ : 'text-green-500'} font-bold py-2 px-4"
599
+ >
600
+ Langganan
601
+ </h6>
602
+ </button>
603
+ </div>
604
+ `;
605
+ }
606
+ packagesSection(data) {
607
+ return html `
608
+ <div class="flex flex-col w-full items-center mt-8 lg:mt-2 px-2 ">
609
+ <h6
610
+ class="text-sm md:text-base ${this.isDark && 'text-white'} font-bold"
611
+ >
612
+ ${data.title}
613
+ </h6>
614
+ ${data.memberships.map(item => item.isHighlight
615
+ ? this.primaryPackages(item)
616
+ : this.secondaryPackages(item))}
617
+ </div>
618
+ `;
619
+ }
620
+ topNavigator() {
621
+ return html `
622
+ <div class="flex lg:hidden items-center w-full pb-4 ">
623
+ <button
624
+ @click=${() => this.redirectToPrevUrl()}
625
+ class="text-xs md:text-lg text-white flex flex-row"
626
+ >
627
+ <div class="icon-lg icon-white w-4 h-4 mr-3.5 md:mr-5 pt-0.5">
628
+ ${unsafeSVG(getFontAwesomeIcon('fas', 'arrow-left'))}
629
+ </div>
630
+ Kembali
631
+ </button>
632
+ </div>
633
+ `;
634
+ }
635
+ helpDesk() {
636
+ return html `
637
+ <div class="py-2.5 text-white self-center text-xs md:text-sm">
638
+ Mengalami masalah? Hubungi
639
+ <button
640
+ @click=${() => this.redirectToHelpdesk()}
641
+ class="font-bold ${this.isDark && 'text-blue-300'} underline"
642
+ >
643
+ Layanan Pelanggan.
644
+ </button>
645
+ </div>
646
+ `;
647
+ }
648
+ authRegister() {
649
+ return html `
650
+ <div
651
+ class="flex flex-row text-white px-2 py-2.5 space-x-4 md:space-x-8 self-center"
652
+ >
653
+ <div class="flex flex-col text-left text-xs md:text-sm text-white">
654
+ <b>Sudah berlangganan Kompas.id?</b>
655
+ <p>Masuk untuk lanjut membaca.</p>
656
+ </div>
657
+ <button
658
+ @click=${() => this.redirectToRegister()}
659
+ class="h-auto ${this.isDark
660
+ ? 'bg-blue-300'
661
+ : 'bg-grey-100'} rounded mr-3"
662
+ >
663
+ <p
664
+ class="text-xs md:text-sm ${this.isDark
665
+ ? 'text-black'
666
+ : 'text-blue-600'} font-bold py-2 px-4"
667
+ >
668
+ Masuk / Daftar
669
+ </p>
670
+ </button>
671
+ </div>
672
+ `;
673
+ }
674
+ userAction(isLogin, type) {
675
+ return html `
676
+ <div
677
+ class="flex h-20 ${this.isDark
678
+ ? 'bg-dark-4'
679
+ : 'bg-blue-600'} w-full justify-evenly rounded-b mt-6 md:mt-8 relative"
680
+ >
681
+ ${isLogin || type !== 'epaper' ? this.helpDesk() : this.authRegister()}
682
+ </div>
683
+ `;
684
+ }
685
+ render() {
686
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
687
+ return html `
688
+ <div
689
+ class="${this.type === 'epaper'
690
+ ? 'bg-transparent wrapper-body'
691
+ : 'wrapper-body'}"
692
+ >
693
+ <div
694
+ class="flex flex-col justify-center items-center w-full max-w-screen-sm px-4 md:px-0 my-5 relative"
695
+ >
696
+ ${this.type === 'epaper' ? this.topNavigator() : ''}
697
+ <div
698
+ class="flex w-full flex-col items-center justify-center ${this
699
+ .isDark
700
+ ? 'bg-dark-3'
701
+ : 'bg-blue-100'} rounded pt-6 md:pt-8 relative"
702
+ >
703
+ ${this.headerSection(this.type)}
704
+ ${this.descriptionSection((_c = (_b = (_a = this.paywallData) === null || _a === void 0 ? void 0 : _a.informations) === null || _b === void 0 ? void 0 : _b.description) !== null && _c !== void 0 ? _c : [])}
705
+ ${this.packagesSection((_e = (_d = this.paywallData) === null || _d === void 0 ? void 0 : _d.packages) !== null && _e !== void 0 ? _e : {})}
706
+ ${this.informationPackages()}
707
+ ${this.swgEnable ? this.separatorLine() : null}
708
+ ${this.swgEnable
709
+ ? html `<button
710
+ class="border-2 bg-grey-100 border-grey-100 rounded-lg px-6 shadow-sm flex flex-row py-2 mt-1 mb-4"
711
+ ref=${(el) => (this.buttonElement = el)}
712
+ >
713
+ <p>Subscribe with</p>
714
+ <img class="pl-2 object-scale-down w-20 pt-0.5" src="https://kompasid-production-www.s3.ap-southeast-1.amazonaws.com/paywall-asset/google.png" alt="subscribe with google"></img>
715
+ </button>`
716
+ : null}
717
+ ${this.paymentDesktopSection((_h = (_g = (_f = this.paywallData) === null || _f === void 0 ? void 0 : _f.payment) === null || _g === void 0 ? void 0 : _g.desktop) !== null && _h !== void 0 ? _h : [])}
718
+ ${this.paymentMobileSection((_l = (_k = (_j = this.paywallData) === null || _j === void 0 ? void 0 : _j.payment) === null || _k === void 0 ? void 0 : _k.mobile) !== null && _l !== void 0 ? _l : [])}
719
+ ${this.userAction(this.isLogin, this.type)}
720
+ ${this.sendDataLayeronPaywallBody()}
721
+ </div>
722
+ ${this.isExtensionsOpened
723
+ ? this.paymentMobileExtension((_p = (_o = (_m = this.paywallData) === null || _m === void 0 ? void 0 : _m.payment) === null || _o === void 0 ? void 0 : _o.ekstension) !== null && _p !== void 0 ? _p : [])
724
+ : ''}
725
+ </div>
726
+ </div>
727
+ `;
728
+ }
729
+ };
730
+ KompasPaywallBody.styles = [css ``, TWStyles];
731
+ __decorate([
732
+ property({ type: String })
733
+ ], KompasPaywallBody.prototype, "slug", void 0);
734
+ __decorate([
735
+ property({ type: Number })
736
+ ], KompasPaywallBody.prototype, "udin", void 0);
737
+ __decorate([
738
+ property({ type: Boolean })
739
+ ], KompasPaywallBody.prototype, "isLogin", void 0);
740
+ __decorate([
741
+ property({ type: String })
742
+ ], KompasPaywallBody.prototype, "type", void 0);
743
+ __decorate([
744
+ property({ type: Object })
745
+ ], KompasPaywallBody.prototype, "paywallData", void 0);
746
+ __decorate([
747
+ property({ type: String })
748
+ ], KompasPaywallBody.prototype, "userGuid", void 0);
749
+ __decorate([
750
+ property({ type: String })
751
+ ], KompasPaywallBody.prototype, "subscriptionStatus", void 0);
752
+ __decorate([
753
+ property({ type: Number })
754
+ ], KompasPaywallBody.prototype, "countdownArticle", void 0);
755
+ __decorate([
756
+ property({ type: Boolean })
757
+ ], KompasPaywallBody.prototype, "swgEnable", void 0);
758
+ __decorate([
759
+ property({ type: String })
760
+ ], KompasPaywallBody.prototype, "paywall_location", void 0);
761
+ __decorate([
762
+ property({ type: String })
763
+ ], KompasPaywallBody.prototype, "paywall_subscription_package", void 0);
764
+ __decorate([
765
+ property({ type: Number })
766
+ ], KompasPaywallBody.prototype, "paywall_subscription_id", void 0);
767
+ __decorate([
768
+ property({ type: Number })
769
+ ], KompasPaywallBody.prototype, "paywall_subscription_price", void 0);
770
+ __decorate([
771
+ property({ type: Number })
772
+ ], KompasPaywallBody.prototype, "paywall_position", void 0);
773
+ __decorate([
774
+ property({ type: String })
775
+ ], KompasPaywallBody.prototype, "tracker_page_type", void 0);
776
+ __decorate([
777
+ property({ type: String })
778
+ ], KompasPaywallBody.prototype, "tracker_content_id", void 0);
779
+ __decorate([
780
+ property({ type: String })
781
+ ], KompasPaywallBody.prototype, "tracker_content_title", void 0);
782
+ __decorate([
783
+ property({ type: String })
784
+ ], KompasPaywallBody.prototype, "tracker_content_categories", void 0);
785
+ __decorate([
786
+ property({ type: String })
787
+ ], KompasPaywallBody.prototype, "tracker_content_type", void 0);
788
+ __decorate([
789
+ property({ type: String })
790
+ ], KompasPaywallBody.prototype, "tracker_user_type", void 0);
791
+ __decorate([
792
+ property({ type: String })
793
+ ], KompasPaywallBody.prototype, "tracker_subscription_status", void 0);
794
+ __decorate([
795
+ property({ type: String })
796
+ ], KompasPaywallBody.prototype, "tracker_page_domain", void 0);
797
+ __decorate([
798
+ property({ type: String })
799
+ ], KompasPaywallBody.prototype, "tracker_metered_wall_type", void 0);
800
+ __decorate([
801
+ property({ type: Number })
802
+ ], KompasPaywallBody.prototype, "tracker_metered_wall_balance", void 0);
803
+ __decorate([
804
+ property({ type: String })
805
+ ], KompasPaywallBody.prototype, "tracker_epaper_edition", void 0);
806
+ __decorate([
807
+ property({ type: String })
808
+ ], KompasPaywallBody.prototype, "theme", void 0);
809
+ __decorate([
810
+ state()
811
+ ], KompasPaywallBody.prototype, "isExtensionsOpened", void 0);
812
+ __decorate([
813
+ state()
814
+ ], KompasPaywallBody.prototype, "kompasAkunHost", void 0);
815
+ __decorate([
816
+ state()
817
+ ], KompasPaywallBody.prototype, "kompasApigenHost", void 0);
818
+ __decorate([
819
+ state()
820
+ ], KompasPaywallBody.prototype, "kompasApiWcmHost", void 0);
821
+ __decorate([
822
+ state()
823
+ ], KompasPaywallBody.prototype, "kompasLoginHost", void 0);
824
+ __decorate([
825
+ state()
826
+ ], KompasPaywallBody.prototype, "selfHost", void 0);
827
+ __decorate([
828
+ state()
829
+ ], KompasPaywallBody.prototype, "swgPublisherName", void 0);
830
+ __decorate([
831
+ state()
832
+ ], KompasPaywallBody.prototype, "swgPublisherId", void 0);
833
+ __decorate([
834
+ state()
835
+ ], KompasPaywallBody.prototype, "swgProductId", void 0);
836
+ __decorate([
837
+ state()
838
+ ], KompasPaywallBody.prototype, "errorFlag", void 0);
839
+ KompasPaywallBody = __decorate([
840
+ customElement('kompas-paywall-body')
841
+ ], KompasPaywallBody);
842
+ export { KompasPaywallBody };
843
+ //# sourceMappingURL=KompasPaywallBody.js.map