{"version":3,"file":"score-button.js","sources":["../../../../src/components/score/score-button/score-button.ts"],"sourcesContent":["import { CSSResultGroup, TemplateResult, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { OutlineButton } from '../../base/outline-button/outline-button';\nimport { SlotController } from '../../controllers/slot-controller';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport componentStyles from './score-button.css.lit';\nimport { isExternalLink, isMessageRequired, isOmittedDomain } from '../../../utilities/external-links'; \n\nexport type ScoreButtonVariant =\n | 'primary'\n | 'secondary'\n | 'login'\n | 'signup'\n | 'filter';\n\n/**\n * The Score Button component\n * @element score-button\n *\n */\n\n@customElement('score-button')\nexport class ScoreButton extends OutlineButton {\n slots = new SlotController(\n this, // This, the host element.\n true // To shift or not to shift LightDom nodes to ShadowDOM.\n );\n static styles: CSSResultGroup = [componentStyles];\n @property({ type: String, attribute: 'sr-only' }) srOnly: string;\n @property({ type: Boolean, attribute: 'is-modal-action' }) isModalAction: boolean;\n @property({ type: String, attribute: 'rel-text' }) relText: string;\n\n render(): TemplateResult {\n const isModalAction = this.isModalAction ? true : false;\n let buttonUrl = this.buttonUrl ? String(this.buttonUrl) : '';\n let buttonTarget = this.buttonTarget ? String(this.buttonTarget) : undefined;\n let isLinkExternal: boolean = isExternalLink(buttonUrl);\n let isLinkOmitted: boolean = isOmittedDomain(buttonUrl);\n // External links should open in the new tab.\n if (isLinkExternal && !isLinkOmitted) {\n buttonTarget = '_blank';\n }\n \n if (isMessageRequired(buttonUrl) && !isModalAction && !isLinkOmitted) {\n // Call the modal in the score_content module.\n // To preserve the external link URL value within the\n // external modal, encode the URL prior to passing to the external modal.\n // When using javascript as an href, web browsers will automatically decode the value\n // which leads to the scoreContentCallModal receiving a decoded URL value.\n // Encoding the URL again before passing to the javascript call ensures any existing encoded\n // characters in the URL are preserved in the scoreContentCallModal once the web browser decodes\n // the value.\n buttonUrl = 'javascript:scoreContentCallModal(\"' + encodeURIComponent(buttonUrl) + '\")';\n buttonTarget = '_self';\n }\n return this.buttonUrl\n ? html` \n ${this.iconTemplate(this.hasLeftIcon, 'left')}\n \n ${this.iconTemplate(this.hasRightIcon, 'right')} ${this.hasSrOnly()}\n `\n : html`\n ${this.iconTemplate(this.hasLeftIcon, 'left')}\n \n ${this.iconTemplate(this.hasRightIcon, 'right')} ${this.hasSrOnly()}\n `;\n }\n hasSrOnly() {\n return this.srOnly\n ? html`${this.srOnly} `\n : undefined;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'score-button': ScoreButton;\n }\n}\n"],"names":["ScoreButton","OutlineButton","constructor","this","slots","SlotController","render","isModalAction","buttonUrl","String","buttonTarget","undefined","isLinkExternal","isExternalLink","isLinkOmitted","isOmittedDomain","isMessageRequired","encodeURIComponent","html","buttonVariant","buttonSize","ifDefined","buttonLabel","isDisabled","relText","iconTemplate","hasLeftIcon","hasRightIcon","hasSrOnly","onClick","onKeyUp","srOnly","styles","componentStyles","__decorate","property","type","attribute","prototype","Boolean","customElement"],"mappings":"glCAsBO,IAAMA,EAAN,cAA0BC,EAA1BC,kCACLC,KAAAC,MAAQ,IAAIC,EACVF,MACA,EA4DH,CArDCG,SACE,MAAMC,IAAgBJ,KAAKI,cAC3B,IAAIC,EAAYL,KAAKK,UAAYC,OAAON,KAAKK,WAAa,GACtDE,EAAeP,KAAKO,aAAeD,OAAON,KAAKO,mBAAgBC,EAC/DC,EAA0BC,EAAeL,GACzCM,EAAyBC,EAAgBP,GAkB7C,OAhBII,IAAmBE,IACrBJ,EAAe,WAGbM,EAAkBR,IAAeD,GAAkBO,IASrDN,EAAY,qCAAuCS,mBAAmBT,GAAa,KACnFE,EAAe,SAEVP,KAAKK,UACRU,CAAI;uBACWf,KAAKgB,iBAAiBhB,KAAKiB;iBACjCZ;mBACEa,EAAUX;wBACLW,EAAUlB,KAAKmB;2BACZD,EAAUlB,KAAKoB;iBACzBF,EAAUlB,KAAKqB;;YAEpBrB,KAAKsB,aAAatB,KAAKuB,YAAa;;YAEpCv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