@rededor/site-front-end-lib 0.0.3 → 0.0.4-alpha.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.
Files changed (38) hide show
  1. package/README.md +80 -18
  2. package/esm2022/lib/directives/index.mjs +3 -0
  3. package/esm2022/lib/directives/rdsite-link/rdsite-link.directive.mjs +137 -0
  4. package/esm2022/lib/directives/rdsite-phone-modal/rdsite-phone-modal.directive.mjs +52 -0
  5. package/esm2022/lib/enums/RdsiteModalComponentStyle.enum.mjs +9 -0
  6. package/esm2022/lib/enums/RdsiteModalDrawerComponentStyle.enum.mjs +6 -0
  7. package/esm2022/lib/enums/index.mjs +6 -0
  8. package/esm2022/lib/helpers/formatPhone.func.mjs +29 -0
  9. package/esm2022/lib/pipes/index.mjs +2 -0
  10. package/esm2022/lib/pipes/phone/phone.pipe.mjs +18 -0
  11. package/esm2022/lib/services/index.mjs +4 -1
  12. package/esm2022/lib/services/modal/modal.service.mjs +56 -0
  13. package/esm2022/lib/services/modal-drawer/modal-drawer.service.mjs +42 -0
  14. package/esm2022/lib/services/phone/phone.service.mjs +32 -0
  15. package/esm2022/lib/services/seo/seo.service.mjs +31 -31
  16. package/esm2022/lib/services/transfer-state/transfer-state.service.mjs +28 -7
  17. package/esm2022/lib/tokens/LibConfig.mjs +2 -2
  18. package/esm2022/public-api.mjs +6 -4
  19. package/fesm2022/rededor-site-front-end-lib.mjs +414 -37
  20. package/fesm2022/rededor-site-front-end-lib.mjs.map +1 -1
  21. package/lib/directives/index.d.ts +2 -0
  22. package/lib/directives/rdsite-link/rdsite-link.directive.d.ts +32 -0
  23. package/lib/directives/rdsite-phone-modal/rdsite-phone-modal.directive.d.ts +17 -0
  24. package/lib/enums/RdsiteModalComponentStyle.enum.d.ts +7 -0
  25. package/lib/enums/RdsiteModalDrawerComponentStyle.enum.d.ts +4 -0
  26. package/lib/enums/index.d.ts +5 -0
  27. package/lib/helpers/formatPhone.func.d.ts +1 -0
  28. package/lib/pipes/index.d.ts +1 -0
  29. package/lib/pipes/phone/phone.pipe.d.ts +7 -0
  30. package/lib/services/index.d.ts +3 -0
  31. package/lib/services/modal/modal.service.d.ts +31 -0
  32. package/lib/services/modal-drawer/modal-drawer.service.d.ts +37 -0
  33. package/lib/services/phone/phone.service.d.ts +13 -0
  34. package/lib/services/seo/seo.service.d.ts +1 -1
  35. package/lib/services/transfer-state/transfer-state.service.d.ts +4 -1
  36. package/lib/tokens/LibConfig.d.ts +3 -1
  37. package/package.json +1 -1
  38. package/public-api.d.ts +3 -3
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Inject, PLATFORM_ID, Optional, makeStateKey, Component, CUSTOM_ELEMENTS_SCHEMA, HostBinding } from '@angular/core';
2
+ import { InjectionToken, Injectable, Inject, PLATFORM_ID, Optional, makeStateKey, Component, CUSTOM_ELEMENTS_SCHEMA, HostBinding, Directive, Input, HostListener, Pipe } from '@angular/core';
3
3
  import * as i2 from '@angular/common';
4
4
  import { isPlatformBrowser, isPlatformServer, DOCUMENT, CommonModule } from '@angular/common';
5
5
  import algoliasearch from 'algoliasearch';
@@ -9,6 +9,7 @@ import { HttpHeaders } from '@angular/common/http';
9
9
  import * as i2$1 from 'ngx-device-detector';
10
10
  import * as he from 'he';
11
11
  import * as i1$1 from '@angular/platform-browser';
12
+ import * as i1$2 from '@angular/router';
12
13
 
13
14
  // Configura a lib com informações especificas de cada projeto.
14
15
  const LIB_CONFIG = new InjectionToken('libConfig');
@@ -384,6 +385,100 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
384
385
  args: [LIB_CONFIG]
385
386
  }] }, { type: i1.HttpClient }, { type: i2$1.DeviceDetectorService }] });
386
387
 
388
+ class AbstractModalComponent {
389
+ }
390
+ class ModalService {
391
+ constructor() {
392
+ this.reference = null;
393
+ }
394
+ open() {
395
+ this.reference?.open();
396
+ }
397
+ setReference(element) {
398
+ this.reference = element;
399
+ }
400
+ setHeader(header) {
401
+ if (!this.reference)
402
+ return;
403
+ this.reference.modalHeader = header;
404
+ }
405
+ setTitle(title) {
406
+ if (!this.reference)
407
+ return;
408
+ this.reference.modalTitle = title;
409
+ }
410
+ setContent(content, context = {}) {
411
+ if (!this.reference)
412
+ return;
413
+ this.reference.modalContent = content;
414
+ this.reference.modalContentContext = context;
415
+ }
416
+ setActions(actions) {
417
+ if (!this.reference)
418
+ return;
419
+ this.reference.modalActions = actions;
420
+ }
421
+ setStyle(style) {
422
+ if (!this.reference)
423
+ return;
424
+ this.reference.componentStyle = style;
425
+ }
426
+ setDefaultPhoneModal(modal) {
427
+ this.defaultPhoneModal = modal;
428
+ }
429
+ close() {
430
+ this.reference?.close();
431
+ }
432
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: ModalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
433
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: ModalService, providedIn: 'root' }); }
434
+ }
435
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: ModalService, decorators: [{
436
+ type: Injectable,
437
+ args: [{
438
+ providedIn: 'root',
439
+ }]
440
+ }] });
441
+
442
+ class AbstractModalDrawerComponent {
443
+ }
444
+ class ModalDrawerService {
445
+ constructor() {
446
+ this.reference = null;
447
+ }
448
+ open() {
449
+ this.reference?.openSheet();
450
+ }
451
+ setReference(element) {
452
+ this.reference = element;
453
+ }
454
+ setContent(content) {
455
+ if (!this.reference)
456
+ return;
457
+ this.reference.modalContent = content;
458
+ }
459
+ setStyle(style) {
460
+ if (!this.reference)
461
+ return;
462
+ this.reference.componentStyle = style;
463
+ }
464
+ setHeight(value) {
465
+ if (!this.reference)
466
+ return;
467
+ this.reference.maxHeight = value;
468
+ }
469
+ close() {
470
+ this.reference?.closeSheet();
471
+ }
472
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: ModalDrawerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
473
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: ModalDrawerService, providedIn: 'root' }); }
474
+ }
475
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: ModalDrawerService, decorators: [{
476
+ type: Injectable,
477
+ args: [{
478
+ providedIn: 'root',
479
+ }]
480
+ }] });
481
+
387
482
  class NguCarouselService {
388
483
  constructor() {
389
484
  this._defaultCarouselConfig = {
@@ -463,6 +558,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
463
558
  }]
464
559
  }] });
465
560
 
561
+ class PhoneService {
562
+ constructor(document) {
563
+ this.document = document;
564
+ this.telRegex = /tel:/;
565
+ this.consultaExameRegex = /(consulta|exame)/gi;
566
+ this.phoneModalIsAllowed = true; // variavel utilizada para permitir/bloquear o modal de telefone
567
+ }
568
+ /** Verifica se o 'href' é de telefone e se a janela está em tamanho desktop */
569
+ isPhoneModal(href) {
570
+ const width = this.document.defaultView?.innerWidth ?? 0;
571
+ const SMALL_BREAKPOINT = 718;
572
+ return this.telRegex.test(href) && width > SMALL_BREAKPOINT;
573
+ }
574
+ isConsultaOuExame(label = '') {
575
+ return this.consultaExameRegex.test(label);
576
+ }
577
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: PhoneService, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
578
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: PhoneService, providedIn: 'root' }); }
579
+ }
580
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: PhoneService, decorators: [{
581
+ type: Injectable,
582
+ args: [{
583
+ providedIn: 'root',
584
+ }]
585
+ }], ctorParameters: () => [{ type: Document, decorators: [{
586
+ type: Inject,
587
+ args: [DOCUMENT]
588
+ }] }] });
589
+
466
590
  var unidades = [
467
591
  {
468
592
  path: "/acreditar/",
@@ -32417,9 +32541,9 @@ class SeoService {
32417
32541
  this.jsonTagId = 'seoJSON';
32418
32542
  this.breadcrumbsJsonTagId = 'breadcrumbsJSON';
32419
32543
  this.unidade = null;
32420
- this.unidadeName = "";
32421
- this.unidadePath = "";
32422
- this.unidadeSlug = "";
32544
+ this.unidadeName = '';
32545
+ this.unidadePath = '';
32546
+ this.unidadeSlug = '';
32423
32547
  }
32424
32548
  setFullSeo(data) {
32425
32549
  this.setTitle(data.title.text, !!data.title.sub);
@@ -32512,7 +32636,7 @@ class SeoService {
32512
32636
  this.setMetaTag('twitter:site', url, 'name');
32513
32637
  this.setMetaTag('twitter:title', title, 'name');
32514
32638
  this.setMetaTag('twitter:description', description, 'name');
32515
- this.setMetaTag("twitter:image", img ?? '', "name");
32639
+ this.setMetaTag('twitter:image', img ?? '', 'name');
32516
32640
  }
32517
32641
  /**
32518
32642
  * Define tags de redes sociais (Twitter e Open Graph)
@@ -32528,7 +32652,7 @@ class SeoService {
32528
32652
  title: this.getTitle(),
32529
32653
  description: this.activeDescription || '',
32530
32654
  url: `${siteurl}${pagePath}`,
32531
- image: `${siteurl}/assets/imgs/logo-novo-rededor-saoluiz-blue.png`,
32655
+ image: this.libConfig?.logoPath ? `${siteurl}${this.libConfig.logoPath}` : 'https://www.rededorsaoluiz.com.br/assets/imgs/logo-rededor-blue.png',
32532
32656
  };
32533
32657
  if (properties) {
32534
32658
  defaultProperties = { ...defaultProperties, ...properties };
@@ -32635,9 +32759,9 @@ class SeoService {
32635
32759
  const pagePath = this.location.path();
32636
32760
  return `${siteurl}${pagePath}`;
32637
32761
  }
32638
- url = url.filter(u => u !== this.unidadePath);
32762
+ url = url.filter((u) => u !== this.unidadePath);
32639
32763
  const unidadePath = this.getUnidadePath();
32640
- const fullPath = `${unidadePath}/${url.join("/").replace(/^\/?/, "")}`;
32764
+ const fullPath = `${unidadePath}/${url.join('/').replace(/^\/?/, '')}`;
32641
32765
  return `${siteurl}/${fullPath}`.replace(/\/$/, '');
32642
32766
  }
32643
32767
  /** Cria tag script para o JSON de SEO */
@@ -32711,9 +32835,9 @@ class SeoService {
32711
32835
  };
32712
32836
  }
32713
32837
  getUnidadePath() {
32714
- let unidadePath = "";
32838
+ let unidadePath = '';
32715
32839
  if (this.unidade && this.unidadePath) {
32716
- unidadePath = this.unidade?.path === "/" ? "" : this.unidadePath?.substring(0, this.unidadePath?.length - 1);
32840
+ unidadePath = this.unidade?.path === '/' ? '' : this.unidadePath?.substring(0, this.unidadePath?.length - 1);
32717
32841
  }
32718
32842
  return unidadePath;
32719
32843
  }
@@ -32783,51 +32907,51 @@ class SeoService {
32783
32907
  const siteurl = getSiteUrl(this.libConfig?.siteUrl, this.libConfig?.siteSufix);
32784
32908
  const unidadeSlug = this.unidadeSlug;
32785
32909
  let converted = urlFromWpApi.replace(apiUrl, siteurl);
32786
- if (unidadeSlug !== "/" && converted.includes(`/${unidadeSlug}/`)) {
32910
+ if (unidadeSlug !== '/' && converted.includes(`/${unidadeSlug}/`)) {
32787
32911
  converted = converted.replace(`/${unidadeSlug}/`, `${this.unidadePath}`);
32788
32912
  }
32789
32913
  return converted;
32790
32914
  }
32791
32915
  getPostContent(post) {
32792
- const content = post.acf.rdsl_post_content.find((content) => content.acf_fc_layout === "text_html");
32793
- return content.content || post.content.rendered || "";
32916
+ const content = post.acf['rdsl_post_content'] ? post.acf.rdsl_post_content.find((content) => content.acf_fc_layout === 'text_html') : null;
32917
+ return content?.content || post.content.rendered || '';
32794
32918
  }
32795
32919
  addArticleScript(post, scriptName) {
32796
32920
  const postContent = this.getPostContent(post);
32797
- const postHeaderImage = post.acf["rdsl_post_header_img"]
32921
+ const postHeaderImage = post.acf['rdsl_post_header_img']
32798
32922
  ? {
32799
- url: post.acf["rdsl_post_header_img"].url,
32800
- width: post.acf["rdsl_post_header_img"].width,
32801
- height: post.acf["rdsl_post_header_img"].height
32923
+ url: post.acf['rdsl_post_header_img'].url,
32924
+ width: post.acf['rdsl_post_header_img'].width,
32925
+ height: post.acf['rdsl_post_header_img'].height,
32802
32926
  }
32803
32927
  : null;
32804
32928
  const structuredData = {
32805
- "@context": "https://schema.org",
32806
- "@type": "Article",
32929
+ '@context': 'https://schema.org',
32930
+ '@type': 'Article',
32807
32931
  mainEntityOfPage: `${getSiteUrl(this.libConfig?.siteUrl, this.libConfig?.siteSufix)}${this.location.path()}`,
32808
32932
  headline: post.title?.rendered,
32809
32933
  datePublished: post.date_gmt,
32810
32934
  publisher: {
32811
- "@type": "Organization",
32812
- name: "Rede D’Or"
32935
+ '@type': 'Organization',
32936
+ name: 'Rede D’Or',
32813
32937
  },
32814
32938
  description: post.title?.rendered,
32815
32939
  articleBody: removeHtmlTags(he.decode(postContent)),
32816
32940
  dateModified: post.modified_gmt,
32817
32941
  image: {
32818
- "@type": "ImageObject",
32819
- url: postHeaderImage?.url || post.featured_media_path || "",
32820
- height: postHeaderImage?.height || "",
32821
- width: postHeaderImage?.width || ""
32942
+ '@type': 'ImageObject',
32943
+ url: postHeaderImage?.url || post.featured_media_path || '',
32944
+ height: postHeaderImage?.height || '',
32945
+ width: postHeaderImage?.width || '',
32822
32946
  },
32823
32947
  author: {
32824
- "@type": "Organization",
32825
- name: "Rede D’Or"
32948
+ '@type': 'Organization',
32949
+ name: 'Rede D’Or',
32826
32950
  },
32827
- wordcount: postContent.split(" ").length
32951
+ wordcount: postContent.split(' ').length,
32828
32952
  };
32829
- const script = this.document.createElement("script");
32830
- script.type = "application/ld+json";
32953
+ const script = this.document.createElement('script');
32954
+ script.type = 'application/ld+json';
32831
32955
  script.id = scriptName;
32832
32956
  script.innerHTML = JSON.stringify(structuredData);
32833
32957
  this.document.head.appendChild(script);
@@ -32836,7 +32960,7 @@ class SeoService {
32836
32960
  const script = this.document.getElementById(scriptName);
32837
32961
  script?.remove();
32838
32962
  }
32839
- setUnidade({ unidade = null, unidadeName = "", unidadePath = "", unidadeSlug = "", }) {
32963
+ setUnidade({ unidade = null, unidadeName = '', unidadePath = '', unidadeSlug = '' }) {
32840
32964
  this.unidade = unidade;
32841
32965
  this.unidadeName = unidadeName;
32842
32966
  this.unidadePath = unidadePath;
@@ -32988,8 +33112,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
32988
33112
  }] }] });
32989
33113
 
32990
33114
  class TransferStateService {
32991
- constructor(transferState) {
33115
+ constructor(transferState, platformId) {
32992
33116
  this.transferState = transferState;
33117
+ this.platformId = platformId;
32993
33118
  this.keys = new Map();
32994
33119
  }
32995
33120
  setKey(name, response) {
@@ -32998,7 +33123,9 @@ class TransferStateService {
32998
33123
  key = makeStateKey(name);
32999
33124
  this.keys.set(name, key);
33000
33125
  }
33001
- this.transferState.set(key, response);
33126
+ const newResponse = this.encryptResponseBase64(response);
33127
+ console.log('res', newResponse);
33128
+ this.transferState.set(key, newResponse);
33002
33129
  }
33003
33130
  getKey(name, defaultValue = null) {
33004
33131
  let key = this.keys.get(name);
@@ -33007,7 +33134,9 @@ class TransferStateService {
33007
33134
  this.keys.set(name, key);
33008
33135
  }
33009
33136
  const response = this.transferState.get(key, defaultValue);
33010
- return response;
33137
+ const newResponse = this.decryptResponseBase64(response);
33138
+ console.log('res', newResponse);
33139
+ return newResponse;
33011
33140
  }
33012
33141
  remove(name) {
33013
33142
  let key = this.keys.get(name);
@@ -33017,7 +33146,19 @@ class TransferStateService {
33017
33146
  }
33018
33147
  this.transferState.remove(key);
33019
33148
  }
33020
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: TransferStateService, deps: [{ token: i0.TransferState }], target: i0.ɵɵFactoryTarget.Injectable }); }
33149
+ encryptResponseBase64(response) {
33150
+ if (isPlatformBrowser(this.platformId) && typeof window !== 'undefined') {
33151
+ return atob(response);
33152
+ }
33153
+ return Buffer.from(response).toString('base64');
33154
+ }
33155
+ decryptResponseBase64(response) {
33156
+ if (isPlatformBrowser(this.platformId) && typeof window !== 'undefined') {
33157
+ return btoa(response);
33158
+ }
33159
+ return Buffer.from(response, 'base64').toString();
33160
+ }
33161
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: TransferStateService, deps: [{ token: i0.TransferState }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
33021
33162
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: TransferStateService, providedIn: 'root' }); }
33022
33163
  }
33023
33164
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: TransferStateService, decorators: [{
@@ -33025,7 +33166,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
33025
33166
  args: [{
33026
33167
  providedIn: 'root',
33027
33168
  }]
33028
- }], ctorParameters: () => [{ type: i0.TransferState }] });
33169
+ }], ctorParameters: () => [{ type: i0.TransferState }, { type: undefined, decorators: [{
33170
+ type: Inject,
33171
+ args: [PLATFORM_ID]
33172
+ }] }] });
33029
33173
 
33030
33174
  class TestComponent {
33031
33175
  constructor(curaService) {
@@ -33048,6 +33192,233 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImpo
33048
33192
 
33049
33193
  // Components
33050
33194
 
33195
+ var RdsiteModalComponentStyle;
33196
+ (function (RdsiteModalComponentStyle) {
33197
+ RdsiteModalComponentStyle["DEFAULT"] = "default";
33198
+ RdsiteModalComponentStyle["ALERT"] = "alert";
33199
+ RdsiteModalComponentStyle["LIGHT"] = "light";
33200
+ RdsiteModalComponentStyle["DOCTORCARD"] = "doctor-card";
33201
+ RdsiteModalComponentStyle["HOMESLIDE"] = "home-slide";
33202
+ })(RdsiteModalComponentStyle || (RdsiteModalComponentStyle = {}));
33203
+
33204
+ const formatPhone = (phone) => {
33205
+ if (!phone)
33206
+ return '';
33207
+ const cleanPhone = phone.replace(/[^0-9]/gi, '');
33208
+ let formatedPhone = '';
33209
+ if (cleanPhone.length === 12) {
33210
+ formatedPhone = cleanPhone.replace(/(\d{3})?(\d{5})?(\d{4})/, '($1) $2-$3');
33211
+ }
33212
+ else if (cleanPhone.length === 11) {
33213
+ formatedPhone = cleanPhone.replace(/(\d{2})?(\d{5})?(\d{4})/, '($1) $2-$3');
33214
+ }
33215
+ else if (cleanPhone.length === 10) {
33216
+ formatedPhone = cleanPhone.replace(/(\d{2})?(\d{4})?(\d{4})/, '($1) $2-$3');
33217
+ }
33218
+ else if (cleanPhone.length === 9) {
33219
+ formatedPhone = cleanPhone.replace(/(\d{5})?(\d{4})/, '$1-$2');
33220
+ }
33221
+ else if (cleanPhone.length === 8) {
33222
+ formatedPhone = cleanPhone.replace(/(\d{4})?(\d{4})/, '$1-$2');
33223
+ }
33224
+ else if (cleanPhone.length === 7) {
33225
+ formatedPhone = cleanPhone.replace(/(\d{3})?(\d{4})/, '$1-$2');
33226
+ }
33227
+ else {
33228
+ formatedPhone = cleanPhone;
33229
+ }
33230
+ return formatedPhone;
33231
+ };
33232
+
33233
+ class RdsitePhoneModalDirective {
33234
+ constructor(modalService, platformId, element, phoneService) {
33235
+ this.modalService = modalService;
33236
+ this.platformId = platformId;
33237
+ this.element = element;
33238
+ this.phoneService = phoneService;
33239
+ this.rdsitephonemodal = null;
33240
+ this.allowedTags = ['A', 'CURA-BUTTON', 'CURA-BUTTON-OUTLINE', 'CURA-BUTTON-TRANSPARENT'];
33241
+ }
33242
+ // Intercepta cliques em telefones e aplica comportamentos diferentes em tamanho desktop.
33243
+ onClick(event) {
33244
+ if (!isPlatformBrowser(this.platformId) || !this.allowedTags.includes(this.element?.nativeElement?.tagName) || !this.phoneService.phoneModalIsAllowed)
33245
+ return;
33246
+ const href = this.element?.nativeElement?.getAttribute('href') ?? '';
33247
+ if (this.phoneService.isPhoneModal(href)) {
33248
+ this.openPhoneModal(event, href);
33249
+ }
33250
+ }
33251
+ openPhoneModal(event, href) {
33252
+ event.preventDefault();
33253
+ event.stopPropagation();
33254
+ this.modalService.setContent(this.rdsitephonemodal || this.modalService.defaultPhoneModal, { phone: formatPhone(href) });
33255
+ this.modalService.setStyle(RdsiteModalComponentStyle.DEFAULT);
33256
+ this.modalService.open();
33257
+ }
33258
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: RdsitePhoneModalDirective, deps: [{ token: ModalService }, { token: PLATFORM_ID }, { token: i0.ElementRef }, { token: PhoneService }], target: i0.ɵɵFactoryTarget.Directive }); }
33259
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.11", type: RdsitePhoneModalDirective, isStandalone: true, selector: "[rdsitephonemodal]", inputs: { rdsitephonemodal: "rdsitephonemodal" }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
33260
+ }
33261
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: RdsitePhoneModalDirective, decorators: [{
33262
+ type: Directive,
33263
+ args: [{
33264
+ // eslint-disable-next-line @angular-eslint/directive-selector
33265
+ selector: '[rdsitephonemodal]',
33266
+ standalone: true,
33267
+ }]
33268
+ }], ctorParameters: () => [{ type: ModalService }, { type: undefined, decorators: [{
33269
+ type: Inject,
33270
+ args: [PLATFORM_ID]
33271
+ }] }, { type: i0.ElementRef }, { type: PhoneService }], propDecorators: { rdsitephonemodal: [{
33272
+ type: Input
33273
+ }], onClick: [{
33274
+ type: HostListener,
33275
+ args: ['click', ['$event']]
33276
+ }] } });
33277
+
33278
+ class RdsiteLinkDirective {
33279
+ constructor(router, platformId, document, libConfig, element, phoneService, rdsitePhoneModalDirective) {
33280
+ this.router = router;
33281
+ this.platformId = platformId;
33282
+ this.document = document;
33283
+ this.libConfig = libConfig;
33284
+ this.element = element;
33285
+ this.phoneService = phoneService;
33286
+ this.rdsitePhoneModalDirective = rdsitePhoneModalDirective;
33287
+ this.externalRegex = /^http:|https:|tel:|www\.|mailto:/;
33288
+ this.telRegex = /tel:/;
33289
+ this.siteUrlList = ['rededorsaoluiz', 'rededorlabs'];
33290
+ this.allowedTags = ['A', 'CURA-BUTTON', 'CURA-BUTTON-OUTLINE', 'CURA-BUTTON-TRANSPARENT'];
33291
+ this.anchorAdjustment = null;
33292
+ this.anchorExtraAdjustment = null;
33293
+ this.phonemodal = null;
33294
+ }
33295
+ onClick(event) {
33296
+ event.preventDefault();
33297
+ if (!isPlatformBrowser(this.platformId) || !this.allowedTags.includes(this.element?.nativeElement?.tagName))
33298
+ return;
33299
+ const href = this.element?.nativeElement?.getAttribute('href') ?? '';
33300
+ if (this.isPhone(href)) {
33301
+ this.phoneClicked({
33302
+ href,
33303
+ event,
33304
+ element: this.element,
33305
+ phonemodal: this.phonemodal,
33306
+ });
33307
+ }
33308
+ else if (this.isExternalUrl(href)) {
33309
+ const target = this.isSiteUrl(href) ? '_self' : '_blank';
33310
+ window.open(href, target);
33311
+ }
33312
+ else if (href.startsWith('#')) {
33313
+ this.scrollToAnchor(href);
33314
+ }
33315
+ else {
33316
+ this.navigateTo(href);
33317
+ }
33318
+ }
33319
+ isPhone(href) {
33320
+ return this.telRegex.test(href);
33321
+ }
33322
+ phoneClicked(value) {
33323
+ const { href, event, element, phonemodal } = value;
33324
+ if (this.phoneService.isPhoneModal(href)) {
33325
+ if (this.phoneService.isConsultaOuExame(element?.nativeElement?.getAttribute('title'))) {
33326
+ this.rdsitePhoneModalDirective.rdsitephonemodal = phonemodal ?? null;
33327
+ }
33328
+ this.rdsitePhoneModalDirective.openPhoneModal(event, href);
33329
+ }
33330
+ else {
33331
+ window.open(href, '_blank');
33332
+ }
33333
+ }
33334
+ isExternalUrl(href) {
33335
+ return this.externalRegex.test(href);
33336
+ }
33337
+ isSiteUrl(href) {
33338
+ const exception = '/paciente';
33339
+ return this.siteUrlList.find((url) => href.includes(url) && !href.includes(exception));
33340
+ }
33341
+ scrollToAnchor(href) {
33342
+ if (href === '#')
33343
+ return;
33344
+ if (isPlatformBrowser(this.platformId)) {
33345
+ const docElement = this.document.documentElement;
33346
+ let adjustment = 0;
33347
+ if (this.libConfig.customAnchorAdjustment) {
33348
+ adjustment = this.libConfig.customAnchorAdjustment(this.document);
33349
+ }
33350
+ if (this.anchorAdjustment) {
33351
+ adjustment = this.anchorAdjustment;
33352
+ }
33353
+ if (this.anchorExtraAdjustment) {
33354
+ adjustment += this.anchorExtraAdjustment;
33355
+ }
33356
+ const bodyTop = this.document?.body?.getBoundingClientRect()?.top ?? 0;
33357
+ const hrefTop = this.document?.querySelector(href)?.getBoundingClientRect()?.top ?? 0;
33358
+ const scrollTop = bodyTop * -1 + hrefTop - adjustment;
33359
+ docElement.scrollTo({ top: scrollTop, behavior: 'smooth' });
33360
+ }
33361
+ }
33362
+ navigateTo(href) {
33363
+ const siteBasePath = this.libConfig.siteSufix ?? '';
33364
+ const noBaseHref = href.includes(siteBasePath) ? href.replace(siteBasePath, '') : href;
33365
+ const [path, query] = noBaseHref.split('?');
33366
+ const queryParams = {};
33367
+ if (query) {
33368
+ const queryArray = query.split('&');
33369
+ queryArray.forEach((q) => {
33370
+ const arr = q.split('=');
33371
+ queryParams[arr[0]] = arr[1];
33372
+ });
33373
+ }
33374
+ this.router.navigate([path], { queryParams: queryParams });
33375
+ }
33376
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: RdsiteLinkDirective, deps: [{ token: i1$2.Router }, { token: PLATFORM_ID }, { token: DOCUMENT }, { token: LIB_CONFIG }, { token: i0.ElementRef }, { token: PhoneService }, { token: RdsitePhoneModalDirective }], target: i0.ɵɵFactoryTarget.Directive }); }
33377
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.11", type: RdsiteLinkDirective, isStandalone: true, selector: "[rdsitelink]", inputs: { anchorAdjustment: "anchorAdjustment", anchorExtraAdjustment: "anchorExtraAdjustment", phonemodal: "phonemodal" }, host: { listeners: { "click": "onClick($event)" } }, providers: [RdsitePhoneModalDirective], ngImport: i0 }); }
33378
+ }
33379
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: RdsiteLinkDirective, decorators: [{
33380
+ type: Directive,
33381
+ args: [{
33382
+ // eslint-disable-next-line @angular-eslint/directive-selector
33383
+ selector: '[rdsitelink]',
33384
+ providers: [RdsitePhoneModalDirective],
33385
+ standalone: true,
33386
+ }]
33387
+ }], ctorParameters: () => [{ type: i1$2.Router }, { type: undefined, decorators: [{
33388
+ type: Inject,
33389
+ args: [PLATFORM_ID]
33390
+ }] }, { type: Document, decorators: [{
33391
+ type: Inject,
33392
+ args: [DOCUMENT]
33393
+ }] }, { type: undefined, decorators: [{
33394
+ type: Inject,
33395
+ args: [LIB_CONFIG]
33396
+ }] }, { type: i0.ElementRef }, { type: PhoneService }, { type: RdsitePhoneModalDirective }], propDecorators: { anchorAdjustment: [{
33397
+ type: Input
33398
+ }], anchorExtraAdjustment: [{
33399
+ type: Input
33400
+ }], phonemodal: [{
33401
+ type: Input
33402
+ }], onClick: [{
33403
+ type: HostListener,
33404
+ args: ['click', ['$event']]
33405
+ }] } });
33406
+
33407
+ class PhonePipe {
33408
+ transform(phone) {
33409
+ return formatPhone(phone);
33410
+ }
33411
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: PhonePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
33412
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.11", ngImport: i0, type: PhonePipe, isStandalone: true, name: "phone" }); }
33413
+ }
33414
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: PhonePipe, decorators: [{
33415
+ type: Pipe,
33416
+ args: [{
33417
+ name: 'phone',
33418
+ standalone: true,
33419
+ }]
33420
+ }] });
33421
+
33051
33422
  var Estados;
33052
33423
  (function (Estados) {
33053
33424
  Estados["AC"] = "Acre";
@@ -33090,6 +33461,12 @@ var EnumDoencaTaxonomyCat;
33090
33461
  EnumDoencaTaxonomyCat["SINTOMA"] = "sintomas";
33091
33462
  })(EnumDoencaTaxonomyCat || (EnumDoencaTaxonomyCat = {}));
33092
33463
 
33464
+ var RdsiteModalDrawerComponentStyle;
33465
+ (function (RdsiteModalDrawerComponentStyle) {
33466
+ RdsiteModalDrawerComponentStyle["DEFAULT"] = "default";
33467
+ RdsiteModalDrawerComponentStyle["DRAWERDOCTOR"] = "doctor-card";
33468
+ })(RdsiteModalDrawerComponentStyle || (RdsiteModalDrawerComponentStyle = {}));
33469
+
33093
33470
  /*
33094
33471
  * Public API Surface of site-front-end-lib
33095
33472
  */
@@ -33099,5 +33476,5 @@ var EnumDoencaTaxonomyCat;
33099
33476
  * Generated bundle index. Do not edit.
33100
33477
  */
33101
33478
 
33102
- export { AlgoliaService, CuraService, EnumDoencaTaxonomy, EnumDoencaTaxonomyCat, Estados, HttpClientService, IconCuraDefaultType, LIB_CONFIG, LogService, NguCarouselService, REQUEST, RESPONSE, SSR_CURA_API, SeoService, ServerResponseService, SiteBackendService, SsrLoadingService, TestComponent, TransferStateService, getSiteUrl, removeDuplicateObjectsFromArray, removeDuplicateValuesFromArray, removeHtmlTags, toQueryParams };
33479
+ export { AbstractModalComponent, AbstractModalDrawerComponent, AlgoliaService, CuraService, EnumDoencaTaxonomy, EnumDoencaTaxonomyCat, Estados, HttpClientService, IconCuraDefaultType, LIB_CONFIG, LogService, ModalDrawerService, ModalService, NguCarouselService, PhonePipe, PhoneService, REQUEST, RESPONSE, RdsiteLinkDirective, RdsiteModalComponentStyle, RdsiteModalDrawerComponentStyle, RdsitePhoneModalDirective, SSR_CURA_API, SeoService, ServerResponseService, SiteBackendService, SsrLoadingService, TestComponent, TransferStateService, getSiteUrl, removeDuplicateObjectsFromArray, removeDuplicateValuesFromArray, removeHtmlTags, toQueryParams };
33103
33480
  //# sourceMappingURL=rededor-site-front-end-lib.mjs.map