Files

128 lines
42 KiB
JavaScript
Raw Permalink Normal View History

2025-06-10 20:17:57 -04:00
(function(b,f){typeof exports=="object"&&typeof module<"u"?module.exports=f():typeof define=="function"&&define.amd?define(f):(b=typeof globalThis<"u"?globalThis:b||self,b["usa-banner"]=f())})(this,function(){"use strict";var Ie=Object.defineProperty;var We=(b,f,w)=>f in b?Ie(b,f,{enumerable:!0,configurable:!0,writable:!0,value:w}):b[f]=w;var G=(b,f,w)=>We(b,typeof f!="symbol"?f+"":f,w);/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/var me;const b=globalThis,f=b.ShadowRoot&&(b.ShadyCSS===void 0||b.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,w=Symbol(),Q=new WeakMap;let pe=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==w)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(f&&e===void 0){const n=t!==void 0&&t.length===1;n&&(e=Q.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Q.set(t,e))}return e}toString(){return this.cssText}};const I=r=>new pe(typeof r=="string"?r:r+"",void 0,w),_e=(r,e)=>{if(f)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const n=document.createElement("style"),a=b.litNonce;a!==void 0&&n.setAttribute("nonce",a),n.textContent=t.cssText,r.appendChild(n)}},Z=f?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return I(t)})(r):r;/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const{is:ge,defineProperty:ve,getOwnPropertyDescriptor:we,getOwnPropertyNames:$e,getOwnPropertySymbols:ye,getPrototypeOf:ke}=Object,p=globalThis,X=p.trustedTypes,xe=X?X.emptyScript:"",W=p.reactiveElementPolyfillSupport,E=(r,e)=>r,D={toAttribute(r,e){switch(e){case Boolean:r=r?xe:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Y=(r,e)=>!ge(r,e),ee={attribute:!0,type:String,converter:D,reflect:!1,useDefault:!1,hasChanged:Y};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),p.litPropertyMetadata??(p.litPropertyMetadata=new WeakMap);let A=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=ee){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const n=Symbol(),a=this.getPropertyDescriptor(e,n,t);a!==void 0&&ve(this.prototype,e,a)}}static getPropertyDescriptor(e,t,n){const{get:a,set:o}=we(this.prototype,e)??{get(){return this[t]},set(i){this[t]=i}};return{get:a,set(i){const l=a==null?void 0:a.call(this);o==null||o.call(this,i),this.requestUpdate(e,l,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??ee}static _$Ei(){if(this.hasOwnProperty(E("elementProperties")))return;const e=ke(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(E("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(E("properties"))){const t=this.properties,n=[...$e(t),...ye(t)];for(const a of n)this.createProperty(a,t[a])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[n,a]of t)this.elementProperties.set(n,a)}this._$Eh=new Map;for(const[t,n]of this.elementProperties){const a=this._$Eu(t,n);a!==void 0&&this._$Eh.set(a,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const a of n)t.unshift(Z(a))}else e!==void 0&&t.push(Z(e));return t}static _$Eu(e,t){const n=t.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return _e(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var n;return(n=t.hostConnected)==null?void 0:n.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var n;return(n=t.hostDisconnected)==null?void 0:n.call(t)})}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){var o;const n=this.constructor.elementProperties.get(e),a=this.constructor._$Eu(e,n);if(a!==void 0&&n.reflect===!0){const i=(((o=n.converter)==null?void 0:o.toAttribute)!==void 0?n.converter:D).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(a):this.setAttribute(a,i),this._$Em=null}}_$AK(e,t){var o,i;const n=this.constructor,a=n._$Eh.get(e);if(a!==
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const T=globalThis,R=T.trustedTypes,te=R?R.createPolicy("lit-html",{createHTML:r=>r}):void 0,ne="$lit$",_=`lit$${Math.random().toFixed(9).slice(2)}$`,ae="?"+_,Ae=`<${ae}>`,$=document,C=()=>$.createComment(""),M=r=>r===null||typeof r!="object"&&typeof r!="function",V=Array.isArray,Se=r=>V(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",q=`[
\f\r]`,z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,re=/-->/g,oe=/>/g,y=RegExp(`>|${q}(?:([^\\s"'>=/]+)(${q}*=${q}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),ie=/'/g,se=/"/g,le=/^(?:script|style|textarea|title)$/i,Ee=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),N=Ee(1),g=Symbol.for("lit-noChange"),d=Symbol.for("lit-nothing"),ce=new WeakMap,k=$.createTreeWalker($,129);function de(r,e){if(!V(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return te!==void 0?te.createHTML(e):e}const Te=(r,e)=>{const t=r.length-1,n=[];let a,o=e===2?"<svg>":e===3?"<math>":"",i=z;for(let l=0;l<t;l++){const s=r[l];let h,u,c=-1,m=0;for(;m<s.length&&(i.lastIndex=m,u=i.exec(s),u!==null);)m=i.lastIndex,i===z?u[1]==="!--"?i=re:u[1]!==void 0?i=oe:u[2]!==void 0?(le.test(u[2])&&(a=RegExp("</"+u[2],"g")),i=y):u[3]!==void 0&&(i=y):i===y?u[0]===">"?(i=a??z,c=-1):u[1]===void 0?c=-2:(c=i.lastIndex-u[2].length,h=u[1],i=u[3]===void 0?y:u[3]==='"'?se:ie):i===se||i===ie?i=y:i===re||i===oe?i=z:(i=y,a=void 0);const v=i===y&&r[l+1].startsWith("/>")?" ":"";o+=i===z?s+Ae:c>=0?(n.push(h),s.slice(0,c)+ne+s.slice(c)+_+v):s+_+(c===-2?l:v)}return[de(r,o+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]};class P{constructor({strings:e,_$litType$:t},n){let a;this.parts=[];let o=0,i=0;const l=e.length-1,s=this.parts,[h,u]=Te(e,t);if(this.el=P.createElement(h,n),k.currentNode=this.el.content,t===2||t===3){const c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(a=k.nextNode())!==null&&s.length<l;){if(a.nodeType===1){if(a.hasAttributes())for(const c of a.getAttributeNames())if(c.endsWith(ne)){const m=u[i++],v=a.getAttribute(c).split(_),j=/([.?@])?(.*)/.exec(m);s.push({type:1,index:o,name:j[2],strings:v,ctor:j[1]==="."?Me:j[1]==="?"?ze:j[1]==="@"?Pe:B}),a.removeAttribute(c)}else c.startsWith(_)&&(s.push({type:6,index:o}),a.removeAttribute(c));if(le.test(a.tagName)){const c=a.textContent.split(_),m=c.length-1;if(m>0){a.textContent=R?R.emptyScript:"";for(let v=0;v<m;v++)a.append(c[v],C()),k.nextNode(),s.push({type:2,index:++o});a.append(c[m],C())}}}else if(a.nodeType===8)if(a.data===ae)s.push({type:2,index:o});else{let c=-1;for(;(c=a.data.indexOf(_,c+1))!==-1;)s.push({type:7,index:o}),c+=_.length-1}o++}}static createElement(e,t){const n=$.createElement("template");return n.innerHTML=e,n}}function S(r,e,t=r,n){var i,l;if(e===g)return e;let a=n!==void 0?(i=t._$Co)==null?void 0:i[n]:t._$Cl;const o=M(e)?void 0:e._$litDirective$;return(a==null?void 0:a.constructor)!==o&&((l=a==null?void 0:a._$AO)==null||l.call(a,!1),o===void 0?a=void 0:(a=new o(r),a._$AT(r,t,n)),n!==void 0?(t._$Co??(t._$Co=[]))[n]=a:t._$Cl=a),a!==void 0&&(e=S(r,a._$AS(r,e.values),a,n)),e}class Ce{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:n}=this._$AD,a=((e==null?void 0:e.creationScope)??$).importNode(t,!0);k.currentNode=a;let o=k.nextNode(),i=0,l=0,s=n[0];for(;s!==void 0;){if(i===s.index){let h;s.type===2?h=new U(o,o.nextSibling,this,e):s.type===1?h=new s.ctor(o,s.name,s.strings,this,e):s.type===6&&(h=new Ue(o,this,e)),this._$AV.push(h),s=n[++l]}i!==(s==null?void 0:s.index)&&(o=k.nextNode(),i++)}return k.currentNode=$,a}p(e){let t=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class U{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,n,a){this.type=2,this._$AH=d,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=a,this._$Cv=(a==null?void 0:a.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=S(this,e,t),M(e)?e===d||e==null||e===""?(this._$AH!==d&&this._$AR(),this._$AH=d):e!==this._$AH&&e!==g&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Se(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==d&&M(this._$AH)?this._$AA.nextSibling.data=e
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const x=globalThis;let H=class extends A{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=He(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return g}};H._$litElement$=!0,H.finalized=!0,(me=x.litElementHydrateSupport)==null||me.call(x,{LitElement:H});const J=x.litElementPolyfillSupport;J==null||J({LitElement:H}),(x.litElementVersions??(x.litElementVersions=[])).push("4.2.0");/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const he={ATTRIBUTE:1,CHILD:2},ue=r=>(...e)=>({_$litDirective$:r,values:e});class fe{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/let K=class extends fe{constructor(e){if(super(e),this.it=d,e.type!==he.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===d||e==null)return this._t=void 0,this.it=e;if(e===g)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};K.directiveName="unsafeHTML",K.resultType=1;const be=ue(K);/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Oe=ue(class extends fe{constructor(r){var e;if(super(r),r.type!==he.ATTRIBUTE||r.name!=="class"||((e=r.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(r){return" "+Object.keys(r).filter(e=>r[e]).join(" ")+" "}update(r,[e]){var n,a;if(this.st===void 0){this.st=new Set,r.strings!==void 0&&(this.nt=new Set(r.strings.join(" ").split(/\s/).filter(o=>o!=="")));for(const o in e)e[o]&&!((n=this.nt)!=null&&n.has(o))&&this.st.add(o);return this.render(e)}const t=r.element.classList;for(const o of this.st)o in e||(t.remove(o),this.st.delete(o));for(const o in e){const i=!!e[o];i===this.st.has(o)||(a=this.nt)!=null&&a.has(o)||(i?(t.add(o),this.st.add(o)):(t.remove(o),this.st.delete(o)))}return g}}),Re='@font-face{font-family:Roboto Mono Web;font-style:normal;font-weight:300;font-display:fallback;src:url(../fonts/roboto-mono/roboto-mono-v5-latin-300.woff2) format("woff2")}@font-face{font-family:Roboto Mono Web;font-style:normal;font-weight:400;font-display:fallback;src:url(../fonts/roboto-mono/roboto-mono-v5-latin-regular.woff2) format("woff2")}@font-face{font-family:Roboto Mono Web;font-style:normal;font-weight:700;font-display:fallback;src:url(../fonts/roboto-mono/roboto-mono-v5-latin-700.woff2) format("woff2")}@font-face{font-family:Roboto Mono Web;font-style:italic;font-weight:300;font-display:fallback;src:url(../fonts/roboto-mono/roboto-mono-v5-latin-300italic.woff2) format("woff2")}@font-face{font-family:Roboto Mono Web;font-style:italic;font-weight:400;font-display:fallback;src:url(../fonts/roboto-mono/roboto-mono-v5-latin-italic.woff2) format("woff2")}@font-face{font-family:Roboto Mono Web;font-style:italic;font-weight:700;font-display:fallback;src:url(../fonts/roboto-mono/roboto-mono-v5-latin-700italic.woff2) format("woff2")}@font-face{font-family:Source Sans Pro Web;font-style:normal;font-weight:300;font-display:fallback;src:url(../fonts/source-sans-pro/sourcesanspro-light-webfont.woff2) format("woff2")}@font-face{font-family:Source Sans Pro Web;font-style:normal;font-weight:400;font-display:fallback;src:url(../fonts/source-sans-pro/sourcesanspro-regular-webfont.woff2) format("woff2")}@font-face{font-family:Source Sans Pro Web;font-style:normal;font-weight:700;font-display:fallback;src:url(../fonts/source-sans-pro/sourcesanspro-bold-webfont.woff2) format("woff2")}@font-face{font-family:Source Sans Pro Web;font-style:italic;font-weight:300;font-display:fallback;src:url(../fonts/source-sans-pro/sourcesanspro-lightitalic-webfont.woff2) format("woff2")}@font-face{font-family:Source Sans Pro Web;font-style:italic;font-weight:400;font-display:fallback;src:url(../fonts/source-sans-pro/sourcesanspro-italic-webfont.woff2) format("woff2")}@font-face{font-family:Source Sans Pro Web;font-style:italic;font-weight:700;font-display:fallback;src:url(../fonts/source-sans-pro/sourcesanspro-bolditalic-webfont.woff2) format("woff2")}@font-face{font-family:Merriweather Web;font-style:normal;font-weight:300;font-display:fallback;src:url(../fonts/merriweather/Latin-Merriweather-Light.woff2) format("woff2")}@font-face{font-family:Merriweather Web;font-style:normal;font-weight:400;font-display:fallback;src:url(../fonts/merriweather/Latin-Merriweather-Regular.woff2) format("woff2")}@font-face{font-family:Merriweather Web;font-style:normal;font-weight:700;font-display:fallback;src:url(../fonts/merriweather/Latin-Merriweather-Bold.woff2) format("woff2")}@font-face{font-family:Merriweather Web;font-style:italic;font-weight:300;font-display:fallback;src:url(../fonts/merriweather/Latin-Merriweather-LightItalic.woff2) format("woff2")}@font-face{font-family:Merriweather Web;font-style:italic;font-weight:400;font-display:fallback;src:url(../fonts/merriweather/Latin-Merriweather-Italic.woff2) format("woff2")}@font-face{font-family:Merriweather Web;font-style:italic;font-weight:700;font-display:fallback;src:url(../fonts/merriweather/Latin-Merriweather-BoldItalic.woff2) format("woff2")}.usa-media-block{align-items:flex-start;display:flex}.usa-me
<img
class="usa-banner__icon usa-media-block__img"
src="${Le}"
role="img"
alt=""
aria-hidden="true"
/>
<div class="usa-media-block__body">
<p>
<strong>
<slot name="domain-heading"> ${t.heading} .${e} </slot>
</strong>
<br />
<slot name="domain-text">
${t.text1} <strong>.${e}</strong> ${t.text2}
</slot>
</p>
</div>
`}static lockIcon(){return N`
<span
class="usa-banner__icon-lock"
role="img"
aria-label="Locked padlock icon"
part="lock-icon"
></span>
`}httpsTemplate(e){const{https:t}=this._bannerText;return N`
<img
class="usa-banner__icon usa-media-block__img"
src="${je}"
role="img"
alt=""
aria-hidden="true"
/>
<div class="usa-media-block__body">
<p>
<strong>
<slot name="https-heading">
${t.heading1} .${e} ${t.heading2}
</slot> </strong
><br />
<slot name="https-text">
${be(t.text1)} (${O.lockIcon()})
${be(t.text2)} .${e} ${t.text3}
</slot>
</p>
</div>
`}render(){const e={"usa-banner__header--expanded":this.isOpen},t=this.tld==="mil"?"mil":"gov",{banner:n}=this._bannerText;return N`
<section class="usa-banner" aria-label=${this.label||n.label}>
<div class="usa-accordion">
<header class="usa-banner__header ${Oe(e)}">
<div class="usa-banner__inner">
<div class="grid-col-auto">
<img
aria-hidden="true"
class="usa-banner__header-flag"
src=${Be}
alt=""
/>
</div>
<div
class="grid-col-fill tablet:grid-col-auto"
aria-hidden="true"
>
<p class="usa-banner__header-text">
<slot name="banner-text">${n.text}</slot>
</p>
<p class="usa-banner__header-action">
<slot name="banner-action">${n.action}</slot>
</p>
</div>
<button
type="button"
class="usa-accordion__button usa-banner__button"
aria-expanded="${this.isOpen}"
aria-controls="gov-banner-default"
@click="${this.toggle}"
>
<span class="usa-banner__button-text">
${this._actionText||n.action}
</span>
</button>
</div>
</header>
<div class="usa-banner__content usa-accordion__content" hidden>
<div class="grid-row grid-gap-lg">
<div class="usa-banner__guidance tablet:grid-col-6">
${this.domainTemplate(t)}
</div>
<div class="usa-banner__guidance tablet:grid-col-6">
${this.httpsTemplate(t)}
</div>
</div>
</div>
</div>
</section>
`}};G(O,"properties",{lang:{type:String,reflect:!0},data:{attribute:!1},isOpen:{type:Boolean},classes:{},label:{type:String},tld:{type:String,reflect:!0}}),G(O,"styles",[I(Re),I(Ne)]);let L=O;return customElements.define("usa-banner",L),L});