@taprootio/espalier 7.1.1 → 7.2.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.
- package/CHANGELOG.md +9 -0
- package/custom-elements.json +8073 -5734
- package/dist/button/paint-registration.js +1 -0
- package/dist/cli/theme-check.js +2 -2
- package/dist/footer/paint-registration.js +1 -0
- package/dist/header/esp-header-button.js +6 -2
- package/dist/header/esp-header.js +8 -4
- package/dist/header/header-geometry-controller.js +1 -1
- package/dist/header/is-tall-header-paint.d.ts +7 -0
- package/dist/header/is-tall-header-paint.js +1 -0
- package/dist/header/paint-registration.js +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/menu/esp-menu-group.js +8 -8
- package/dist/menu/esp-menu-item.js +8 -8
- package/dist/menu/esp-menu.js +10 -6
- package/dist/menu/navigation-focus-outline.js +8 -0
- package/dist/menu/navigation-paint.js +1 -0
- package/dist/menu/paint-registration.js +1 -0
- package/dist/shared/color-engine.js +1 -1
- package/dist/shared/composed-dom.js +1 -0
- package/dist/shared/configured-brand-color.js +1 -0
- package/dist/shared/configured-brand.js +5 -5
- package/dist/shared/css-named-colors.js +1 -0
- package/dist/shared/paint-catalog.d.ts +27 -0
- package/dist/shared/paint-catalog.js +1 -0
- package/dist/shared/paint-color.d.ts +25 -0
- package/dist/shared/paint-color.js +1 -0
- package/dist/shared/paint-fit.js +1 -0
- package/dist/shared/paint-identity.js +1 -0
- package/dist/shared/paint-types.d.ts +88 -0
- package/dist/shared/paint-types.js +0 -0
- package/dist/shared/theme-fit-report.d.ts +10 -2
- package/dist/shared/theme-fit-report.js +1 -1
- package/dist/shared/theme.d.ts +3 -24
- package/dist/shared/theme.js +1 -1
- package/dist/shared/token-pairings.d.ts +25 -0
- package/dist/shared/token-pairings.js +1 -0
- package/dist/shared/wcag-contrast.d.ts +14 -0
- package/dist/shared/wcag-contrast.js +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/observe-paint.d.ts +29 -0
- package/dist/testing/observe-paint.iife.js +3 -0
- package/dist/testing/observe-paint.js +3 -0
- package/dist/testing/paint-bands.js +1 -0
- package/dist/testing/paint-coverage.d.ts +14 -0
- package/dist/testing/paint-coverage.js +1 -0
- package/dist/testing/paint-dom.js +1 -0
- package/dist/testing/svg-paint.js +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PAINT_INTERACTIONS as I,closestPaintElement as d,isPaintFocus as C,navigationPaintFlags as S,navigationPaintPlacement as y,navigationPaintState as g}from"../menu/navigation-paint.js";import{derivePaintLightness as v,parsePaintColor as p}from"../shared/paint-color.js";import{TOKEN_PAIRINGS as A}from"../shared/token-pairings.js";import{BUTTON_INTERACTION_LIGHTNESS_FACTOR as B}from"./action-state-lightness.js";const h="action-interaction-fill",b="button-focus-shadow",k=A.actionText.bg,P=({element:t,source:o})=>{const r=o==="fill"||o==="stroke";if(o!=="text"&&o!=="shadow"&&!r)return;const n=d(t,"[part=wrapper].esp-field:not(.incognito)"),e=n&&d(n,"esp-button"),c=n?.querySelector(":scope > [part=control]");if(!n||!e||!c||o==="shadow"&&t!==n||o==="text"&&!d(t,"[part=label]"))return;const l=d(e,"esp-menu-item"),f=!l&&d(e,"esp-footer");if(!(l&&d(e,"esp-header"))&&!f)return;const i=l?y(e):"inline",u=c.matches("[aria-current=page]"),a=c.matches("button:disabled"),s=!a&&n.matches(":hover"),m=!a&&n.matches(":focus-within"),x=s||m,N=u?s?"current-hover":"current":m?s?"hover-focus":"focus":s?"hover":"rest",w=f?"footer-action-button":"nav-button";return{element:r?`${w}-icon`:w,owner:c,state:()=>g(i,N),...o==="shadow"?{foregroundDerivations:[b],foregroundAliases:["shadow"]}:x?{backgroundDerivations:[h]}:{}}};function T(t,o=!1){const r=o?["footerActionButton"]:S(t),n=o?void 0:{kind:"button",...t==="inline"?{depth:"top-level"}:t==="inline-panel"?{depth:"nested"}:{}},e=o?"footer-action-button":"nav-button",c=o?[...r,"footerActionIcon"]:r,l=t==="inline"?"layer2":"layer1",f=I.flatMap(i=>{const u=g(t,i),a={element:e,foreground:"actionText",background:i==="rest"?k:h,state:u,kind:"text",flags:r,...n?{navigation:n}:{}},s={...a,element:`${e}-icon`,kind:"graphic",flags:c,...n?{navigation:{...n,icon:!0}}:{}};return C(i)?[a,s,{...a,foreground:b,background:l,kind:"ring",indicator:"blurred-shadow"}]:[a,s]});if(n)for(const i of["current","current-hover"]){const u={element:e,foreground:"actionText",background:i==="current"?k:h,state:g(t,i),kind:"text",flags:r,navigation:{...n,canBeCurrent:!0}};f.push(u,{...u,element:`${e}-icon`,kind:"graphic",navigation:{...n,canBeCurrent:!0,icon:!0}})}return f}const O={entriesByRole:{header:["inline","inline-panel","panel","full-screen"].flatMap(t=>T(t)),footer:T("inline",!0)},targets:{header:[P],footer:[P]},derivations:{[h]:t=>v(t.readColor("actionBackground"),o=>o*B),[b]:t=>{const o=t.readProperty("--esp-field-focus-shadow");if(o)return p(o);if(t.scheme==="light")return p(t.readColor("shadow")??"");const r=t.readProperty("--_esp-context-shadow");if(r)return p(r);const n=t.readProperty("--esp-l-ink")?.trim(),e=n?.endsWith("%")?Number(n.slice(0,-1))/100:Number(n);return n&&Number.isFinite(e)?v(t.readColor("primary"),()=>e):null}}};export{O as buttonPaintRegistration};
|
package/dist/cli/theme-check.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{encodeTheme as D,isObjectRecord as
|
|
2
|
-
`)}catch(c){return t.error(`Cannot write ${e.updateExpect}: ${c instanceof Error?c.message:String(c)}`),2}i(`Wrote fit tables to ${e.updateExpect}.`)}if(e.expect!==void 0){let c;try{c=t.readFile(e.expect)}catch{return t.error(`Expected fit tables not found at ${e.expect} \u2014 create them with --update-expect ${e.expect}.`),2}let a;try{a=JSON.parse(c)}catch{return t.error(`${e.expect} is not JSON.`),2}if(!ie(a))return t.error(`${e.expect} is not a fit-table suite \u2014 regenerate it with --update-expect ${e.expect}.`),2;const f=le(a,n);if(f.length>0){s>0&&xe(n,s,t);for(const u of f)t.error(`drift: ${u}`);return t.error(`Fit tables drifted from ${e.expect} (${f.length} difference(s)). Review, then refresh deliberately with --update-expect.`),1}i(`Fit tables match ${e.expect}.`)}return e.json?(t.log(JSON.stringify(n,null,2)),s>0?1:0):(Ie(n,s,t),s>0?1:0)}function ie(e){if(!l(e)||!k.every(({field:r,kind:o})=>T(e[String(r)],o)))return!1;const t=e;if(!w(t.surfaces))return!1;for(const r of["light","dark"]){const n=t.paletteLints[r].map(h);if(!w(n))return!1;const s=t[r],i=new Set;for(const c of s){if(!pe(c,r)||!t.surfaces.includes(c.surface)||i.has(c.surface))return!1;i.add(c.surface)}}return!0}function se(e){return typeof e=="number"&&Number.isFinite(e)}function ce(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function w(e){return new Set(e).size===e.length}function ae(e){return l(e)&&M.every(({field:t,kind:r})=>T(e[String(t)],r))}function fe(e){return l(e)&&R.every(({field:t,kind:r})=>T(e[String(t)],r))}function ue(e){return l(e)&&I.every(({field:t,kind:r})=>T(e[String(t)],r))}function T(e,t){switch(t){case"anchor":return e===void 0||H(e,N);case"anchor-record":return l(e)&&Object.keys(e).every(te)&&Object.values(e).every(r=>typeof r=="string");case"apca":return e===void 0||H(e,C);case"boolean":return typeof e=="boolean";case"data-palette-record":return l(e)?["light","dark"].every(r=>{const o=e[r];return l(o)&&x.every(n=>typeof o[n]=="string")}):!1;case"explicit":return e===void 0||X.includes(e);case"fit-lint-id":return Y.includes(e);case"lint-array":return Array.isArray(e)&&e.every(fe);case"message":case"string":return typeof e=="string";case"number":return se(e);case"pairing":return e===void 0||Q.includes(e);case"palette-lint-id":return G.includes(e);case"palette-lint-record":return l(e)&&["light","dark"].every(r=>Array.isArray(e[r])&&e[r].every(ae));case"report-array":return Array.isArray(e);case"scheme":return e==="light"||e==="dark";case"semantic":return P(e);case"semantic-array":return Array.isArray(e)&&e.every(P);case"series-pair":return de(e);case"simulation":return v.includes(e);case"string-array":return ce(e);case"token-array":return Array.isArray(e)&&e.every(ue);case"warning":return B.includes(e);default:{const r=t;return!1}}}function H(e,t){return l(e)&&t.every(({field:r,kind:o})=>T(e[String(r)],o))}function de(e){if(!Array.isArray(e)||e.length!==2)return!1;const t=x.indexOf(e[0]),r=x.indexOf(e[1]);return t>=0&&r>t}function pe(e,t){if(!l(e)||!_.every(({field:o,kind:n})=>T(e[String(o)],n)))return!1;const r=e;return r.scheme!==t?!1:w(r.tokens.map(o=>o.token))&&w(r.adjustedTokens)&&w(r.lints.map(o=>o.id))}function le(e,t){const r=[];for(const n of k)n.compared&&me(r,n,e,t);return(g(W(e))!==g(W(t))||r.length===0&&g(e)!==g(t))&&r.push("fit tables differ outside compared fields"),r}function me(e,t,r,o){const{field:n,kind:s}=t;if(s==="string-array"){const i=r[n],c=o[n];U(e,String(n),i,c),E(e,String(n),i,c);return}if(s==="data-palette-record"){const i=r[n],c=o[n];for(const a of["light","dark"])for(const f of x)J(e,`${a}/${String(n)}/${f}`,i[a][f],c[a][f]);return}if(s==="palette-lint-record"){const i=r[n],c=o[n];for(const a of["light","dark"])ke(e,a,String(n),i[a],c[a]),E(e,`${a}/${String(n)}`,i[a].map(h),c[a].map(h));return}if(s==="report-array"&&(n==="light"||n==="dark")){ge(e,n,r[n],o[n]);return}F(e,"fit tables",String(n),r[n],o[n],s)}function ge(e,t,r,o){const n=new Map(r.map(i=>[i.surface,i])),s=new Map(o.map(i=>[i.surface,i]));E(e,`${t}/reports`,r.map(i=>i.surface),o.map(i=>i.surface));for(const i of L(n.keys(),s.keys())){const c=n.get(i),a=s.get(i),f=`${t}/${i}`;if(!c||!a){e.push(`${f}: surface ${c?"removed":"added"}`);continue}he(e,f,c,a)}}function he(e,t,r,o){for(const n of _){const{compared:s,field:i,kind:c}=n;if(!(!s||i==="scheme"||i==="surface")){if(c==="anchor-record"){Te(e,`${t}/${String(i)}`,r[i],o[i]);continue}if(c==="semantic-array"){const a=r[i],f=o[i];U(e,`${t}/${String(i)}`,a,f),E(e,`${t}/${String(i)}`,a,f);continue}if(c==="lint-array"){const a=r[i],f=o[i];Se(e,t,String(i),a,f),E(e,`${t}/${String(i)}`,a.map(u=>u.id),f.map(u=>u.id));continue}if(c==="token-array"){$e(e,t,String(i),r[i],o[i]);continue}F(e,t,String(i),r[i],o[i],c)}}}function $e(e,t,r,o,n){const s=new Map(o.map(a=>[a.token,a])),i=new Map(n.map(a=>[a.token,a]));E(e,`${t}/${r}`,o.map(a=>a.token),n.map(a=>a.token));const c=r==="tokens"?t:`${t}/${r}`;for(const a of L(s.keys(),i.keys())){const f=s.get(a),u=i.get(a),S=`${c}/${a}`;if(!f||!u){e.push(`${S}: token ${f?"removed":"added"}`);continue}ye(e,S,f,u)}}function ye(e,t,r,o){for(const{compared:n,field:s,kind:i}of I)if(!(!n||s==="token")){if(i==="anchor"){V(e,t,"anchor",r.anchor,o.anchor,N);continue}if(i==="apca"){V(e,t,"apca",r.apca,o.apca,C);continue}F(e,t,String(s),r[s],o[s],i)}}function V(e,t,r,o,n,s){const i=o,c=n;for(const{compared:a,field:f,kind:u}of s)a&&F(e,t,`${r}.${String(f)}`,i?.[f],c?.[f],u)}function Se(e,t,r,o,n){const s=new Map(o.map(c=>[c.id,c])),i=new Map(n.map(c=>[c.id,c]));for(const c of L(s.keys(),i.keys())){const a=s.get(c),f=i.get(c),u=`${t}/${r}/${c}`;if(!a||!f){e.push(`${u}: lint ${a?"removed":"added"}`);continue}for(const{compared:S,field:d,kind:b}of R)if(!(!S||d==="id")){if(b==="semantic-array"){Ee(e,u,String(d),a[d],f[d]);continue}F(e,u,String(d),a[d],f[d],b)}}}function ke(e,t,r,o,n){const s=new Map(o.map(c=>[h(c),c])),i=new Map(n.map(c=>[h(c),c]));for(const c of L(s.keys(),i.keys())){const a=s.get(c),f=i.get(c),u=`${t}/${r}/${c}`;if(!a||!f){e.push(`${u}: lint ${a?"removed":"added"}`);continue}for(const{compared:S,field:d,kind:b}of M)!S||d==="id"||d==="series"||d==="simulation"||F(e,u,String(d),a[d],f[d],b)}}function h(e){return`${e.id}/${e.series[0]}+${e.series[1]}/${e.simulation}`}function Te(e,t,r,o){for(const n of L(Object.keys(r),Object.keys(o)))J(e,`${t}/${n}`,r[n],o[n])}function U(e,t,r,o){const n=new Set(r),s=new Set(o);for(const i of L(n,s))n.has(i)!==s.has(i)&&e.push(`${t}/${i}: ${n.has(i)?"removed":"added"}`)}function E(e,t,r,o){const n=new Set(r),s=new Set(o),i=r.filter(a=>s.has(a)),c=o.filter(a=>n.has(a));i.some((a,f)=>a!==c[f])&&e.push(`${t}: order changed`)}function Ee(e,t,r,o,n){const s=Math.max(o.length,n.length);for(let i=0;i<s;i+=1)K(e,t,`${r}[${i}]`,o[i],n[i])}function J(e,t,r,o){r!==o&&e.push(`${t}: ${j(r)} \u2192 ${j(o)}`)}function K(e,t,r,o,n,s){if(!Object.is(o,n)){if(s==="message"){e.push(`${t}: message changed`);return}e.push(`${t}: ${r} ${j(o)} \u2192 ${j(n)}`)}}function Fe(e,t,r,o,n){g(o)!==g(n)&&e.push(`${t}: ${r} changed`)}function F(e,t,r,o,n,s){if(_e(s)){K(e,t,r,o,n,s);return}Fe(e,t,r,o,n)}const Le={anchor:!1,"anchor-record":!1,apca:!1,boolean:!0,"data-palette-record":!1,explicit:!0,"fit-lint-id":!0,"lint-array":!1,message:!0,number:!0,pairing:!0,"palette-lint-id":!0,"palette-lint-record":!1,"report-array":!1,scheme:!0,semantic:!0,"semantic-array":!1,"series-pair":!1,simulation:!0,string:!0,"string-array":!1,"token-array":!1,warning:!0};function _e(e){return Le[e]===!0}function j(e){return e===void 0?"(absent)":e===""?'""':String(e)}function L(e,t){return[...new Set([...e,...t])].sort()}function g(e){return Array.isArray(e)?`[${e.map(g).join(",")}]`:l(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${g(e[t])}`).join(",")}}`:JSON.stringify(e)??"undefined"}function W(e){const t=m(e,$(k)),r=["light","dark"];if(y(k,"dataPalette")){const o=m(e.dataPalette,r);for(const n of r)p(o,n,m(e.dataPalette[n],x));p(t,"dataPalette",o)}if(y(k,"paletteLints")){const o=m(e.paletteLints,r);for(const n of r)p(o,n,z(e.paletteLints[n],h,$(M)));p(t,"paletteLints",o)}for(const o of r){if(!y(k,o))continue;const n=O();for(const s of e[o]){const i=m(s,$(_));if(y(_,"tokens")){const c=O();for(const a of s.tokens){const f=m(a,$(I));a.anchor&&y(I,"anchor")&&p(f,"anchor",m(a.anchor,$(N))),a.apca&&y(I,"apca")&&p(f,"apca",m(a.apca,$(C))),p(c,a.token,f)}p(i,"tokens",c)}y(_,"lints")&&p(i,"lints",z(s.lints,c=>c.id,$(R))),p(n,s.surface,i)}p(t,o,n)}return t}function z(e,t,r){const o=O();for(const n of e)p(o,t(n),m(n,r));return o}function $(e){return e.filter(({compared:t})=>t).map(({field:t})=>t)}function y(e,t){return e.some(r=>r.field===t&&r.compared)}function m(e,t){const r=new Set(t.map(String)),o=O();for(const[n,s]of Object.entries(e))r.has(n)||(o[n]=s);return o}function O(){return Object.create(null)}function p(e,t,r){Object.keys(r).length>0&&(e[t]=r)}function Ie(e,t,r){for(const o of["light","dark"]){for(const n of e.paletteLints[o])r.log(` ${o} lint(${n.id}): ${n.message}`);for(const n of e[o]){r.log(be(o,n));for(const s of n.lints)r.log(` lint(${s.id}): ${s.message}`)}}r.log(`Checked ${e.surfaces.length} surface(s) \xD7 2 schemes \u2014 `+(t===0?"no lints.":`${t} lint(s), listed above.`))}function xe(e,t,r){r.error(`${t} theme lint(s) are standing while fit-table drift is present:`);for(const o of["light","dark"]){for(const n of e.paletteLints[o])r.error(`lint: ${o}/paletteLints/${h(n)}: ${n.message}`);for(const n of e[o])for(const s of n.lints)r.error(`lint: ${o}/${n.surface}/lints/${s.id}: ${s.message}`)}}function Ae(e){return[...e.light,...e.dark].reduce((r,o)=>r+o.lints.length,0)+e.paletteLints.light.length+e.paletteLints.dark.length}function we(e,t){return["light","dark"].some(r=>{const o=`${r}: `;if(!e.startsWith(o))return!1;const n=e.slice(o.length);return t.paletteLints[r].some(s=>ee(n,s))})}function be(e,t){const r=t.adjustedTokens.length===0?"contrast enforcement moved nothing":`contrast enforcement moved ${t.adjustedTokens.join(", ")}`,o=t.tokens.filter(s=>s.explicit==="inherited").length,n=o===0?"":`; ${o} inherited explicit pin(s) \u2014 see the fit tables`;return`${e}/${t.surface}: ${t.tokens.length} tokens, ${r}${n}.`}export{Me as runEspalierCli};
|
|
1
|
+
import{encodeTheme as D,isObjectRecord as p,isSemanticColorName as H,validateThemePair as X}from"../shared/theme.js";import{THEME_FIT_ANCHOR_FIELDS as P,THEME_FIT_APCA_FIELDS as R,THEME_FIT_DATA_PALETTE_LINT_FIELDS as C,THEME_FIT_DATA_PALETTE_LINT_IDS as Y,THEME_FIT_EXPLICIT_VALUES as B,THEME_FIT_LINT_FIELDS as M,THEME_FIT_LINT_IDS as Q,THEME_FIT_LINT_SEVERITIES as Z,THEME_FIT_PAIRING_VALUES as v,THEME_FIT_REPORT_FIELDS as A,THEME_FIT_SUITE_FIELDS as k,THEME_FIT_TOKEN_FIELDS as x,themeFitReportSuite as ee}from"../shared/theme-fit-report.js";import{COLOR_VISION_SIMULATIONS as te,DATA_SERIES_KEYS as I,isPaletteCollisionDescription as re}from"../shared/data-colors.js";import{isPaintKind as ne,isPaintName as T}from"../shared/paint-catalog.js";import{paintRequiredRatio as ie}from"../shared/paint-color.js";import{isSafeKey as oe}from"../shared/unsafe-keys.js";const w="usage: espalier theme check <theme.json> [--json] [--expect <fit.json>] [--update-expect <fit.json>]";function Je(e,t){const[r,i,...n]=e;if(r!=="theme"||i!=="check")return t.error(w),2;const s=se(n,t);return s?ae(s,t):2}function se(e,t){const r={file:"",json:!1};for(let i=0;i<e.length;i+=1){const n=e[i];if(n==="--json")r.json=!0;else if(n==="--expect"||n==="--update-expect"){const s=e[i+1];if(s===void 0)return t.error(`${n} requires a file path. ${w}`),null;n==="--expect"?r.expect=s:r.updateExpect=s,i+=1}else if(!n.startsWith("--")&&r.file==="")r.file=n;else return t.error(`Unknown argument "${n}". ${w}`),null}return r.file===""?(t.error(w),null):r.expect!==void 0&&r.updateExpect!==void 0?(t.error(`--expect checks the committed fit tables and --update-expect rewrites them \u2014 pick one. ${w}`),null):r}function ce(e,t){let r;try{r=t.readFile(e)}catch(s){return t.error(`Cannot read ${e}: ${s instanceof Error?s.message:String(s)}`),null}let i;try{i=JSON.parse(r)}catch(s){return t.error(`${e} is not JSON: ${s instanceof Error?s.message:String(s)}`),null}if(typeof i!="object"||i===null||Array.isArray(i))return t.error(`${e} must contain a theme object.`),null;const n=i;if("light"in n||"dark"in n){for(const s of["light","dark"]){const o=n[s];if(o!==void 0&&(typeof o!="object"||o===null||Array.isArray(o)))return t.error(`${e}: "${s}" must be a theme object.`),null}return{light:n.light??{},dark:n.dark??{}}}return{light:n,dark:n}}function ae(e,t){const r=ce(e.file,t);if(!r)return 2;const i=X(D(r.light),D(r.dark));if(!i.valid){for(const c of i.warnings)t.error(`warning: ${c}`);for(const c of i.errors)t.error(`error: ${c}`);return t.error(`${e.file}: ${i.errors.length} validation error(s).`),1}const n=ee(r.light,r.dark);for(const c of i.warnings)Pe(c,n)||t.error(`warning: ${c}`);const s=Ne(n),o=e.json?t.error:t.log;if(e.updateExpect!==void 0){try{t.writeFile(e.updateExpect,`${JSON.stringify(n,null,2)}
|
|
2
|
+
`)}catch(c){return t.error(`Cannot write ${e.updateExpect}: ${c instanceof Error?c.message:String(c)}`),2}o(`Wrote fit tables to ${e.updateExpect}.`)}if(e.expect!==void 0){let c;try{c=t.readFile(e.expect)}catch{return t.error(`Expected fit tables not found at ${e.expect} \u2014 create them with --update-expect ${e.expect}.`),2}let a;try{a=JSON.parse(c)}catch{return t.error(`${e.expect} is not JSON.`),2}if(!fe(a))return t.error(`${e.expect} is not a fit-table suite \u2014 regenerate it with --update-expect ${e.expect}.`),2;const f=ye(a,n);if(f.length>0){s>0&&Oe(n,s,t);for(const u of f)t.error(`drift: ${u}`);return t.error(`Fit tables drifted from ${e.expect} (${f.length} difference(s)). Review, then refresh deliberately with --update-expect.`),1}o(`Fit tables match ${e.expect}.`)}return e.json?(t.log(JSON.stringify(n,null,2)),s>0?1:0):(je(n,s,t),s>0?1:0)}function fe(e){if(!p(e)||!k.every(({field:r,kind:i})=>E(e[String(r)],i)))return!1;const t=e;if(!b(t.surfaces))return!1;for(const r of["light","dark"]){const n=t.paletteLints[r].map(h);if(!b(n))return!1;const s=t[r],o=new Set;for(const c of s){if(!$e(c,r)||!t.surfaces.includes(c.surface)||o.has(c.surface))return!1;o.add(c.surface)}}return!0}function V(e){return typeof e=="number"&&Number.isFinite(e)}function ue(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function b(e){return new Set(e).size===e.length}function de(e){return p(e)&&C.every(({field:t,kind:r})=>E(e[String(t)],r))}function pe(e){return p(e)&&M.every(({field:t,kind:r})=>E(e[String(t)],r))}function le(e){return p(e)&&x.every(({field:t,kind:r})=>E(e[String(t)],r))}function E(e,t){switch(t){case"anchor":return e===void 0||U(e,P);case"anchor-record":return p(e)&&Object.keys(e).every(oe)&&Object.values(e).every(r=>typeof r=="string");case"apca":return e===void 0||U(e,R);case"boolean":return typeof e=="boolean";case"data-palette-record":return p(e)?["light","dark"].every(r=>{const i=e[r];return p(i)&&I.every(n=>typeof i[n]=="string")}):!1;case"explicit":return e===void 0||B.includes(e);case"fit-lint-id":return Q.includes(e);case"lint-array":return Array.isArray(e)&&e.every(pe);case"message":case"string":return typeof e=="string";case"number":return V(e);case"paint-record":return e===void 0||me(e);case"pairing":return e===void 0||v.includes(e);case"palette-lint-id":return Y.includes(e);case"palette-lint-record":return p(e)&&["light","dark"].every(r=>Array.isArray(e[r])&&e[r].every(de));case"report-array":return Array.isArray(e);case"scheme":return e==="light"||e==="dark";case"semantic":return H(e);case"semantic-array":return Array.isArray(e)&&e.every(H);case"series-pair":return he(e);case"simulation":return te.includes(e);case"string-array":return ue(e);case"token-array":return Array.isArray(e)&&e.every(le);case"warning":return Z.includes(e);default:{const r=t;return!1}}}function me(e){return p(e)?["light","dark"].every(t=>{const r=e[t];if(!Array.isArray(r))return!1;const i=new Set;for(const n of r){if(!p(n)||!T(n.role)||i.has(n.role)||n.context!==null&&!T(n.context)||!Array.isArray(n.pairs)||!Array.from(n.pairs).every(ge))return!1;i.add(n.role)}return!0}):!1}function ge(e){return p(e)&&T(e.element)&&T(e.foreground)&&T(e.background)&&T(e.state)&&ne(e.kind)&&V(e.ratio)&&e.ratio>=1&&e.ratio<=21&&e.required===ie(e.kind)}function U(e,t){return p(e)&&t.every(({field:r,kind:i})=>E(e[String(r)],i))}function he(e){if(!Array.isArray(e)||e.length!==2)return!1;const t=I.indexOf(e[0]),r=I.indexOf(e[1]);return t>=0&&r>t}function $e(e,t){if(!p(e)||!A.every(({field:i,kind:n})=>E(e[String(i)],n)))return!1;const r=e;return r.scheme!==t?!1:b(r.tokens.map(i=>i.token))&&b(r.adjustedTokens)&&b(r.lints.map(i=>i.id))}function ye({paint:e,...t},{paint:r,...i}){const n=[];for(const o of k)o.compared&&Se(n,o,t,i);return(g(z(t))!==g(z(i))||n.length===0&&g(t)!==g(i))&&n.push("fit tables differ outside compared fields"),n}function Se(e,t,r,i){const{field:n,kind:s}=t;if(s==="string-array"){const o=r[n],c=i[n];K(e,String(n),o,c),F(e,String(n),o,c);return}if(s==="data-palette-record"){const o=r[n],c=i[n];for(const a of["light","dark"])for(const f of I)q(e,`${a}/${String(n)}/${f}`,o[a][f],c[a][f]);return}if(s==="palette-lint-record"){const o=r[n],c=i[n];for(const a of["light","dark"])Le(e,a,String(n),o[a],c[a]),F(e,`${a}/${String(n)}`,o[a].map(h),c[a].map(h));return}if(s==="report-array"&&(n==="light"||n==="dark")){ke(e,n,r[n],i[n]);return}_(e,"fit tables",String(n),r[n],i[n],s)}function ke(e,t,r,i){const n=new Map(r.map(o=>[o.surface,o])),s=new Map(i.map(o=>[o.surface,o]));F(e,`${t}/reports`,r.map(o=>o.surface),i.map(o=>o.surface));for(const o of L(n.keys(),s.keys())){const c=n.get(o),a=s.get(o),f=`${t}/${o}`;if(!c||!a){e.push(`${f}: surface ${c?"removed":"added"}`);continue}Te(e,f,c,a)}}function Te(e,t,r,i){for(const n of A){const{compared:s,field:o,kind:c}=n;if(!(!s||o==="scheme"||o==="surface")){if(c==="anchor-record"){Ae(e,`${t}/${String(o)}`,r[o],i[o]);continue}if(c==="semantic-array"){const a=r[o],f=i[o];K(e,`${t}/${String(o)}`,a,f),F(e,`${t}/${String(o)}`,a,f);continue}if(c==="lint-array"){const a=r[o],f=i[o];_e(e,t,String(o),a,f),F(e,`${t}/${String(o)}`,a.map(u=>u.id),f.map(u=>u.id));continue}if(c==="token-array"){Ee(e,t,String(o),r[o],i[o]);continue}_(e,t,String(o),r[o],i[o],c)}}}function Ee(e,t,r,i,n){const s=new Map(i.map(a=>[a.token,a])),o=new Map(n.map(a=>[a.token,a]));F(e,`${t}/${r}`,i.map(a=>a.token),n.map(a=>a.token));const c=r==="tokens"?t:`${t}/${r}`;for(const a of L(s.keys(),o.keys())){const f=s.get(a),u=o.get(a),S=`${c}/${a}`;if(!f||!u){e.push(`${S}: token ${f?"removed":"added"}`);continue}Fe(e,S,f,u)}}function Fe(e,t,r,i){for(const{compared:n,field:s,kind:o}of x)if(!(!n||s==="token")){if(o==="anchor"){J(e,t,"anchor",r.anchor,i.anchor,P);continue}if(o==="apca"){J(e,t,"apca",r.apca,i.apca,R);continue}_(e,t,String(s),r[s],i[s],o)}}function J(e,t,r,i,n,s){const o=i,c=n;for(const{compared:a,field:f,kind:u}of s)a&&_(e,t,`${r}.${String(f)}`,o?.[f],c?.[f],u)}function _e(e,t,r,i,n){const s=new Map(i.map(c=>[c.id,c])),o=new Map(n.map(c=>[c.id,c]));for(const c of L(s.keys(),o.keys())){const a=s.get(c),f=o.get(c),u=`${t}/${r}/${c}`;if(!a||!f){e.push(`${u}: lint ${a?"removed":"added"}`);continue}for(const{compared:S,field:d,kind:j}of M)if(!(!S||d==="id")){if(j==="semantic-array"){xe(e,u,String(d),a[d],f[d]);continue}_(e,u,String(d),a[d],f[d],j)}}}function Le(e,t,r,i,n){const s=new Map(i.map(c=>[h(c),c])),o=new Map(n.map(c=>[h(c),c]));for(const c of L(s.keys(),o.keys())){const a=s.get(c),f=o.get(c),u=`${t}/${r}/${c}`;if(!a||!f){e.push(`${u}: lint ${a?"removed":"added"}`);continue}for(const{compared:S,field:d,kind:j}of C)!S||d==="id"||d==="series"||d==="simulation"||_(e,u,String(d),a[d],f[d],j)}}function h(e){return`${e.id}/${e.series[0]}+${e.series[1]}/${e.simulation}`}function Ae(e,t,r,i){for(const n of L(Object.keys(r),Object.keys(i)))q(e,`${t}/${n}`,r[n],i[n])}function K(e,t,r,i){const n=new Set(r),s=new Set(i);for(const o of L(n,s))n.has(o)!==s.has(o)&&e.push(`${t}/${o}: ${n.has(o)?"removed":"added"}`)}function F(e,t,r,i){const n=new Set(r),s=new Set(i),o=r.filter(a=>s.has(a)),c=i.filter(a=>n.has(a));o.some((a,f)=>a!==c[f])&&e.push(`${t}: order changed`)}function xe(e,t,r,i,n){const s=Math.max(i.length,n.length);for(let o=0;o<s;o+=1)W(e,t,`${r}[${o}]`,i[o],n[o])}function q(e,t,r,i){r!==i&&e.push(`${t}: ${O(r)} \u2192 ${O(i)}`)}function W(e,t,r,i,n,s){if(!Object.is(i,n)){if(s==="message"){e.push(`${t}: message changed`);return}e.push(`${t}: ${r} ${O(i)} \u2192 ${O(n)}`)}}function Ie(e,t,r,i,n){g(i)!==g(n)&&e.push(`${t}: ${r} changed`)}function _(e,t,r,i,n,s){if(be(s)){W(e,t,r,i,n,s);return}Ie(e,t,r,i,n)}const we={anchor:!1,"anchor-record":!1,apca:!1,boolean:!0,"data-palette-record":!1,explicit:!0,"fit-lint-id":!0,"lint-array":!1,message:!0,number:!0,"paint-record":!1,pairing:!0,"palette-lint-id":!0,"palette-lint-record":!1,"report-array":!1,scheme:!0,semantic:!0,"semantic-array":!1,"series-pair":!1,simulation:!0,string:!0,"string-array":!1,"token-array":!1,warning:!0};function be(e){return we[e]===!0}function O(e){return e===void 0?"(absent)":e===""?'""':String(e)}function L(e,t){return[...new Set([...e,...t])].sort()}function g(e){return Array.isArray(e)?`[${e.map(g).join(",")}]`:p(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${g(e[t])}`).join(",")}}`:JSON.stringify(e)??"undefined"}function z(e){const t=m(e,$(k)),r=["light","dark"];if(y(k,"dataPalette")){const i=m(e.dataPalette,r);for(const n of r)l(i,n,m(e.dataPalette[n],I));l(t,"dataPalette",i)}if(y(k,"paletteLints")){const i=m(e.paletteLints,r);for(const n of r)l(i,n,G(e.paletteLints[n],h,$(C)));l(t,"paletteLints",i)}for(const i of r){if(!y(k,i))continue;const n=N();for(const s of e[i]){const o=m(s,$(A));if(y(A,"tokens")){const c=N();for(const a of s.tokens){const f=m(a,$(x));a.anchor&&y(x,"anchor")&&l(f,"anchor",m(a.anchor,$(P))),a.apca&&y(x,"apca")&&l(f,"apca",m(a.apca,$(R))),l(c,a.token,f)}l(o,"tokens",c)}y(A,"lints")&&l(o,"lints",G(s.lints,c=>c.id,$(M))),l(n,s.surface,o)}l(t,i,n)}return t}function G(e,t,r){const i=N();for(const n of e)l(i,t(n),m(n,r));return i}function $(e){return e.filter(({compared:t})=>t).map(({field:t})=>t)}function y(e,t){return e.some(r=>r.field===t&&r.compared)}function m(e,t){const r=new Set(t.map(String)),i=N();for(const[n,s]of Object.entries(e))r.has(n)||(i[n]=s);return i}function N(){return Object.create(null)}function l(e,t,r){Object.keys(r).length>0&&(e[t]=r)}function je(e,t,r){for(const i of["light","dark"]){for(const n of e.paletteLints[i])r.log(` ${i} lint(${n.id}): ${n.message}`);for(const n of e[i]){r.log(Re(i,n));for(const s of n.lints)r.log(` lint(${s.id}): ${s.message}`)}}r.log(`Checked ${e.surfaces.length} surface(s) \xD7 2 schemes \u2014 `+(t===0?"no lints.":`${t} lint(s), listed above.`))}function Oe(e,t,r){r.error(`${t} theme lint(s) are standing while fit-table drift is present:`);for(const i of["light","dark"]){for(const n of e.paletteLints[i])r.error(`lint: ${i}/paletteLints/${h(n)}: ${n.message}`);for(const n of e[i])for(const s of n.lints)r.error(`lint: ${i}/${n.surface}/lints/${s.id}: ${s.message}`)}}function Ne(e){return[...e.light,...e.dark].reduce((r,i)=>r+i.lints.length,0)+e.paletteLints.light.length+e.paletteLints.dark.length}function Pe(e,t){return["light","dark"].some(r=>{const i=`${r}: `;if(!e.startsWith(i))return!1;const n=e.slice(i.length);return t.paletteLints[r].some(s=>re(n,s))})}function Re(e,t){const r=t.adjustedTokens.length===0?"contrast enforcement moved nothing":`contrast enforcement moved ${t.adjustedTokens.join(", ")}`,i=t.tokens.filter(s=>s.explicit==="inherited").length,n=i===0?"":`; ${i} inherited explicit pin(s) \u2014 see the fit tables`;return`${e}/${t.surface}: ${t.tokens.length} tokens, ${r}${n}.`}export{Je as runEspalierCli};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PAINT_INTERACTIONS as d,closestPaintElement as i,configuredBrandColor as l,isPaintFocus as c,isPaintHover as u}from"../menu/navigation-paint.js";import{TOKEN_PAIRINGS as g}from"../shared/token-pairings.js";const b=({element:e,source:o})=>{const t=i(e,".brand .configured-brand");if(!(!t||!i(t,"esp-footer"))){if(o==="outline"&&e===t&&t.matches("a[href]"))return{element:"brand-link",owner:t};if(o==="text"&&i(e,".brand-text"))return{element:"brand-text",owner:t,...t.matches("a[href]")?{}:{state:()=>"rest"},...t.matches("a[href]:hover")?{}:{brandColor:l(t,"--_esp-footer-brand-color")}}}};function k(e){const o=e.ownerDocument,t=o.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=o.createRange();for(let r=t.nextNode();r;r=t.nextNode()){const a=r.parentElement;if(!(!a||!r.textContent?.trim()||a.closest("svg, [hidden], .sr-only"))&&o.defaultView?.getComputedStyle(a).visibility==="visible"&&(n.selectNodeContents(r),Array.from(n.getClientRects()).some(({width:s,height:f})=>s>0&&f>0)))return!0}return!1}const h=({element:e,source:o})=>{if(!i(e,"esp-footer")||i(e,"esp-button"))return;const t=i(e,"a[href]");if(t&&!t.classList.contains("configured-brand")&&(o==="text"||o==="outline"&&e===t&&k(t)))return{element:"footer-link",owner:t};if(o!=="text")return;const n=i(e,"h1, h2, h3, h4, h5, h6");if(n)return{element:"footer-heading",owner:n,state:()=>"rest"};if(i(e,".aside, .bottom, esp-footer-link-group"))return{element:"footer-body",owner:e,state:()=>"rest"}},x=g.linkHover.bg,y={entriesByRole:{footer:[{element:"footer-heading",foreground:"headings",background:"layer2",state:"rest",kind:"text",flags:["footerHeadings"]},{element:"footer-body",foreground:"text",background:"layer2",state:"rest",kind:"text",flags:["footerBody"]},...d.flatMap(e=>{const o=u(e),t=c(e),n={foreground:o?"linkHover":"link",background:o?x:"layer2",state:e,kind:"text"},r=[{...n,element:"footer-link",flags:["footerLinks"]},{...n,element:"brand-text",foreground:o?"linkHover":"brand-color",flags:e==="rest"?["brandText"]:["brandText","brandLink"]}];if(t)for(const[a,s]of[["footer-link","footerLinks"],["brand-link","brandLink"]])r.push({element:a,foreground:"link",background:"layer2",state:e,kind:"ring",flags:[s]});return r})]},targets:{footer:[b,h]}};export{y as footerPaintRegistration};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var a=function(i,e,r,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,r,n);else for(var
|
|
1
|
+
var a=function(i,e,r,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,r,n);else for(var d=i.length-1;d>=0;d--)(l=i[d])&&(o=(s<3?l(o):s>3?l(e,r,o):l(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};import{LitElement as h,css as u,html as b,nothing as p}from"lit";import{customElement as v,eventOptions as m,property as c}from"lit/decorators.js";import{ref as f}from"lit/directives/ref.js";import{getIconHrefForHost as g}from"../shared/intent-values.js";import{SlottedIconController as x}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as S}from"../shared/svgs/render-sprite-icon.js";import{DocumentSpriteController as y}from"../shared/document-sprite.js";import{ESP_EVENTS as C}from"../shared/events.js";import{insetNavigationFocusOutline as E}from"../menu/navigation-focus-outline.js";let t=class extends h{constructor(){super(),this.iconSlot=new x(this),this.ariaLabel=null,this.ariaControls=null,this.ariaExpanded=null,this.icon="",new y(this,{reactToSpriteChanges:!0})}handleClick(e){this.dispatchEvent(new CustomEvent(C.CLICKED,{detail:{},bubbles:!0,composed:!0}))}render(){const e=g(this.icon,this),r=this.iconSlot.hasSlottedIcon(":scope > *");return b`<button
|
|
2
2
|
@click=${this.handleClick}
|
|
3
3
|
aria-label=${this.ariaLabel??p}
|
|
4
4
|
aria-controls=${this.ariaControls??p}
|
|
@@ -37,8 +37,12 @@ var a=function(i,e,r,n){var s=arguments.length,o=s<3?e:n===null?n=Object.getOwnP
|
|
|
37
37
|
height: var(--esp-size-medium);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
&:focus-visible {
|
|
41
|
+
${E}
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
&:hover {
|
|
41
45
|
background: var(--_esp-header-button-background-hover, var(--esp-header-button-background-hover, var(--esp-color-layer-4)));
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
|
-
`,a([
|
|
48
|
+
`,a([c({attribute:"aria-label",type:String})],t.prototype,"ariaLabel",void 0),a([c({attribute:"aria-controls",type:String})],t.prototype,"ariaControls",void 0),a([c({attribute:"aria-expanded",type:String})],t.prototype,"ariaExpanded",void 0),a([c({type:String})],t.prototype,"icon",void 0),a([m({capture:!1,passive:!0})],t.prototype,"handleClick",null),t=a([v("esp-header-button")],t);export{t as EspalierHeaderButton};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var a=function(f,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(f,e,t,r);else for(var d=f.length-1;d>=0;d--)(i=f[d])&&(s=(n<3?i(s):n>3?i(e,t,s):i(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s};import{paintedSurface as Q}from"../shared/surface-layer.js";import{css as I,html as b,nothing as p,unsafeCSS as Y}from"lit";import{customElement as K,property as l,state as v}from"lit/decorators.js";import{classMap as W}from"lit/directives/class-map.js";import{styleMap as Z}from"lit/directives/style-map.js";import"../burger/esp-burger.js";import{createRef as A,ref as H}from"lit/directives/ref.js";import{MENU_PRESENTATION_CHANGED as S,MENU_LAYOUT_CHANGED as R,MENU_FIT_PROBE_STYLES as J,menuPresentationStyle as X,renderMenuNode as ee}from"../menu/menu-presentation.js";import{EspalierMenu as T}from"../menu/esp-menu.js";import{RafThrottle as q}from"../shared/raf-throttle.js";import{viewportSize as
|
|
1
|
+
var a=function(f,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(f,e,t,r);else for(var d=f.length-1;d>=0;d--)(i=f[d])&&(s=(n<3?i(s):n>3?i(e,t,s):i(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s};import{paintedSurface as Q}from"../shared/surface-layer.js";import{css as I,html as b,nothing as p,unsafeCSS as Y}from"lit";import{customElement as K,property as l,state as v}from"lit/decorators.js";import{classMap as W}from"lit/directives/class-map.js";import{styleMap as Z}from"lit/directives/style-map.js";import"../burger/esp-burger.js";import{createRef as A,ref as H}from"lit/directives/ref.js";import{MENU_PRESENTATION_CHANGED as S,MENU_LAYOUT_CHANGED as R,MENU_FIT_PROBE_STYLES as J,menuPresentationStyle as X,renderMenuNode as ee}from"../menu/menu-presentation.js";import{EspalierMenu as T}from"../menu/esp-menu.js";import{configuredBrandFocusOutline as te}from"../menu/navigation-focus-outline.js";import{RafThrottle as q}from"../shared/raf-throttle.js";import{viewportSize as re}from"../shared/viewport.js";import{CONFIGURED_BRAND_LOGO_ASPECT_RATIO as U,configuredBrandLogoGeometry as ne,renderConfiguredBrand as F,resolveConfiguredBrand as oe}from"../shared/configured-brand.js";import{EspalierElementBase as V}from"../shared/esp-element-base.js";import{ESP_EVENTS as x}from"../shared/events.js";import{HEADER_GEOMETRY_PAINT_PROPERTIES as ie,HeaderGeometryController as ae}from"./header-geometry-controller.js";const se="(max-width: 36rem)",G=I`
|
|
2
2
|
background-color 0.24s ease,
|
|
3
3
|
border-color 0.24s ease,
|
|
4
4
|
box-shadow 0.24s ease,
|
|
5
5
|
color 0.24s ease,
|
|
6
6
|
transform 0.24s ease
|
|
7
|
-
`;function L(f,e){const t=new Set(f);return{allowedValues:t,converter:{fromAttribute(n){return n??e},toAttribute(n){return t.has(n)?n:e}},defaultValue:e}}const se=["standard","centered-brand","centered-menu","extended","extended-centered","minimal"],de=["start","center","end"],le=["truncate","wrap","nowrap"],he=["auto","inline","drawer"],ce=["hidden","visible"],ue=["compact","standard"],j=new Set(Array.from({length:41},(f,e)=>(e+10)/10)),M=L(se,"standard"),D=L(de,"start"),B=L(le,"truncate"),z=L(he,"auto"),P=L(ce,"hidden"),k=L(ue,"compact");let o=class extends V{constructor(){super(...arguments),this.menuOpen=!1,this.navigationConstrained=!1,this.menuTooLarge=!1,this.mobileMenu=!1,this.scrolled=!1,this.hiddenByScroll=!1,this.scrollProgress=0,this.showBurger=!1,this.layout=M.defaultValue,this.brandText="",this.brandLogo="",this.lightBrandLogo="",this.darkBrandLogo="",this.compactBrandLogo="",this.lightCompactBrandLogo="",this.darkCompactBrandLogo="",this.heightMultiplier=1,this.minHeightMultiplier=1,this.compactSize=k.defaultValue,this.brandHref="",this.brandAlt="",this.brandColor="",this.lightBrandColor="",this.darkBrandColor="",this.brandAlign=D.defaultValue,this.brandWrap=B.defaultValue,this.menuDisplay=z.defaultValue,this.themeToggle=P.defaultValue,this.scrollBehavior="none",this.scrollThreshold=16,this.dockOffset=0,this.drawerTarget="",this.previewCollapseRequested=!1,this.fullBleedContent=!1,this.geometry=new ie(this,()=>({heightMultiplier:this.heightMultiplier,minHeightMultiplier:this.minHeightMultiplier,compactSize:this.compactSize,compactLogo:!!(this.compactBrandLogo||this.lightCompactBrandLogo||this.darkCompactBrandLogo)}),()=>this.syncBrandFitWidth(),()=>this.runScrollStateUpdate(!0)),this.readyCompactLogo="",this.naturalBrandWidth=0,this.syncCompactLogoReadiness=()=>{const e=this.shadowRoot?.querySelector(".compact-brand-fit .brand-logo"),t=this.compactLogoSource,r=t&&e?.getAttribute("src")===t&&e.complete&&e.naturalWidth>0?t:"";r!==this.readyCompactLogo&&(this.readyCompactLogo=r)},this.keyboardFocusHeld=!1,this.pointerFocusPending=!1,this.pointerActivation=null,this.onGeometryKeyboard=()=>{this.pointerFocusPending=!1,this.keyboardFocusHeld=!0,this.updateScrollState()},this.onGeometryPointer=e=>{if(!e.isPrimary||e.button!==0||this.pointerActivation)return;this.pointerFocusPending=!0;const t=e.composedPath();this.geometryPointerBlocked(t)||(this.pointerActivation={pointerId:e.pointerId,path:t}),this.keyboardFocusHeld=!1,this.updateScrollState()},this.releaseGeometryPointer=()=>{this.pointerActivation&&(this.pointerActivation=null,this.updateScrollState())},this.onGeometryPointerEnd=e=>{if(!e.isPrimary||this.pointerActivation&&e.pointerId!==this.pointerActivation.pointerId)return;this.pointerFocusPending=!1;const t=e.composedPath();(e.type==="pointercancel"||!t.includes(this)||this.geometryPointerBlocked(t)||this.pointerActivation&&this.geometryPointerBlocked(this.pointerActivation.path))&&this.releaseGeometryPointer()},this.onGeometryClick=e=>{e instanceof PointerEvent&&e.pointerId!==this.pointerActivation?.pointerId||this.releaseGeometryPointer()},this.onGeometryDrag=()=>{this.pointerFocusPending=!1,this.releaseGeometryPointer()},this.onGeometryBlur=()=>{this.keyboardFocusHeld=!1,this.pointerFocusPending=!1,this.releaseGeometryPointer(),this.updateScrollState()},this.openHeaderPopovers=new Set,this.onHeaderPopoverOpened=e=>{e.target&&this.openHeaderPopovers.add(e.target),this.updateScrollState()},this.onHeaderPopoverClosed=e=>{e.target&&this.openHeaderPopovers.delete(e.target),this.updateScrollState()},this.onHeaderGroupToggle=e=>{e.detail.open?this.onHeaderPopoverOpened(e):this.onHeaderPopoverClosed(e)},this.onGeometryFocus=e=>{const t=e.composedPath();this.keyboardFocusHeld=!this.pointerFocusPending&&t.some(r=>r instanceof Element&&r.matches(":focus-visible")),this.updateScrollState()},this.onGeometryFocusOut=()=>{queueMicrotask(()=>{this.isConnected&&(this.matches(":focus-within")||(this.keyboardFocusHeld=!1,this.pointerFocusPending=!1),this.updateScrollState())})},this.menuContainer=A(),this.menuButton=A(),this.menu=void 0,this.externalDrawerTarget=null,this.lastScrollY=0,this.lastInlineMenuWidth=0,this.mobileMenuQuery=null,this.menuDrawerListenersAttached=!1,this.observingMenuContainer=!1,this.scrollListenersAttached=!1,this.scrollFrame=new q(()=>this.runScrollStateUpdate()),this.resizeObserver=new ResizeObserver(()=>this.syncMenuLayout()),this.menuChildObserver=null,this.endProbe=A(),this.observedEndProbe=null,this.endProbeObserver=null,this.invalidMenuSlot=null,this.actionsWidth=0,this.syncPrimaryMenu=()=>{const r=(this.menuContainer.value?.querySelector('slot[name="menu"]')?.assignedElements()??[])[0],n=r instanceof T&&r.parentElement===this?r:void 0,s=r&&!n?r:null;s&&s!==this.invalidMenuSlot&&console.warn("<esp-header>: the menu slot expects an <esp-menu> element, received",s),this.invalidMenuSlot=s,this.geometry.setPrimaryMenu(n),n!==this.menu&&(this.demoteMenuToggle(),this.removeMenuDrawerListeners(),this.menu?.removeEventListener(S,this.onPrimaryPresentationChanged),this.menu?.removeEventListener(R,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=null,this.menu.sliding=!1),this.menuChildObserver?.disconnect(),this.menuChildObserver=null,this.menu=n,this.lastInlineMenuWidth=0,this.lastDrawerBrandKey="",this.addMenuDrawerListeners(),this.menu?.addEventListener(S,this.onPrimaryPresentationChanged),this.observeMenuChildren(),this.syncDrawerBrand(),this.requestUpdate()),this.menu?.addEventListener(S,this.onPrimaryPresentationChanged),this.menu?.addEventListener(R,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=this.menu.mode==="horizontal"?this:null),this.syncExternalDrawerTarget(),this.syncMenuLayout()},this.onPrimaryPresentationChanged=()=>{this.menu?.headerDrawerActive&&this.returnEndFocusToBurger(),this.requestUpdate()},this.onPrimaryLayoutChanged=()=>{if(!this.menu)return;this.geometry.invalidate();const e=this.menu.mode==="horizontal"&&this.menu.parentElement===this?this:null;this.menu.headerEndOwner!==e&&(this.menu.headerEndOwner=e),this.menu.headerDrawerActive&&this.returnEndFocusToBurger(),this.observeMenuChildren(),this.requestUpdate(),this.syncMenuLayout()},this.updateScrollState=()=>this.scrollFrame.schedule(),this.handleMobileMenuQueryChange=e=>{this.mobileMenu=e.matches,this.syncMenuLayout(),this.syncExternalDrawerControl()},this.toggleTheme=()=>{const e=this.getThemeRoot();if(!e)return;e.scheme=e.scheme==="dark"?"light":"dark";const t=e.scheme==="dark"?"dark":"light";this.dispatchEvent(new CustomEvent(x.HEADER_THEME_TOGGLE,{detail:{scheme:t},bubbles:!0,composed:!0}))},this.handleMenuToggleClicked=()=>{if(this.menuOpen){this.closeNav();return}this.openNav()},this.onMenuDrawerOpened=()=>{this.menuOpen=!0,document.body.classList.add("menu-open"),this.burger&&(this.burger.menuOpen=!0)},this.onMenuDrawerClosed=()=>{this.menuOpen=!1,document.body.classList.remove("menu-open"),this.burger&&(this.burger.menuOpen=!1),this.demoteMenuToggle(),this.updateScrollState()},this.onMenuDrawerPresented=e=>{e.target!==this.menu||!this.menu?.isFullScreenDrawer||this.promoteMenuToggle()},this.menuTogglePromoted=!1,this.promotedToggleFrame=new q(()=>this.positionPromotedToggle()),this.handlePromotedViewportResize=()=>this.promotedToggleFrame.schedule(),this.lastDrawerBrandKey="",this.inertedHeaderChrome=[],this.onGeometryContentChanged=()=>this.geometry.invalidate()}resolveBrand(){return ne({scheme:this.scheme,brandLogo:this.brandLogo,brandColor:this.brandColor,lightBrandLogo:this.lightBrandLogo,darkBrandLogo:this.darkBrandLogo,lightBrandColor:this.lightBrandColor,darkBrandColor:this.darkBrandColor})}get compactLogoSource(){if(!this.resolveBrand().brandLogo)return"";const e=this.scheme==="dark"?this.darkCompactBrandLogo:this.lightCompactBrandLogo,t=this.scheme==="dark"?this.lightCompactBrandLogo:this.darkCompactBrandLogo;return e||this.compactBrandLogo||t}syncBrandFitWidth(){const e=this.menuContainer.value?.parentElement;if(!e)return;const t=e.querySelector(".brand-fit-probe");this.naturalBrandWidth=t?.getBoundingClientRect().width??0;const r=e.querySelector('slot[name="brand"]')?.assignedElements().length,n=[...t?.querySelectorAll(".brand-logo")??[]].map(d=>d.getBoundingClientRect().width),s=getComputedStyle(e),i=[s.paddingTop,s.paddingBottom,s.borderTopWidth,s.borderBottomWidth].reduce((d,h)=>d+(parseFloat(h)||0),0);for(const[d,h]of[["--_esp-header-stable-brand-width",this.geometry.active&&!r?this.naturalBrandWidth:null],["--_esp-header-logo-reservation-width",Math.max(0,...n)],["--_esp-header-bar-block-insets",i]])if(h===null)e.style.removeProperty(d);else{const c=`${h}px`;e.style.getPropertyValue(d)!==c&&e.style.setProperty(d,c)}}geometryPointerBlocked(e){return e.some(t=>t instanceof Element&&(!t.isConnected||t.matches(":disabled, [aria-disabled=true], [inert]")))}get headerOverlayHeld(){for(const e of this.openHeaderPopovers)e instanceof Element&&!e.isConnected&&this.openHeaderPopovers.delete(e);return this.menuOpen||this.openHeaderPopovers.size>0}get usesIntrinsicNavigation(){return!!this.menu?.headerNavigationOwned}syncEndProbeObserver(){const e=this.endProbe.value??null;e!==this.observedEndProbe&&(this.endProbeObserver?.disconnect(),this.observedEndProbe=e,e&&(this.endProbeObserver??=new ResizeObserver(()=>this.syncMenuLayout()),this.endProbeObserver.observe(e,{box:"border-box"})),this.syncMenuLayout())}returnEndFocusToBurger(){const e=this.shadowRoot?.querySelector(".header-end"),t=this.shadowRoot?.activeElement;t&&e?.contains(t)&&this.updateComplete.then(()=>this.getBurgerFocusTarget()?.focus({preventScroll:!0}))}readHeaderEndFit(){const e=this.menuContainer.value?.parentElement;if(!e||!this.menu)return null;const t=getComputedStyle(e),r=e.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0),n=parseFloat(t.columnGap)||0,s=e.querySelector(":scope > .brand"),d=s?.querySelector("slot")?.assignedElements().length?Math.max(s?.scrollWidth??0,s?.getBoundingClientRect().width??0):this.naturalBrandWidth,h=e.querySelector(":scope > .buttons"),c=Array.from(h?.children??[]).flatMap(g=>g.matches(".header-end, .header-end-measurement, .menu-toggle")?[]:g instanceof HTMLSlotElement?g.assignedElements():[g]).filter(g=>getComputedStyle(g).display!=="none");let u=c.reduce((g,N)=>{const $=getComputedStyle(N);return g+N.getBoundingClientRect().width+(parseFloat($.marginLeft)||0)+(parseFloat($.marginRight)||0)},0);const E=this.endProbe.value?.getBoundingClientRect().width??0,m=h&&parseFloat(getComputedStyle(h).columnGap)||0;u+=m*Math.max(0,c.length-1+(E>0?1:0));const y=this.menu.getHeaderNavigationWidths().main,w=E+u,_=this.layout==="extended"?y>r||d+w+n>r:this.layout==="extended-centered"?y>r||d+2*w+2*n>r:this.layout==="centered-brand"?d+2*Math.max(y,w)+2*n>r:d+y+w+2*n>r,C=this.getExternalDrawerTarget()?h?.querySelector(".menu-toggle"):null,O=u+(C&&getComputedStyle(C).display!=="none"?C.getBoundingClientRect().width+(c.length||E?m:0):0);return{width:r,brandWidth:d,main:y,endWidth:E,actions:u,actionFloor:O,gap:n,tooWide:_}}syncMenuLayout(){if(this.syncBrandFitWidth(),!this.menuContainer.value||!this.menu||!this.menu.getWidth)return;this.positionPromotedToggle();const e=this.menu.getWidth();e>0&&(this.lastInlineMenuWidth=e);const t=this.lastInlineMenuWidth||e,r=this.getExternalDrawerTarget(),n=this.menuDisplay!=="inline",s=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested,i=n&&this.menuDisplay==="auto",d=i?this.layout==="centered-menu"?this.centeredMenuCapacity():this.menuContainer.value.clientWidth:0,h=this.usesIntrinsicNavigation?this.readHeaderEndFit():null;h&&this.actionsWidth!==h.actionFloor&&(this.actionsWidth=h.actionFloor,this.requestUpdate()),this.menuTooLarge=i&&(h?h.tooWide:t>d);const c=n&&!r&&this.hasDrawerableContent()&&(this.menuTooLarge||s||this.mobileMenu);c&&this.returnEndFocusToBurger(),this.menu.sliding=c,this.navigationConstrained=h?.tooWide??!1}centeredMenuCapacity(){const e=this.menuContainer.value?.parentElement;if(!(e instanceof HTMLElement))return 0;const t=d=>d?d.getBoundingClientRect().width:0,r=getComputedStyle(e),n=e.clientWidth-(Number.parseFloat(r.paddingLeft)||0)-(Number.parseFloat(r.paddingRight)||0),s=e.querySelector(":scope > section.brand"),i=e.querySelector(":scope > section.buttons");return n-t(s)-t(i)+t(i?.querySelector("esp-header-button.menu-toggle"))}menuHasContent(){return!!(this.menu??this.querySelector(':scope > [slot="menu"]'))?.querySelector("esp-menu-item, esp-menu-group")}hasDrawerableContent(){return this.showBurger||!!this.getExternalDrawerTarget()||this.menuHasContent()}getExternalDrawerTarget(){if(!this.drawerTarget)return null;const e=document.getElementById(this.drawerTarget);return e===this.menu?null:e&&"openDrawer"in e&&typeof e.openDrawer=="function"&&"closeDrawer"in e&&typeof e.closeDrawer=="function"?e:null}getBurgerFocusTarget(){const t=this.shadowRoot?.querySelector("esp-header-button.menu-toggle")?.shadowRoot?.querySelector("button"),r=this.menuButton.value?.shadowRoot?.querySelector("button");return t??r??null}getScrollTokens(){const e=this.scrollBehavior.split(/\s+/).map(t=>t.trim().toLowerCase()).filter(Boolean);return new Set(e.filter(t=>t!=="none"))}getEffectiveScrollThreshold(){return Number.isFinite(this.scrollThreshold)?Math.max(0,this.scrollThreshold):0}clearScrollState(){this.geometry.requestScroll(0,!1,!1,this.getEffectiveScrollThreshold(),!1),this.scrolled=!1,this.hiddenByScroll=!1,this.scrollProgress=0}runScrollStateUpdate(e=!1){const t=this.getScrollTokens();if(!t.size){e||this.clearScrollState();return}const r=Math.max(0,window.scrollY||document.documentElement.scrollTop||0),n=this.getEffectiveScrollThreshold(),s=Number.isFinite(this.dockOffset)?Math.max(0,this.dockOffset):n,i=r>(t.has("dock")?s:n),d=r>this.lastScrollY,h=t.has("reveal")&&d&&r>n&&!this.menuOpen;if(this.geometry.requestScroll(r,t.has("compact"),t.has("collapse-topbar")&&i,n,this.headerOverlayHeld||this.keyboardFocusHeld||this.pointerActivation!==null),!e){if(this.scrolled=i,this.hiddenByScroll=h,t.has("progress")){const c=document.documentElement,u=Math.max(1,c.scrollHeight-window.innerHeight);this.scrollProgress=Math.min(1,r/u)}else this.scrollProgress=0;this.lastScrollY=r}}cancelScrollUpdate(){this.scrollFrame.cancel()}syncScrollListeners(){const e=this.getScrollTokens().size>0;if(e&&!this.scrollListenersAttached?(window.addEventListener("scroll",this.updateScrollState,{passive:!0}),window.addEventListener("resize",this.updateScrollState,{passive:!0}),this.scrollListenersAttached=!0):!e&&this.scrollListenersAttached&&this.removeScrollListeners(),e){this.updateScrollState();return}this.cancelScrollUpdate(),this.clearScrollState()}removeScrollListeners(){this.scrollListenersAttached&&(window.removeEventListener("scroll",this.updateScrollState),window.removeEventListener("resize",this.updateScrollState),this.scrollListenersAttached=!1)}addMenuDrawerListeners(){!this.menu||this.menuDrawerListenersAttached||(this.menu.addEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.menu.addEventListener("esp-menu-drawer-presented",this.onMenuDrawerPresented),this.menu.addEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!0)}removeMenuDrawerListeners(){!this.menu||!this.menuDrawerListenersAttached||(this.menu.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.menu.removeEventListener("esp-menu-drawer-presented",this.onMenuDrawerPresented),this.menu.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!1)}observeMenuContainer(){if(!this.menuContainer.value||this.observingMenuContainer)return;this.resizeObserver.observe(this.menuContainer.value);const e=this.menuContainer.value.parentElement;if(e){this.resizeObserver.observe(e);for(const t of e.querySelectorAll(":scope > section.brand, :scope > section.buttons, :scope > .brand-fit-probe"))this.resizeObserver.observe(t)}this.observingMenuContainer=!0}disconnectResizeObserver(){this.observingMenuContainer&&(this.resizeObserver.disconnect(),this.observingMenuContainer=!1)}observeMenuChildren(){if(this.usesIntrinsicNavigation){this.menuChildObserver?.disconnect(),this.menuChildObserver=null;return}!this.menu||this.menuChildObserver||(this.menuChildObserver=new MutationObserver(()=>{this.syncMenuLayout(),this.requestUpdate()}),this.menuChildObserver.observe(this.menu,{childList:!0,subtree:!0}))}syncMobileMenuQuery(){if("matchMedia"in window){if(!this.mobileMenuQuery){this.mobileMenuQuery=window.matchMedia(ae),this.mobileMenu=this.mobileMenuQuery.matches,this.mobileMenuQuery.addEventListener("change",this.handleMobileMenuQueryChange);return}this.mobileMenu=this.mobileMenuQuery.matches}}getThemeRoot(){return this.traverseToClosest("esp-root")}syncExternalDrawerTarget(){const e=this.getExternalDrawerTarget(),t=e===this.menu?null:e;t!==this.externalDrawerTarget&&(this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof T&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=t,this.externalDrawerTarget?.addEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.addEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed)),this.syncExternalDrawerControl()}burgerVisibleForTarget(){if(this.menuDisplay==="inline")return!1;const e=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested;return this.menuTooLarge||this.mobileMenu||e}syncExternalDrawerControl(){this.externalDrawerTarget instanceof T&&(this.externalDrawerTarget.hasExternalDrawerControl=this.burgerVisibleForTarget())}openNav(){const e=this.getBurgerFocusTarget(),t=this.getExternalDrawerTarget();if(this.burger&&(this.burger.menuOpen=!0),t){this.menuOpen=!0,t.openDrawer(e),document.body.classList.add("menu-open");return}if(this.menu){this.menu.sliding=!0,this.menuOpen=!0,this.menu.isFullScreenDrawer&&this.canPromoteMenuToggle()&&(this.menu.liftedCloseControl=this.getMenuToggleElement()),this.menu.openDrawer(e),document.body.classList.add("menu-open");return}this.burger&&(this.burger.menuOpen=!1)}closeNav(){this.menuOpen=!1,this.burger&&(this.burger.menuOpen=!1),this.demoteMenuToggle();const e=this.getExternalDrawerTarget();if(e){e.closeDrawer(),document.body.classList.remove("menu-open");return}this.menu&&(this.menu.closeDrawer(),document.body.classList.remove("menu-open"))}getMenuToggleElement(){return this.shadowRoot?.querySelector("esp-header-button.menu-toggle")??null}canPromoteMenuToggle(){const e=this.getMenuToggleElement();return!!e&&typeof e?.showPopover=="function"}setHeaderChromeInert(e){if(!e){for(const i of this.inertedHeaderChrome)i.inert=!1;this.inertedHeaderChrome=[];return}const t=this.menuContainer.value?.parentElement,r=this.getMenuToggleElement();if(!t||!r)return;const n=[];for(const i of t.querySelectorAll(":scope > section.brand, :scope > section.topbar"))n.push(i);const s=t.querySelector(":scope > section.buttons");for(const i of s?.children??[])if(!(!(i instanceof HTMLElement)||i===r)){if(i instanceof HTMLSlotElement){for(const d of i.assignedElements())d instanceof HTMLElement&&n.push(d);continue}n.push(i)}for(const i of n)i.inert||(i.inert=!0,this.inertedHeaderChrome.push(i))}promoteMenuToggle(){const e=this.getMenuToggleElement();if(!e||this.menuTogglePromoted||typeof e.showPopover!="function")return;const t=e.getBoundingClientRect();e.setAttribute("popover","manual"),Object.assign(e.style,{position:"fixed",inset:"auto",margin:"0",padding:"0",border:"0",background:"transparent",overflow:"visible"}),this.setPromotedTogglePosition(e,t.width);try{e.showPopover()}catch{e.removeAttribute("popover"),e.removeAttribute("style"),this.menu&&(this.menu.liftedCloseControl=null);return}this.menuTogglePromoted=!0,window.addEventListener("resize",this.handlePromotedViewportResize),this.menu&&(this.menu.liftedCloseControl=e),this.setHeaderChromeInert(!0)}positionPromotedToggle(){if(!this.menuTogglePromoted)return;const e=this.getMenuToggleElement();if(!e)return;const t=e.getBoundingClientRect();this.setPromotedTogglePosition(e,t.width)}setPromotedTogglePosition(e,t){const r=te(),n=getComputedStyle(e).direction==="rtl";e.style.left=`${n?0:Math.max(0,r.width-t)}px`,e.style.top="0px"}demoteMenuToggle(){if(window.removeEventListener("resize",this.handlePromotedViewportResize),this.promotedToggleFrame.cancel(),this.menu?.liftedCloseControl&&(this.menu.liftedCloseControl=null),!this.menuTogglePromoted)return;this.menuTogglePromoted=!1,this.setHeaderChromeInert(!1);const e=this.getMenuToggleElement();if(e){try{e.hidePopover()}catch{}e.removeAttribute("popover"),e.removeAttribute("style")}}syncDrawerBrand(){if(!this.menu)return;const e=this.resolveBrand(),t=e.brandLogo||this.brandText?{brandLogo:e.brandLogo,brandText:this.brandText,brandHref:this.brandHref,brandAlt:this.brandAlt,brandColor:e.brandColor}:null,r=JSON.stringify(t);r!==this.lastDrawerBrandKey&&(this.lastDrawerBrandKey=r,this.menu.drawerBrand=t)}get burger(){return this.menuButton.value??void 0}willUpdate(e){super.willUpdate(e),j.has(this.heightMultiplier)||(this.heightMultiplier=1),j.has(this.minHeightMultiplier)||(this.minHeightMultiplier=1),k.allowedValues.has(this.compactSize)||(this.compactSize=k.defaultValue),["heightMultiplier","minHeightMultiplier","compactSize","compactBrandLogo","lightCompactBrandLogo","darkCompactBrandLogo"].some(t=>e.has(t))&&this.geometry.configure(),["scheme","brandLogo","lightBrandLogo","darkBrandLogo","compactBrandLogo","lightCompactBrandLogo","darkCompactBrandLogo"].some(t=>e.has(t))&&(this.readyCompactLogo=""),e.has("layout")&&!M.allowedValues.has(this.layout)&&(this.layout=M.defaultValue),e.has("brandAlign")&&!D.allowedValues.has(this.brandAlign)&&(this.brandAlign=D.defaultValue),e.has("brandWrap")&&!B.allowedValues.has(this.brandWrap)&&(this.brandWrap=B.defaultValue),e.has("menuDisplay")&&!z.allowedValues.has(this.menuDisplay)&&(this.menuDisplay=z.defaultValue),e.has("themeToggle")&&!P.allowedValues.has(this.themeToggle)&&(this.themeToggle=P.defaultValue)}firstUpdated(e){super.firstUpdated(e),this.shadowRoot?.addEventListener("load",this.syncCompactLogoReadiness,!0),this.shadowRoot?.addEventListener("error",this.syncCompactLogoReadiness,!0),this.menuContainer.value&&(this.syncPrimaryMenu(),this.observeMenuContainer(),this.syncExternalDrawerTarget(),this.syncMobileMenuQuery(),this.syncScrollListeners(),this.syncMenuLayout())}updated(e){super.updated(e),this.syncCompactLogoReadiness(),this.syncDrawerBrand(),this.syncEndProbeObserver(),(e.has("scheme")||e.has("layout")||e.has("brandLogo")||e.has("brandText")||e.has("lightBrandLogo")||e.has("darkBrandLogo"))&&this.geometry.invalidate(),(!e.size||[...e.keys()].some(t=>t!=="scrollProgress"&&t!=="hiddenByScroll"))&&this.geometry.measure(),this.observeMenuChildren(),(e.has("showBurger")||e.has("drawerTarget")||e.has("menuDisplay")||e.has("layout")||e.has("previewCollapseRequested"))&&(this.syncExternalDrawerTarget(),this.syncMenuLayout()),(e.has("mobileMenu")||e.has("menuTooLarge"))&&this.syncExternalDrawerControl(),e.has("scrollBehavior")?this.syncScrollListeners():(e.has("scrollThreshold")||e.has("dockOffset"))&&this.updateScrollState()}connectedCallback(){super.connectedCallback(),this.geometry.connect(),this.shadowRoot?.addEventListener("load",this.syncCompactLogoReadiness,!0),this.shadowRoot?.addEventListener("error",this.syncCompactLogoReadiness,!0),this.addEventListener(x.POPOVER_OPENED,this.onHeaderPopoverOpened),this.addEventListener(x.POPOVER_CLOSED,this.onHeaderPopoverClosed),this.addEventListener(x.MENU_GROUP_TOGGLE,this.onHeaderGroupToggle),this.addEventListener("keydown",this.onGeometryKeyboard),this.addEventListener("pointerdown",this.onGeometryPointer,!0),this.addEventListener("dragstart",this.onGeometryDrag,!0),window.addEventListener("pointerup",this.onGeometryPointerEnd,!0),window.addEventListener("pointercancel",this.onGeometryPointerEnd,!0),window.addEventListener("click",this.onGeometryClick,!0),window.addEventListener("blur",this.onGeometryBlur),this.addEventListener("focusin",this.onGeometryFocus),this.addEventListener("focusout",this.onGeometryFocusOut),this.addEventListener("slotchange",this.onGeometryContentChanged),this.syncScrollListeners(),this.syncMobileMenuQuery(),this.addMenuDrawerListeners(),this.syncExternalDrawerTarget(),this.observeMenuContainer(),this.hasUpdated&&this.syncPrimaryMenu(),this.observeMenuChildren()}disconnectedCallback(){this.geometry.disconnect(),this.shadowRoot?.removeEventListener("load",this.syncCompactLogoReadiness,!0),this.shadowRoot?.removeEventListener("error",this.syncCompactLogoReadiness,!0),this.readyCompactLogo="",this.removeEventListener(x.POPOVER_OPENED,this.onHeaderPopoverOpened),this.removeEventListener(x.POPOVER_CLOSED,this.onHeaderPopoverClosed),this.removeEventListener(x.MENU_GROUP_TOGGLE,this.onHeaderGroupToggle),this.openHeaderPopovers.clear(),this.pointerActivation=null,this.keyboardFocusHeld=!1,this.pointerFocusPending=!1,this.removeEventListener("keydown",this.onGeometryKeyboard),this.removeEventListener("pointerdown",this.onGeometryPointer,!0),this.removeEventListener("dragstart",this.onGeometryDrag,!0),window.removeEventListener("pointerup",this.onGeometryPointerEnd,!0),window.removeEventListener("pointercancel",this.onGeometryPointerEnd,!0),window.removeEventListener("click",this.onGeometryClick,!0),window.removeEventListener("blur",this.onGeometryBlur),this.removeEventListener("focusin",this.onGeometryFocus),this.removeEventListener("focusout",this.onGeometryFocusOut),this.removeEventListener("slotchange",this.onGeometryContentChanged),this.menu?.removeEventListener(S,this.onPrimaryPresentationChanged),this.menu?.removeEventListener(R,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=null),this.removeMenuDrawerListeners(),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof T&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=null,this.mobileMenuQuery?.removeEventListener("change",this.handleMobileMenuQueryChange),this.mobileMenuQuery=null,this.removeScrollListeners(),this.cancelScrollUpdate(),this.disconnectResizeObserver(),this.endProbeObserver?.disconnect(),this.observedEndProbe=null,this.menuChildObserver?.disconnect(),this.menuChildObserver=null,this.demoteMenuToggle(),super.disconnectedCallback()}renderHeaderEnd(e,t,r){return b`<nav
|
|
7
|
+
`;function L(f,e){const t=new Set(f);return{allowedValues:t,converter:{fromAttribute(n){return n??e},toAttribute(n){return t.has(n)?n:e}},defaultValue:e}}const de=["standard","centered-brand","centered-menu","extended","extended-centered","minimal"],le=["start","center","end"],he=["truncate","wrap","nowrap"],ce=["auto","inline","drawer"],ue=["hidden","visible"],pe=["compact","standard"],j=new Set(Array.from({length:41},(f,e)=>(e+10)/10)),M=L(de,"standard"),D=L(le,"start"),B=L(he,"truncate"),z=L(ce,"auto"),P=L(ue,"hidden"),k=L(pe,"compact");let o=class extends V{constructor(){super(...arguments),this.menuOpen=!1,this.navigationConstrained=!1,this.menuTooLarge=!1,this.mobileMenu=!1,this.scrolled=!1,this.hiddenByScroll=!1,this.scrollProgress=0,this.showBurger=!1,this.layout=M.defaultValue,this.brandText="",this.brandLogo="",this.lightBrandLogo="",this.darkBrandLogo="",this.compactBrandLogo="",this.lightCompactBrandLogo="",this.darkCompactBrandLogo="",this.heightMultiplier=1,this.minHeightMultiplier=1,this.compactSize=k.defaultValue,this.brandHref="",this.brandAlt="",this.brandColor="",this.lightBrandColor="",this.darkBrandColor="",this.brandAlign=D.defaultValue,this.brandWrap=B.defaultValue,this.menuDisplay=z.defaultValue,this.themeToggle=P.defaultValue,this.scrollBehavior="none",this.scrollThreshold=16,this.dockOffset=0,this.drawerTarget="",this.previewCollapseRequested=!1,this.fullBleedContent=!1,this.geometry=new ae(this,()=>({heightMultiplier:this.heightMultiplier,minHeightMultiplier:this.minHeightMultiplier,compactSize:this.compactSize,compactLogo:!!(this.compactBrandLogo||this.lightCompactBrandLogo||this.darkCompactBrandLogo)}),()=>this.syncBrandFitWidth(),()=>this.runScrollStateUpdate(!0)),this.readyCompactLogo="",this.naturalBrandWidth=0,this.syncCompactLogoReadiness=()=>{const e=this.shadowRoot?.querySelector(".compact-brand-fit .brand-logo"),t=this.compactLogoSource,r=t&&e?.getAttribute("src")===t&&e.complete&&e.naturalWidth>0?t:"";r!==this.readyCompactLogo&&(this.readyCompactLogo=r)},this.keyboardFocusHeld=!1,this.pointerFocusPending=!1,this.pointerActivation=null,this.onGeometryKeyboard=()=>{this.pointerFocusPending=!1,this.keyboardFocusHeld=!0,this.updateScrollState()},this.onGeometryPointer=e=>{if(!e.isPrimary||e.button!==0||this.pointerActivation)return;this.pointerFocusPending=!0;const t=e.composedPath();this.geometryPointerBlocked(t)||(this.pointerActivation={pointerId:e.pointerId,path:t}),this.keyboardFocusHeld=!1,this.updateScrollState()},this.releaseGeometryPointer=()=>{this.pointerActivation&&(this.pointerActivation=null,this.updateScrollState())},this.onGeometryPointerEnd=e=>{if(!e.isPrimary||this.pointerActivation&&e.pointerId!==this.pointerActivation.pointerId)return;this.pointerFocusPending=!1;const t=e.composedPath();(e.type==="pointercancel"||!t.includes(this)||this.geometryPointerBlocked(t)||this.pointerActivation&&this.geometryPointerBlocked(this.pointerActivation.path))&&this.releaseGeometryPointer()},this.onGeometryClick=e=>{e instanceof PointerEvent&&e.pointerId!==this.pointerActivation?.pointerId||this.releaseGeometryPointer()},this.onGeometryDrag=()=>{this.pointerFocusPending=!1,this.releaseGeometryPointer()},this.onGeometryBlur=()=>{this.keyboardFocusHeld=!1,this.pointerFocusPending=!1,this.releaseGeometryPointer(),this.updateScrollState()},this.openHeaderPopovers=new Set,this.onHeaderPopoverOpened=e=>{e.target&&this.openHeaderPopovers.add(e.target),this.updateScrollState()},this.onHeaderPopoverClosed=e=>{e.target&&this.openHeaderPopovers.delete(e.target),this.updateScrollState()},this.onHeaderGroupToggle=e=>{e.detail.open?this.onHeaderPopoverOpened(e):this.onHeaderPopoverClosed(e)},this.onGeometryFocus=e=>{const t=e.composedPath();this.keyboardFocusHeld=!this.pointerFocusPending&&t.some(r=>r instanceof Element&&r.matches(":focus-visible")),this.updateScrollState()},this.onGeometryFocusOut=()=>{queueMicrotask(()=>{this.isConnected&&(this.matches(":focus-within")||(this.keyboardFocusHeld=!1,this.pointerFocusPending=!1),this.updateScrollState())})},this.menuContainer=A(),this.menuButton=A(),this.menu=void 0,this.externalDrawerTarget=null,this.lastScrollY=0,this.lastInlineMenuWidth=0,this.mobileMenuQuery=null,this.menuDrawerListenersAttached=!1,this.observingMenuContainer=!1,this.scrollListenersAttached=!1,this.scrollFrame=new q(()=>this.runScrollStateUpdate()),this.resizeObserver=new ResizeObserver(()=>this.syncMenuLayout()),this.menuChildObserver=null,this.endProbe=A(),this.observedEndProbe=null,this.endProbeObserver=null,this.invalidMenuSlot=null,this.actionsWidth=0,this.syncPrimaryMenu=()=>{const r=(this.menuContainer.value?.querySelector('slot[name="menu"]')?.assignedElements()??[])[0],n=r instanceof T&&r.parentElement===this?r:void 0,s=r&&!n?r:null;s&&s!==this.invalidMenuSlot&&console.warn("<esp-header>: the menu slot expects an <esp-menu> element, received",s),this.invalidMenuSlot=s,this.geometry.setPrimaryMenu(n),n!==this.menu&&(this.demoteMenuToggle(),this.removeMenuDrawerListeners(),this.menu?.removeEventListener(S,this.onPrimaryPresentationChanged),this.menu?.removeEventListener(R,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=null,this.menu.sliding=!1),this.menuChildObserver?.disconnect(),this.menuChildObserver=null,this.menu=n,this.lastInlineMenuWidth=0,this.lastDrawerBrandKey="",this.addMenuDrawerListeners(),this.menu?.addEventListener(S,this.onPrimaryPresentationChanged),this.observeMenuChildren(),this.syncDrawerBrand(),this.requestUpdate()),this.menu?.addEventListener(S,this.onPrimaryPresentationChanged),this.menu?.addEventListener(R,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=this.menu.mode==="horizontal"?this:null),this.syncExternalDrawerTarget(),this.syncMenuLayout()},this.onPrimaryPresentationChanged=()=>{this.menu?.headerDrawerActive&&this.returnEndFocusToBurger(),this.requestUpdate()},this.onPrimaryLayoutChanged=()=>{if(!this.menu)return;this.geometry.invalidate();const e=this.menu.mode==="horizontal"&&this.menu.parentElement===this?this:null;this.menu.headerEndOwner!==e&&(this.menu.headerEndOwner=e),this.menu.headerDrawerActive&&this.returnEndFocusToBurger(),this.observeMenuChildren(),this.requestUpdate(),this.syncMenuLayout()},this.updateScrollState=()=>this.scrollFrame.schedule(),this.handleMobileMenuQueryChange=e=>{this.mobileMenu=e.matches,this.syncMenuLayout(),this.syncExternalDrawerControl()},this.toggleTheme=()=>{const e=this.getThemeRoot();if(!e)return;e.scheme=e.scheme==="dark"?"light":"dark";const t=e.scheme==="dark"?"dark":"light";this.dispatchEvent(new CustomEvent(x.HEADER_THEME_TOGGLE,{detail:{scheme:t},bubbles:!0,composed:!0}))},this.handleMenuToggleClicked=()=>{if(this.menuOpen){this.closeNav();return}this.openNav()},this.onMenuDrawerOpened=()=>{this.menuOpen=!0,document.body.classList.add("menu-open"),this.burger&&(this.burger.menuOpen=!0)},this.onMenuDrawerClosed=()=>{this.menuOpen=!1,document.body.classList.remove("menu-open"),this.burger&&(this.burger.menuOpen=!1),this.demoteMenuToggle(),this.updateScrollState()},this.onMenuDrawerPresented=e=>{e.target!==this.menu||!this.menu?.isFullScreenDrawer||this.promoteMenuToggle()},this.menuTogglePromoted=!1,this.promotedToggleFrame=new q(()=>this.positionPromotedToggle()),this.handlePromotedViewportResize=()=>this.promotedToggleFrame.schedule(),this.lastDrawerBrandKey="",this.inertedHeaderChrome=[],this.onGeometryContentChanged=()=>this.geometry.invalidate()}resolveBrand(){return oe({scheme:this.scheme,brandLogo:this.brandLogo,brandColor:this.brandColor,lightBrandLogo:this.lightBrandLogo,darkBrandLogo:this.darkBrandLogo,lightBrandColor:this.lightBrandColor,darkBrandColor:this.darkBrandColor})}get compactLogoSource(){if(!this.resolveBrand().brandLogo)return"";const e=this.scheme==="dark"?this.darkCompactBrandLogo:this.lightCompactBrandLogo,t=this.scheme==="dark"?this.lightCompactBrandLogo:this.darkCompactBrandLogo;return e||this.compactBrandLogo||t}syncBrandFitWidth(){const e=this.menuContainer.value?.parentElement;if(!e)return;const t=e.querySelector(".brand-fit-probe");this.naturalBrandWidth=t?.getBoundingClientRect().width??0;const r=e.querySelector('slot[name="brand"]')?.assignedElements().length,n=[...t?.querySelectorAll(".brand-logo")??[]].map(d=>d.getBoundingClientRect().width),s=getComputedStyle(e),i=[s.paddingTop,s.paddingBottom,s.borderTopWidth,s.borderBottomWidth].reduce((d,h)=>d+(parseFloat(h)||0),0);for(const[d,h]of[["--_esp-header-stable-brand-width",this.geometry.active&&!r?this.naturalBrandWidth:null],["--_esp-header-logo-reservation-width",Math.max(0,...n)],["--_esp-header-bar-block-insets",i]])if(h===null)e.style.removeProperty(d);else{const c=`${h}px`;e.style.getPropertyValue(d)!==c&&e.style.setProperty(d,c)}}geometryPointerBlocked(e){return e.some(t=>t instanceof Element&&(!t.isConnected||t.matches(":disabled, [aria-disabled=true], [inert]")))}get headerOverlayHeld(){for(const e of this.openHeaderPopovers)e instanceof Element&&!e.isConnected&&this.openHeaderPopovers.delete(e);return this.menuOpen||this.openHeaderPopovers.size>0}get usesIntrinsicNavigation(){return!!this.menu?.headerNavigationOwned}syncEndProbeObserver(){const e=this.endProbe.value??null;e!==this.observedEndProbe&&(this.endProbeObserver?.disconnect(),this.observedEndProbe=e,e&&(this.endProbeObserver??=new ResizeObserver(()=>this.syncMenuLayout()),this.endProbeObserver.observe(e,{box:"border-box"})),this.syncMenuLayout())}returnEndFocusToBurger(){const e=this.shadowRoot?.querySelector(".header-end"),t=this.shadowRoot?.activeElement;t&&e?.contains(t)&&this.updateComplete.then(()=>this.getBurgerFocusTarget()?.focus({preventScroll:!0}))}readHeaderEndFit(){const e=this.menuContainer.value?.parentElement;if(!e||!this.menu)return null;const t=getComputedStyle(e),r=e.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0),n=parseFloat(t.columnGap)||0,s=e.querySelector(":scope > .brand"),d=s?.querySelector("slot")?.assignedElements().length?Math.max(s?.scrollWidth??0,s?.getBoundingClientRect().width??0):this.naturalBrandWidth,h=e.querySelector(":scope > .buttons"),c=Array.from(h?.children??[]).flatMap(g=>g.matches(".header-end, .header-end-measurement, .menu-toggle")?[]:g instanceof HTMLSlotElement?g.assignedElements():[g]).filter(g=>getComputedStyle(g).display!=="none");let u=c.reduce((g,N)=>{const $=getComputedStyle(N);return g+N.getBoundingClientRect().width+(parseFloat($.marginLeft)||0)+(parseFloat($.marginRight)||0)},0);const E=this.endProbe.value?.getBoundingClientRect().width??0,m=h&&parseFloat(getComputedStyle(h).columnGap)||0;u+=m*Math.max(0,c.length-1+(E>0?1:0));const y=this.menu.getHeaderNavigationWidths().main,w=E+u,_=this.layout==="extended"?y>r||d+w+n>r:this.layout==="extended-centered"?y>r||d+2*w+2*n>r:this.layout==="centered-brand"?d+2*Math.max(y,w)+2*n>r:d+y+w+2*n>r,C=this.getExternalDrawerTarget()?h?.querySelector(".menu-toggle"):null,O=u+(C&&getComputedStyle(C).display!=="none"?C.getBoundingClientRect().width+(c.length||E?m:0):0);return{width:r,brandWidth:d,main:y,endWidth:E,actions:u,actionFloor:O,gap:n,tooWide:_}}syncMenuLayout(){if(this.syncBrandFitWidth(),!this.menuContainer.value||!this.menu||!this.menu.getWidth)return;this.positionPromotedToggle();const e=this.menu.getWidth();e>0&&(this.lastInlineMenuWidth=e);const t=this.lastInlineMenuWidth||e,r=this.getExternalDrawerTarget(),n=this.menuDisplay!=="inline",s=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested,i=n&&this.menuDisplay==="auto",d=i?this.layout==="centered-menu"?this.centeredMenuCapacity():this.menuContainer.value.clientWidth:0,h=this.usesIntrinsicNavigation?this.readHeaderEndFit():null;h&&this.actionsWidth!==h.actionFloor&&(this.actionsWidth=h.actionFloor,this.requestUpdate()),this.menuTooLarge=i&&(h?h.tooWide:t>d);const c=n&&!r&&this.hasDrawerableContent()&&(this.menuTooLarge||s||this.mobileMenu);c&&this.returnEndFocusToBurger(),this.menu.sliding=c,this.navigationConstrained=h?.tooWide??!1}centeredMenuCapacity(){const e=this.menuContainer.value?.parentElement;if(!(e instanceof HTMLElement))return 0;const t=d=>d?d.getBoundingClientRect().width:0,r=getComputedStyle(e),n=e.clientWidth-(Number.parseFloat(r.paddingLeft)||0)-(Number.parseFloat(r.paddingRight)||0),s=e.querySelector(":scope > section.brand"),i=e.querySelector(":scope > section.buttons");return n-t(s)-t(i)+t(i?.querySelector("esp-header-button.menu-toggle"))}menuHasContent(){return!!(this.menu??this.querySelector(':scope > [slot="menu"]'))?.querySelector("esp-menu-item, esp-menu-group")}hasDrawerableContent(){return this.showBurger||!!this.getExternalDrawerTarget()||this.menuHasContent()}getExternalDrawerTarget(){if(!this.drawerTarget)return null;const e=document.getElementById(this.drawerTarget);return e===this.menu?null:e&&"openDrawer"in e&&typeof e.openDrawer=="function"&&"closeDrawer"in e&&typeof e.closeDrawer=="function"?e:null}getBurgerFocusTarget(){const t=this.shadowRoot?.querySelector("esp-header-button.menu-toggle")?.shadowRoot?.querySelector("button"),r=this.menuButton.value?.shadowRoot?.querySelector("button");return t??r??null}getScrollTokens(){const e=this.scrollBehavior.split(/\s+/).map(t=>t.trim().toLowerCase()).filter(Boolean);return new Set(e.filter(t=>t!=="none"))}getEffectiveScrollThreshold(){return Number.isFinite(this.scrollThreshold)?Math.max(0,this.scrollThreshold):0}clearScrollState(){this.geometry.requestScroll(0,!1,!1,this.getEffectiveScrollThreshold(),!1),this.scrolled=!1,this.hiddenByScroll=!1,this.scrollProgress=0}runScrollStateUpdate(e=!1){const t=this.getScrollTokens();if(!t.size){e||this.clearScrollState();return}const r=Math.max(0,window.scrollY||document.documentElement.scrollTop||0),n=this.getEffectiveScrollThreshold(),s=Number.isFinite(this.dockOffset)?Math.max(0,this.dockOffset):n,i=r>(t.has("dock")?s:n),d=r>this.lastScrollY,h=t.has("reveal")&&d&&r>n&&!this.menuOpen;if(this.geometry.requestScroll(r,t.has("compact"),t.has("collapse-topbar")&&i,n,this.headerOverlayHeld||this.keyboardFocusHeld||this.pointerActivation!==null),!e){if(this.scrolled=i,this.hiddenByScroll=h,t.has("progress")){const c=document.documentElement,u=Math.max(1,c.scrollHeight-window.innerHeight);this.scrollProgress=Math.min(1,r/u)}else this.scrollProgress=0;this.lastScrollY=r}}cancelScrollUpdate(){this.scrollFrame.cancel()}syncScrollListeners(){const e=this.getScrollTokens().size>0;if(e&&!this.scrollListenersAttached?(window.addEventListener("scroll",this.updateScrollState,{passive:!0}),window.addEventListener("resize",this.updateScrollState,{passive:!0}),this.scrollListenersAttached=!0):!e&&this.scrollListenersAttached&&this.removeScrollListeners(),e){this.updateScrollState();return}this.cancelScrollUpdate(),this.clearScrollState()}removeScrollListeners(){this.scrollListenersAttached&&(window.removeEventListener("scroll",this.updateScrollState),window.removeEventListener("resize",this.updateScrollState),this.scrollListenersAttached=!1)}addMenuDrawerListeners(){!this.menu||this.menuDrawerListenersAttached||(this.menu.addEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.menu.addEventListener("esp-menu-drawer-presented",this.onMenuDrawerPresented),this.menu.addEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!0)}removeMenuDrawerListeners(){!this.menu||!this.menuDrawerListenersAttached||(this.menu.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.menu.removeEventListener("esp-menu-drawer-presented",this.onMenuDrawerPresented),this.menu.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!1)}observeMenuContainer(){if(!this.menuContainer.value||this.observingMenuContainer)return;this.resizeObserver.observe(this.menuContainer.value);const e=this.menuContainer.value.parentElement;if(e){this.resizeObserver.observe(e);for(const t of e.querySelectorAll(":scope > section.brand, :scope > section.buttons, :scope > .brand-fit-probe"))this.resizeObserver.observe(t)}this.observingMenuContainer=!0}disconnectResizeObserver(){this.observingMenuContainer&&(this.resizeObserver.disconnect(),this.observingMenuContainer=!1)}observeMenuChildren(){if(this.usesIntrinsicNavigation){this.menuChildObserver?.disconnect(),this.menuChildObserver=null;return}!this.menu||this.menuChildObserver||(this.menuChildObserver=new MutationObserver(()=>{this.syncMenuLayout(),this.requestUpdate()}),this.menuChildObserver.observe(this.menu,{childList:!0,subtree:!0}))}syncMobileMenuQuery(){if("matchMedia"in window){if(!this.mobileMenuQuery){this.mobileMenuQuery=window.matchMedia(se),this.mobileMenu=this.mobileMenuQuery.matches,this.mobileMenuQuery.addEventListener("change",this.handleMobileMenuQueryChange);return}this.mobileMenu=this.mobileMenuQuery.matches}}getThemeRoot(){return this.traverseToClosest("esp-root")}syncExternalDrawerTarget(){const e=this.getExternalDrawerTarget(),t=e===this.menu?null:e;t!==this.externalDrawerTarget&&(this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof T&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=t,this.externalDrawerTarget?.addEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.addEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed)),this.syncExternalDrawerControl()}burgerVisibleForTarget(){if(this.menuDisplay==="inline")return!1;const e=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested;return this.menuTooLarge||this.mobileMenu||e}syncExternalDrawerControl(){this.externalDrawerTarget instanceof T&&(this.externalDrawerTarget.hasExternalDrawerControl=this.burgerVisibleForTarget())}openNav(){const e=this.getBurgerFocusTarget(),t=this.getExternalDrawerTarget();if(this.burger&&(this.burger.menuOpen=!0),t){this.menuOpen=!0,t.openDrawer(e),document.body.classList.add("menu-open");return}if(this.menu){this.menu.sliding=!0,this.menuOpen=!0,this.menu.isFullScreenDrawer&&this.canPromoteMenuToggle()&&(this.menu.liftedCloseControl=this.getMenuToggleElement()),this.menu.openDrawer(e),document.body.classList.add("menu-open");return}this.burger&&(this.burger.menuOpen=!1)}closeNav(){this.menuOpen=!1,this.burger&&(this.burger.menuOpen=!1),this.demoteMenuToggle();const e=this.getExternalDrawerTarget();if(e){e.closeDrawer(),document.body.classList.remove("menu-open");return}this.menu&&(this.menu.closeDrawer(),document.body.classList.remove("menu-open"))}getMenuToggleElement(){return this.shadowRoot?.querySelector("esp-header-button.menu-toggle")??null}canPromoteMenuToggle(){const e=this.getMenuToggleElement();return!!e&&typeof e?.showPopover=="function"}setHeaderChromeInert(e){if(!e){for(const i of this.inertedHeaderChrome)i.inert=!1;this.inertedHeaderChrome=[];return}const t=this.menuContainer.value?.parentElement,r=this.getMenuToggleElement();if(!t||!r)return;const n=[];for(const i of t.querySelectorAll(":scope > section.brand, :scope > section.topbar"))n.push(i);const s=t.querySelector(":scope > section.buttons");for(const i of s?.children??[])if(!(!(i instanceof HTMLElement)||i===r)){if(i instanceof HTMLSlotElement){for(const d of i.assignedElements())d instanceof HTMLElement&&n.push(d);continue}n.push(i)}for(const i of n)i.inert||(i.inert=!0,this.inertedHeaderChrome.push(i))}promoteMenuToggle(){const e=this.getMenuToggleElement();if(!e||this.menuTogglePromoted||typeof e.showPopover!="function")return;const t=e.getBoundingClientRect();e.setAttribute("popover","manual"),Object.assign(e.style,{position:"fixed",inset:"auto",margin:"0",padding:"0",border:"0",background:"transparent",overflow:"visible"}),this.setPromotedTogglePosition(e,t.width);try{e.showPopover()}catch{e.removeAttribute("popover"),e.removeAttribute("style"),this.menu&&(this.menu.liftedCloseControl=null);return}this.menuTogglePromoted=!0,window.addEventListener("resize",this.handlePromotedViewportResize),this.menu&&(this.menu.liftedCloseControl=e),this.setHeaderChromeInert(!0)}positionPromotedToggle(){if(!this.menuTogglePromoted)return;const e=this.getMenuToggleElement();if(!e)return;const t=e.getBoundingClientRect();this.setPromotedTogglePosition(e,t.width)}setPromotedTogglePosition(e,t){const r=re(),n=getComputedStyle(e).direction==="rtl";e.style.left=`${n?0:Math.max(0,r.width-t)}px`,e.style.top="0px"}demoteMenuToggle(){if(window.removeEventListener("resize",this.handlePromotedViewportResize),this.promotedToggleFrame.cancel(),this.menu?.liftedCloseControl&&(this.menu.liftedCloseControl=null),!this.menuTogglePromoted)return;this.menuTogglePromoted=!1,this.setHeaderChromeInert(!1);const e=this.getMenuToggleElement();if(e){try{e.hidePopover()}catch{}e.removeAttribute("popover"),e.removeAttribute("style")}}syncDrawerBrand(){if(!this.menu)return;const e=this.resolveBrand(),t=e.brandLogo||this.brandText?{brandLogo:e.brandLogo,brandText:this.brandText,brandHref:this.brandHref,brandAlt:this.brandAlt,brandColor:e.brandColor}:null,r=JSON.stringify(t);r!==this.lastDrawerBrandKey&&(this.lastDrawerBrandKey=r,this.menu.drawerBrand=t)}get burger(){return this.menuButton.value??void 0}willUpdate(e){super.willUpdate(e),j.has(this.heightMultiplier)||(this.heightMultiplier=1),j.has(this.minHeightMultiplier)||(this.minHeightMultiplier=1),k.allowedValues.has(this.compactSize)||(this.compactSize=k.defaultValue),["heightMultiplier","minHeightMultiplier","compactSize","compactBrandLogo","lightCompactBrandLogo","darkCompactBrandLogo"].some(t=>e.has(t))&&this.geometry.configure(),["scheme","brandLogo","lightBrandLogo","darkBrandLogo","compactBrandLogo","lightCompactBrandLogo","darkCompactBrandLogo"].some(t=>e.has(t))&&(this.readyCompactLogo=""),e.has("layout")&&!M.allowedValues.has(this.layout)&&(this.layout=M.defaultValue),e.has("brandAlign")&&!D.allowedValues.has(this.brandAlign)&&(this.brandAlign=D.defaultValue),e.has("brandWrap")&&!B.allowedValues.has(this.brandWrap)&&(this.brandWrap=B.defaultValue),e.has("menuDisplay")&&!z.allowedValues.has(this.menuDisplay)&&(this.menuDisplay=z.defaultValue),e.has("themeToggle")&&!P.allowedValues.has(this.themeToggle)&&(this.themeToggle=P.defaultValue)}firstUpdated(e){super.firstUpdated(e),this.shadowRoot?.addEventListener("load",this.syncCompactLogoReadiness,!0),this.shadowRoot?.addEventListener("error",this.syncCompactLogoReadiness,!0),this.menuContainer.value&&(this.syncPrimaryMenu(),this.observeMenuContainer(),this.syncExternalDrawerTarget(),this.syncMobileMenuQuery(),this.syncScrollListeners(),this.syncMenuLayout())}updated(e){super.updated(e),this.syncCompactLogoReadiness(),this.syncDrawerBrand(),this.syncEndProbeObserver(),(e.has("scheme")||e.has("layout")||e.has("brandLogo")||e.has("brandText")||e.has("lightBrandLogo")||e.has("darkBrandLogo"))&&this.geometry.invalidate(),(!e.size||[...e.keys()].some(t=>t!=="scrollProgress"&&t!=="hiddenByScroll"))&&this.geometry.measure(),this.observeMenuChildren(),(e.has("showBurger")||e.has("drawerTarget")||e.has("menuDisplay")||e.has("layout")||e.has("previewCollapseRequested"))&&(this.syncExternalDrawerTarget(),this.syncMenuLayout()),(e.has("mobileMenu")||e.has("menuTooLarge"))&&this.syncExternalDrawerControl(),e.has("scrollBehavior")?this.syncScrollListeners():(e.has("scrollThreshold")||e.has("dockOffset"))&&this.updateScrollState()}connectedCallback(){super.connectedCallback(),this.geometry.connect(),this.shadowRoot?.addEventListener("load",this.syncCompactLogoReadiness,!0),this.shadowRoot?.addEventListener("error",this.syncCompactLogoReadiness,!0),this.addEventListener(x.POPOVER_OPENED,this.onHeaderPopoverOpened),this.addEventListener(x.POPOVER_CLOSED,this.onHeaderPopoverClosed),this.addEventListener(x.MENU_GROUP_TOGGLE,this.onHeaderGroupToggle),this.addEventListener("keydown",this.onGeometryKeyboard),this.addEventListener("pointerdown",this.onGeometryPointer,!0),this.addEventListener("dragstart",this.onGeometryDrag,!0),window.addEventListener("pointerup",this.onGeometryPointerEnd,!0),window.addEventListener("pointercancel",this.onGeometryPointerEnd,!0),window.addEventListener("click",this.onGeometryClick,!0),window.addEventListener("blur",this.onGeometryBlur),this.addEventListener("focusin",this.onGeometryFocus),this.addEventListener("focusout",this.onGeometryFocusOut),this.addEventListener("slotchange",this.onGeometryContentChanged),this.syncScrollListeners(),this.syncMobileMenuQuery(),this.addMenuDrawerListeners(),this.syncExternalDrawerTarget(),this.observeMenuContainer(),this.hasUpdated&&this.syncPrimaryMenu(),this.observeMenuChildren()}disconnectedCallback(){this.geometry.disconnect(),this.shadowRoot?.removeEventListener("load",this.syncCompactLogoReadiness,!0),this.shadowRoot?.removeEventListener("error",this.syncCompactLogoReadiness,!0),this.readyCompactLogo="",this.removeEventListener(x.POPOVER_OPENED,this.onHeaderPopoverOpened),this.removeEventListener(x.POPOVER_CLOSED,this.onHeaderPopoverClosed),this.removeEventListener(x.MENU_GROUP_TOGGLE,this.onHeaderGroupToggle),this.openHeaderPopovers.clear(),this.pointerActivation=null,this.keyboardFocusHeld=!1,this.pointerFocusPending=!1,this.removeEventListener("keydown",this.onGeometryKeyboard),this.removeEventListener("pointerdown",this.onGeometryPointer,!0),this.removeEventListener("dragstart",this.onGeometryDrag,!0),window.removeEventListener("pointerup",this.onGeometryPointerEnd,!0),window.removeEventListener("pointercancel",this.onGeometryPointerEnd,!0),window.removeEventListener("click",this.onGeometryClick,!0),window.removeEventListener("blur",this.onGeometryBlur),this.removeEventListener("focusin",this.onGeometryFocus),this.removeEventListener("focusout",this.onGeometryFocusOut),this.removeEventListener("slotchange",this.onGeometryContentChanged),this.menu?.removeEventListener(S,this.onPrimaryPresentationChanged),this.menu?.removeEventListener(R,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=null),this.removeMenuDrawerListeners(),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof T&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=null,this.mobileMenuQuery?.removeEventListener("change",this.handleMobileMenuQueryChange),this.mobileMenuQuery=null,this.removeScrollListeners(),this.cancelScrollUpdate(),this.disconnectResizeObserver(),this.endProbeObserver?.disconnect(),this.observedEndProbe=null,this.menuChildObserver?.disconnect(),this.menuChildObserver=null,this.demoteMenuToggle(),super.disconnectedCallback()}renderHeaderEnd(e,t,r){return b`<nav
|
|
8
8
|
class=${W({"header-end":!t,"header-end-probe":t})}
|
|
9
9
|
${t?H(this.endProbe):p}
|
|
10
10
|
aria-label=${t?p:`${this.menu?.ariaLabel??"Navigation"} links`}
|
|
@@ -68,7 +68,7 @@ var a=function(f,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
68
68
|
</div>
|
|
69
69
|
${d?b`<div class="scroll-progress" aria-hidden="true"></div>`:p}
|
|
70
70
|
</header>
|
|
71
|
-
`}};o.styles=[...V.styles,J,Q(2,"header"),
|
|
71
|
+
`}};o.styles=[...V.styles,J,Q(2,"header"),ne,I`
|
|
72
72
|
:host {
|
|
73
73
|
--_esp-header-base-height: var(--esp-header-height, calc(4.5 * var(--esp-size-small)));
|
|
74
74
|
--_esp-header-current-height: var(--_esp-header-base-height);
|
|
@@ -218,6 +218,10 @@ var a=function(f,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
a.configured-brand:focus-visible {
|
|
222
|
+
${te}
|
|
223
|
+
}
|
|
224
|
+
|
|
221
225
|
.brand-logo {
|
|
222
226
|
|
|
223
227
|
aspect-ratio: auto
|
|
@@ -667,7 +671,7 @@ var a=function(f,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
667
671
|
:host([data-esp-geometry-transaction]) header,
|
|
668
672
|
:host([data-esp-geometry-transaction]) header > section,
|
|
669
673
|
:host([data-esp-geometry-transaction]) header .brand-logo {
|
|
670
|
-
transition-property: ${Y(
|
|
674
|
+
transition-property: ${Y(ie.join(", "))} !important;
|
|
671
675
|
}
|
|
672
676
|
|
|
673
677
|
:host([data-esp-geometry-measuring]) header.geometry-active {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const c=["opacity","transform","translate","rotate","scale","color","background","background-color","background-image","background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode","box-shadow","filter","backdrop-filter","outline","outline-color","outline-style","outline-width","outline-offset","border-color","border-top-color","border-right-color","border-bottom-color","border-left-color","border-block-color","border-block-start-color","border-block-end-color","border-inline-color","border-inline-start-color","border-inline-end-color","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-decoration-thickness","text-shadow","fill","fill-opacity","fill-rule","stroke","stroke-opacity","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","visibility"],u=new Set(c),d=new WeakMap;function p(l){return d.get(l)}class m{constructor(e,i,t,s){this.host=e,this.settings=i,this.prepareStructuralMeasurement=t,this.reconcileScroll=s,this.listeners=new Set,this.observer=null,this.mutations=null,this.observedChildren=new Set,this.connected=!1,this.hasMeasured=!1,this.generation=0,this.invalidated=!0,this.measuring=!1,this.owner=null,this.fixedRequested=!1,this.fixedAcknowledged=!1,this.requestedCompact=!1,this.requestedTopbarCollapsed=!1,this.compactEnabled=!1,this.scrollDistance=0,this.heldPrimarySize=null,this.expandedPrimarySize=0,this.compactPrimarySize=0,this.compactHostSize=0,this.inputEndpoints=new Map,this.inlineSize=-1,this.barInlineSize=-1,this.completionGeneration=-1,this.completionAnimations=[],this.initial=!0,this.expandedMeasurements=0,this.value={active:!1,settled:!0,expandedBlockSize:0,visibleBlockSize:0},this.onContentChange=r=>{const o=r.target;o instanceof HTMLImageElement&&o.matches(".brand-logo")&&o.getRootNode()===this.host.shadowRoot&&o.closest("section.brand")||this.invalidate()},d.set(e,this),this.value={...this.value,active:this.active,settled:!1}}get record(){return this.value}get measurementCount(){return this.expandedMeasurements}get multiplier(){return this.settings().heightMultiplier}get minimumMultiplier(){return Math.min(this.settings().minHeightMultiplier,this.multiplier)}get tallChrome(){return this.multiplier>1&&(!this.complete||this.standard&&this.minimumMultiplier>1)}get standard(){return this.settings().compactSize==="standard"}get active(){return this.multiplier>1||this.standard||this.settings().compactLogo}get compact(){return this.scrollDriven?this.primarySize<this.expandedPrimarySize:this.active&&this.fixedAcknowledged&&this.requestedCompact}get scrollDriven(){return this.multiplier>1&&this.fixedAcknowledged&&this.compactEnabled}get primarySize(){const e=this.heldPrimarySize??this.expandedPrimarySize-this.scrollDistance;return Math.max(this.compactPrimarySize,Math.min(this.expandedPrimarySize,e))}get progress(){const e=this.expandedPrimarySize-this.compactPrimarySize;return this.scrollDriven&&e>0?(this.expandedPrimarySize-this.primarySize)/e:0}get complete(){return this.scrollDriven?this.compact&&this.primarySize===this.compactPrimarySize:this.compact}get topbarCollapsed(){return this.active&&this.fixedAcknowledged&&this.requestedTopbarCollapsed}get pending(){return this.active&&this.initial}subscribe(e){return this.listeners.add(e),this.hasMeasured&&e(this.value),()=>this.listeners.delete(e)}configure(){const e=this.active;e!==this.value.active&&(this.initial=!0,this.fixedAcknowledged=!1,this.publish({active:e,settled:!e,expandedBlockSize:0,visibleBlockSize:0})),this.invalidate(),this.syncObservation()}connect(){this.connected=!0,this.initial=!0,this.fixedAcknowledged=!1,this.invalidated=!0,this.syncObservation(),this.host.addEventListener("load",this.onContentChange,!0)}disconnect(){this.connected=!1,this.hasMeasured=!1,this.generation+=1,this.observer?.disconnect(),this.observer=null,this.mutations?.disconnect(),this.mutations=null,this.host.removeEventListener("load",this.onContentChange,!0),this.host.shadowRoot?.removeEventListener("load",this.onContentChange,!0),this.observedChildren.clear(),this.inputEndpoints.clear(),this.owner=null,this.fixedRequested=!1,this.fixedAcknowledged=!1}setPrimaryMenu(e){e!==this.primaryMenu&&(this.primaryMenu=e,this.invalidate(),this.syncObservation())}setOwner(e,i){e===this.owner&&i===this.fixedRequested||(this.owner=e,this.fixedRequested=!!(e&&i),this.fixedAcknowledged=!1,this.initial=!0,this.active&&this.publish({...this.value,active:!0,settled:!1}),this.host.requestUpdate())}acknowledgeFixedHost(e){e!==this.owner||!this.fixedRequested||this.fixedAcknowledged||(this.fixedAcknowledged=!0,this.reconcileScroll(),this.host.requestUpdate())}requestScroll(e,i,t,s,r){if(r){this.scrollDriven&&this.heldPrimarySize===null&&(this.heldPrimarySize=this.primarySize);return}const o=this.primarySize,a=this.scrollDriven;this.heldPrimarySize=null,this.scrollDistance=Math.max(0,e),this.compactEnabled=i;const n=i&&(e>s||this.requestedCompact&&e>s/2),h=n!==this.requestedCompact||t!==this.requestedTopbarCollapsed||a!==this.scrollDriven||this.scrollDriven&&o!==this.primarySize;this.requestedCompact=n,this.requestedTopbarCollapsed=t,h&&this.host.requestUpdate()}invalidate(){this.generation+=1,this.invalidated=!0,this.host.requestUpdate()}syncObservation(){if(!this.connected||!this.active){this.observer?.disconnect(),this.observer=null,this.mutations?.disconnect(),this.mutations=null,this.observedChildren.clear(),this.inputEndpoints.clear();return}this.observer??=new ResizeObserver(t=>{const s=this.host.shadowRoot?.querySelector("header");for(const r of t)r.target===this.host?this.inlineSize!==r.contentRect.width&&(this.inlineSize=r.contentRect.width,this.invalidate()):r.target===s?this.barInlineSize!==r.contentRect.width&&(this.barInlineSize=r.contentRect.width,this.invalidate()):this.matchesRowResize(r.target)||this.invalidate();this.measure()}),this.observer.observe(this.host,{box:"border-box"});const e=this.host.shadowRoot?.querySelector("header");e&&this.observer.observe(e,{box:"content-box"});for(const t of this.host.shadowRoot?.querySelectorAll(".header-expanded-size-probe, .header-compact-size-probe, .header-extra-rows-size-probe, .header-bar-border-probe, .header-extended-border-probe, .brand-fit-probe")??[])this.observer.observe(t,{box:"border-box"});const i=new Set(this.host.querySelectorAll(":scope > [slot=topbar], :scope > [slot=buttons], :scope > [slot=brand]"));this.primaryMenu&&i.add(this.primaryMenu);for(const t of this.observedChildren)i.has(t)||this.observer.unobserve(t);for(const t of i)this.observedChildren.has(t)||this.observer.observe(t,{box:"border-box"});this.observedChildren=i,this.host.shadowRoot?.addEventListener("load",this.onContentChange,!0),this.mutations??=new MutationObserver(()=>this.invalidate()),this.mutations.observe(this.host,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["src","slot","label"]})}matchesRowResize(e){const i=this.inputEndpoints.get(e);if(!this.scrollDriven||this.invalidated||!i)return!1;const t=e.getBoundingClientRect(),s=o=>{const a=n=>i.expanded[n]+(i.compact[n]-i.expanded[n])*o;return Math.abs(t.width-a("width"))<=1/32&&Math.abs(t.height-a("height"))<=1/32};if(s(this.progress))return!0;const r=this.value.expandedBlockSize-this.compactHostSize;return r!==0&&s((this.value.expandedBlockSize-this.host.getBoundingClientRect().height)/r)}affectsLayout(e){const i=e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);return["offset","computed-offset","easing","composite"].includes(i)?!1:!u.has(i)}collectAnimations(e,i){for(const t of e.getAnimations?.({subtree:!0})??[])i.add(t);for(const t of[e,...e.querySelectorAll("*")])if(t.shadowRoot)for(const s of t.shadowRoot.children)this.collectAnimations(s,i)}geometryAnimations(){const e=new Set,i=this.host.shadowRoot?.querySelector("header");i&&this.collectAnimations(i,e);for(const t of this.observedChildren)this.collectAnimations(t,e);return[...e].filter(t=>{const s=t.effect;return!(s instanceof KeyframeEffect)||!Number.isFinite(s.getComputedTiming().endTime)||t.playState!=="running"&&!t.pending?!1:"transitionProperty"in t?this.affectsLayout(t.transitionProperty):s.getKeyframes().some(r=>Object.keys(r).some(o=>this.affectsLayout(o)))})}measureEndpoints(){this.expandedMeasurements+=1,this.host.setAttribute("data-esp-geometry-transaction",""),this.host.setAttribute("data-esp-geometry-measuring","");try{const e=this.host.getBoundingClientRect().height,i=new Map([...this.observedChildren].map(s=>[s,s.getBoundingClientRect()])),t=this.host.shadowRoot.querySelector("header");return this.expandedPrimarySize=parseFloat(getComputedStyle(t).gridTemplateRows.split(/\s+/)[1])||0,this.host.removeAttribute("data-esp-geometry-measuring"),this.host.setAttribute("data-esp-geometry-measuring-compact",""),this.compactPrimarySize=Math.min(this.expandedPrimarySize,parseFloat(getComputedStyle(t).gridTemplateRows.split(/\s+/)[1])||this.expandedPrimarySize),this.compactHostSize=this.host.getBoundingClientRect().height,this.inputEndpoints=new Map([...i].map(([s,r])=>[s,{expanded:r,compact:s.getBoundingClientRect()}])),this.host.removeAttribute("data-esp-geometry-measuring-compact"),this.heldPrimarySize!==null&&(this.heldPrimarySize=this.primarySize),this.host.getBoundingClientRect(),e}finally{this.host.removeAttribute("data-esp-geometry-measuring"),this.host.removeAttribute("data-esp-geometry-measuring-compact"),this.host.removeAttribute("data-esp-geometry-transaction")}}publish(e,i=!1){const t=this.value;if(!(!i&&Object.keys(e).every(s=>e[s]===t[s]))){if(this.value=Object.freeze(e),this.hasMeasured)for(const s of this.listeners)s(this.value);this.host.requestUpdate()}}measure(){if(!this.connected||this.measuring||!this.host.shadowRoot?.querySelector("header"))return;this.syncObservation();const e=!this.hasMeasured;if(this.hasMeasured=!0,!this.active){this.publish({active:!1,settled:!0,expandedBlockSize:0,visibleBlockSize:0},e);return}this.measuring=!0;try{const i=this.generation,t=this.geometryAnimations();!t.length&&(this.invalidated||this.value.expandedBlockSize===0)&&this.prepareStructuralMeasurement();const s=this.host.getBoundingClientRect().height,r=this.compact||this.topbarCollapsed;let o=this.value.expandedBlockSize;t.length||(this.invalidated||o===0?(o=this.measureEndpoints(),this.invalidated=!1):r||(o=s));const a=!this.fixedRequested||this.fixedAcknowledged;this.publish({active:!0,settled:a,expandedBlockSize:o,visibleBlockSize:s},e),this.initial&&a&&(this.initial=!1,this.host.requestUpdate()),t.length&&(this.completionGeneration!==i||t.some((n,h)=>n!==this.completionAnimations[h]))&&(this.completionGeneration=i,this.completionAnimations=t,Promise.allSettled(t.map(n=>n.finished)).then(()=>{this.connected&&this.generation===i&&this.measure()}))}finally{this.measuring=!1}}}export{c as HEADER_GEOMETRY_PAINT_PROPERTIES,m as HeaderGeometryController,p as headerGeometryFor};
|
|
1
|
+
import{isTallHeaderPaint as c}from"./is-tall-header-paint.js";const u=["opacity","transform","translate","rotate","scale","color","background","background-color","background-image","background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode","box-shadow","filter","backdrop-filter","outline","outline-color","outline-style","outline-width","outline-offset","border-color","border-top-color","border-right-color","border-bottom-color","border-left-color","border-block-color","border-block-start-color","border-block-end-color","border-inline-color","border-inline-start-color","border-inline-end-color","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-decoration-thickness","text-shadow","fill","fill-opacity","fill-rule","stroke","stroke-opacity","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","visibility"],p=new Set(u),d=new WeakMap;function f(l){return d.get(l)}class b{constructor(e,i,t,s){this.host=e,this.settings=i,this.prepareStructuralMeasurement=t,this.reconcileScroll=s,this.listeners=new Set,this.observer=null,this.mutations=null,this.observedChildren=new Set,this.connected=!1,this.hasMeasured=!1,this.generation=0,this.invalidated=!0,this.measuring=!1,this.owner=null,this.fixedRequested=!1,this.fixedAcknowledged=!1,this.requestedCompact=!1,this.requestedTopbarCollapsed=!1,this.compactEnabled=!1,this.scrollDistance=0,this.heldPrimarySize=null,this.expandedPrimarySize=0,this.compactPrimarySize=0,this.compactHostSize=0,this.inputEndpoints=new Map,this.inlineSize=-1,this.barInlineSize=-1,this.completionGeneration=-1,this.completionAnimations=[],this.initial=!0,this.expandedMeasurements=0,this.value={active:!1,settled:!0,expandedBlockSize:0,visibleBlockSize:0},this.onContentChange=r=>{const o=r.target;o instanceof HTMLImageElement&&o.matches(".brand-logo")&&o.getRootNode()===this.host.shadowRoot&&o.closest("section.brand")||this.invalidate()},d.set(e,this),this.value={...this.value,active:this.active,settled:!1}}get record(){return this.value}get measurementCount(){return this.expandedMeasurements}get multiplier(){return this.settings().heightMultiplier}get minimumMultiplier(){return Math.min(this.settings().minHeightMultiplier,this.multiplier)}get tallChrome(){return c({...this.settings(),complete:this.complete})}get standard(){return this.settings().compactSize==="standard"}get active(){return this.multiplier>1||this.standard||this.settings().compactLogo}get compact(){return this.scrollDriven?this.primarySize<this.expandedPrimarySize:this.active&&this.fixedAcknowledged&&this.requestedCompact}get scrollDriven(){return this.multiplier>1&&this.fixedAcknowledged&&this.compactEnabled}get primarySize(){const e=this.heldPrimarySize??this.expandedPrimarySize-this.scrollDistance;return Math.max(this.compactPrimarySize,Math.min(this.expandedPrimarySize,e))}get progress(){const e=this.expandedPrimarySize-this.compactPrimarySize;return this.scrollDriven&&e>0?(this.expandedPrimarySize-this.primarySize)/e:0}get complete(){return this.scrollDriven?this.compact&&this.primarySize===this.compactPrimarySize:this.compact}get topbarCollapsed(){return this.active&&this.fixedAcknowledged&&this.requestedTopbarCollapsed}get pending(){return this.active&&this.initial}subscribe(e){return this.listeners.add(e),this.hasMeasured&&e(this.value),()=>this.listeners.delete(e)}configure(){const e=this.active;e!==this.value.active&&(this.initial=!0,this.fixedAcknowledged=!1,this.publish({active:e,settled:!e,expandedBlockSize:0,visibleBlockSize:0})),this.invalidate(),this.syncObservation()}connect(){this.connected=!0,this.initial=!0,this.fixedAcknowledged=!1,this.invalidated=!0,this.syncObservation(),this.host.addEventListener("load",this.onContentChange,!0)}disconnect(){this.connected=!1,this.hasMeasured=!1,this.generation+=1,this.observer?.disconnect(),this.observer=null,this.mutations?.disconnect(),this.mutations=null,this.host.removeEventListener("load",this.onContentChange,!0),this.host.shadowRoot?.removeEventListener("load",this.onContentChange,!0),this.observedChildren.clear(),this.inputEndpoints.clear(),this.owner=null,this.fixedRequested=!1,this.fixedAcknowledged=!1}setPrimaryMenu(e){e!==this.primaryMenu&&(this.primaryMenu=e,this.invalidate(),this.syncObservation())}setOwner(e,i){e===this.owner&&i===this.fixedRequested||(this.owner=e,this.fixedRequested=!!(e&&i),this.fixedAcknowledged=!1,this.initial=!0,this.active&&this.publish({...this.value,active:!0,settled:!1}),this.host.requestUpdate())}acknowledgeFixedHost(e){e!==this.owner||!this.fixedRequested||this.fixedAcknowledged||(this.fixedAcknowledged=!0,this.reconcileScroll(),this.host.requestUpdate())}requestScroll(e,i,t,s,r){if(r){this.scrollDriven&&this.heldPrimarySize===null&&(this.heldPrimarySize=this.primarySize);return}const o=this.primarySize,a=this.scrollDriven;this.heldPrimarySize=null,this.scrollDistance=Math.max(0,e),this.compactEnabled=i;const n=i&&(e>s||this.requestedCompact&&e>s/2),h=n!==this.requestedCompact||t!==this.requestedTopbarCollapsed||a!==this.scrollDriven||this.scrollDriven&&o!==this.primarySize;this.requestedCompact=n,this.requestedTopbarCollapsed=t,h&&this.host.requestUpdate()}invalidate(){this.generation+=1,this.invalidated=!0,this.host.requestUpdate()}syncObservation(){if(!this.connected||!this.active){this.observer?.disconnect(),this.observer=null,this.mutations?.disconnect(),this.mutations=null,this.observedChildren.clear(),this.inputEndpoints.clear();return}this.observer??=new ResizeObserver(t=>{const s=this.host.shadowRoot?.querySelector("header");for(const r of t)r.target===this.host?this.inlineSize!==r.contentRect.width&&(this.inlineSize=r.contentRect.width,this.invalidate()):r.target===s?this.barInlineSize!==r.contentRect.width&&(this.barInlineSize=r.contentRect.width,this.invalidate()):this.matchesRowResize(r.target)||this.invalidate();this.measure()}),this.observer.observe(this.host,{box:"border-box"});const e=this.host.shadowRoot?.querySelector("header");e&&this.observer.observe(e,{box:"content-box"});for(const t of this.host.shadowRoot?.querySelectorAll(".header-expanded-size-probe, .header-compact-size-probe, .header-extra-rows-size-probe, .header-bar-border-probe, .header-extended-border-probe, .brand-fit-probe")??[])this.observer.observe(t,{box:"border-box"});const i=new Set(this.host.querySelectorAll(":scope > [slot=topbar], :scope > [slot=buttons], :scope > [slot=brand]"));this.primaryMenu&&i.add(this.primaryMenu);for(const t of this.observedChildren)i.has(t)||this.observer.unobserve(t);for(const t of i)this.observedChildren.has(t)||this.observer.observe(t,{box:"border-box"});this.observedChildren=i,this.host.shadowRoot?.addEventListener("load",this.onContentChange,!0),this.mutations??=new MutationObserver(()=>this.invalidate()),this.mutations.observe(this.host,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["src","slot","label"]})}matchesRowResize(e){const i=this.inputEndpoints.get(e);if(!this.scrollDriven||this.invalidated||!i)return!1;const t=e.getBoundingClientRect(),s=o=>{const a=n=>i.expanded[n]+(i.compact[n]-i.expanded[n])*o;return Math.abs(t.width-a("width"))<=1/32&&Math.abs(t.height-a("height"))<=1/32};if(s(this.progress))return!0;const r=this.value.expandedBlockSize-this.compactHostSize;return r!==0&&s((this.value.expandedBlockSize-this.host.getBoundingClientRect().height)/r)}affectsLayout(e){const i=e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);return["offset","computed-offset","easing","composite"].includes(i)?!1:!p.has(i)}collectAnimations(e,i){for(const t of e.getAnimations?.({subtree:!0})??[])i.add(t);for(const t of[e,...e.querySelectorAll("*")])if(t.shadowRoot)for(const s of t.shadowRoot.children)this.collectAnimations(s,i)}geometryAnimations(){const e=new Set,i=this.host.shadowRoot?.querySelector("header");i&&this.collectAnimations(i,e);for(const t of this.observedChildren)this.collectAnimations(t,e);return[...e].filter(t=>{const s=t.effect;return!(s instanceof KeyframeEffect)||!Number.isFinite(s.getComputedTiming().endTime)||t.playState!=="running"&&!t.pending?!1:"transitionProperty"in t?this.affectsLayout(t.transitionProperty):s.getKeyframes().some(r=>Object.keys(r).some(o=>this.affectsLayout(o)))})}measureEndpoints(){this.expandedMeasurements+=1,this.host.setAttribute("data-esp-geometry-transaction",""),this.host.setAttribute("data-esp-geometry-measuring","");try{const e=this.host.getBoundingClientRect().height,i=new Map([...this.observedChildren].map(s=>[s,s.getBoundingClientRect()])),t=this.host.shadowRoot.querySelector("header");return this.expandedPrimarySize=parseFloat(getComputedStyle(t).gridTemplateRows.split(/\s+/)[1])||0,this.host.removeAttribute("data-esp-geometry-measuring"),this.host.setAttribute("data-esp-geometry-measuring-compact",""),this.compactPrimarySize=Math.min(this.expandedPrimarySize,parseFloat(getComputedStyle(t).gridTemplateRows.split(/\s+/)[1])||this.expandedPrimarySize),this.compactHostSize=this.host.getBoundingClientRect().height,this.inputEndpoints=new Map([...i].map(([s,r])=>[s,{expanded:r,compact:s.getBoundingClientRect()}])),this.host.removeAttribute("data-esp-geometry-measuring-compact"),this.heldPrimarySize!==null&&(this.heldPrimarySize=this.primarySize),this.host.getBoundingClientRect(),e}finally{this.host.removeAttribute("data-esp-geometry-measuring"),this.host.removeAttribute("data-esp-geometry-measuring-compact"),this.host.removeAttribute("data-esp-geometry-transaction")}}publish(e,i=!1){const t=this.value;if(!(!i&&Object.keys(e).every(s=>e[s]===t[s]))){if(this.value=Object.freeze(e),this.hasMeasured)for(const s of this.listeners)s(this.value);this.host.requestUpdate()}}measure(){if(!this.connected||this.measuring||!this.host.shadowRoot?.querySelector("header"))return;this.syncObservation();const e=!this.hasMeasured;if(this.hasMeasured=!0,!this.active){this.publish({active:!1,settled:!0,expandedBlockSize:0,visibleBlockSize:0},e);return}this.measuring=!0;try{const i=this.generation,t=this.geometryAnimations();!t.length&&(this.invalidated||this.value.expandedBlockSize===0)&&this.prepareStructuralMeasurement();const s=this.host.getBoundingClientRect().height,r=this.compact||this.topbarCollapsed;let o=this.value.expandedBlockSize;t.length||(this.invalidated||o===0?(o=this.measureEndpoints(),this.invalidated=!1):r||(o=s));const a=!this.fixedRequested||this.fixedAcknowledged;this.publish({active:!0,settled:a,expandedBlockSize:o,visibleBlockSize:s},e),this.initial&&a&&(this.initial=!1,this.host.requestUpdate()),t.length&&(this.completionGeneration!==i||t.some((n,h)=>n!==this.completionAnimations[h]))&&(this.completionGeneration=i,this.completionAnimations=t,Promise.allSettled(t.map(n=>n.finished)).then(()=>{this.connected&&this.generation===i&&this.measure()}))}finally{this.measuring=!1}}}export{u as HEADER_GEOMETRY_PAINT_PROPERTIES,b as HeaderGeometryController,f as headerGeometryFor};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Whether header controls use the unframed tall-chrome paint at this geometry endpoint. */
|
|
2
|
+
export declare function isTallHeaderPaint({ heightMultiplier, minHeightMultiplier, compactSize, complete, }: {
|
|
3
|
+
heightMultiplier: number;
|
|
4
|
+
minHeightMultiplier: number;
|
|
5
|
+
compactSize: "compact" | "standard";
|
|
6
|
+
complete: boolean;
|
|
7
|
+
}): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d({heightMultiplier:a,minHeightMultiplier:n,compactSize:r,complete:t}){return a>1&&(!t||r==="standard"&&Math.min(n,a)>1)}export{d as isTallHeaderPaint};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PAINT_INTERACTIONS as c,closestPaintElement as o,configuredBrandColor as g,isPaintFocus as d,isPaintHover as u,navigationPaintState as h}from"../menu/navigation-paint.js";const b=({element:e,source:t})=>{const r=o(e,"section.brand .configured-brand");if(!(!r||!o(r,"esp-header"))){if(t==="outline"&&e===r&&r.matches("a[href]"))return{element:"brand-link",owner:r};if(t==="text"&&o(e,".brand-text"))return{element:"brand-text",owner:r,...r.matches(":hover")?{}:{brandColor:g(r,"--_esp-header-brand-color")}}}},f=({element:e,source:t})=>{if(t!=="fill"&&t!=="stroke"&&t!=="outline")return;const r=o(e,"esp-header-button");if(!r||!o(r,"esp-header"))return;const n=r.shadowRoot?.querySelector("button");if(!n||t==="outline"&&e!==n)return;if(r.classList.contains("theme-toggle"))return{element:"theme-toggle",owner:n};if(r.classList.contains("menu-toggle")){const i=r.matches(":popover-open")?"full-screen":n.getAttribute("aria-expanded")==="true"?"panel":"inline";return{element:"burger",owner:n,state:s=>h(i,s)}}const a=r.shadowRoot?.querySelector("use[href$='#search']")??r.querySelector("use[href$='#search']");if(r.getAttribute("icon")==="search"||a)return{element:"search-button",owner:n}};function l(e,t,r,n="inline"){return c.flatMap(a=>{const i={element:e,foreground:"text",background:r==="tall"?"layer2":u(a)?"layer4":"layer3",state:h(n,a),flags:t},s={...i,kind:"graphic"};return d(a)?[s,{...i,kind:"ring"}]:[s]})}const m={entriesByRole:{header:[...c.flatMap(e=>{const t={element:"brand-text",foreground:u(e)?"headingsHover":"brand-color",background:"layer2",state:e,kind:"text",flags:d(e)?["brandText","brandLink"]:["brandText"]};return d(e)?[t,{element:"brand-link",foreground:"link",background:"layer2",state:e,kind:"ring",flags:["brandLink"]}]:[t]}),...["standard","tall"].flatMap(e=>{const t=`headerPaint:${e}`;return[...l("search-button",["searchButton",t],e),...l("theme-toggle",["themeToggle",t],e),...l("burger",["burger",t],e),...l("burger",["burger","drawer:panel",t],e,"panel")]}),...l("burger",["burger","drawer:full-screen"],"standard","full-screen")]},targets:{header:[b,f]}};export{m as headerPaintRegistration};
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export { canonicalFontStack, classifyFontStack, customWebSafeFont, isDeviceFontS
|
|
|
82
82
|
export { WEIGHT_LABELS, extractWeights, normalizeWeight, bestAvailableWeight, extractFamily, getFallbackFont, googleFontStylesheetUrl, isLocalFontFamily, normalizeFontFaceWeight, removeRuntimeGoogleFontLink, removeRuntimeGoogleFontLinks, syncRuntimeGoogleFontLink, RUNTIME_GOOGLE_FONT_OWNER_ATTR, type RuntimeGoogleFontLinkOptions, } from "./shared/font-helpers.js";
|
|
83
83
|
export { compileFontPlan, fontFallbackAliases, fontFallbackBaseIndexes, fontFaceRequestKey, type CompileFontPlanOptions, type CompiledFontPlan, type FontFaceRequest, type FontFallbackCatalog, type FontFallbackProfile, type FontPlanProfileMiss, type FontPlanScheme, type FontPlanSlot, type FontPlanStyle, type FontPlanTheme, type ResolvedFontSource, } from "./shared/font-plan.js";
|
|
84
84
|
export { getGoogleFonts } from "./font-picker/esp-font-picker.js";
|
|
85
|
-
export { ROOT_SURFACE, THEME_FIT_ANCHOR_FIELDS, THEME_FIT_APCA_FIELDS, THEME_FIT_DATA_PALETTE_LINT_FIELDS, THEME_FIT_DATA_PALETTE_LINT_IDS, THEME_FIT_EXPLICIT_VALUES, THEME_FIT_LINT_FIELDS, THEME_FIT_LINT_IDS, THEME_FIT_LINT_SEVERITIES, THEME_FIT_PAIRING_VALUES, THEME_FIT_REPORT_FIELDS, THEME_FIT_SUITE_FIELDS, THEME_FIT_TOKEN_FIELDS, themeFitReport, themeFitRows, themeFitLints, themeFitReportSuite, printThemeFitReport, type ThemeFitReport, type ThemeFitReportOptions, type ThemeFitToken, type ThemeFitApcaAction, type ThemeFitAnchor, type ThemeFitRow, type ThemeFitLint, type ThemeFitDataPaletteLint, type ThemeFitFieldDescriptor, type ThemeFitFieldKind, type ThemeFitSurfaceReport, type ThemeFitSuite, } from "./shared/theme-fit-report.js";
|
|
85
|
+
export { ROOT_SURFACE, THEME_FIT_ANCHOR_FIELDS, THEME_FIT_APCA_FIELDS, THEME_FIT_DATA_PALETTE_LINT_FIELDS, THEME_FIT_DATA_PALETTE_LINT_IDS, THEME_FIT_EXPLICIT_VALUES, THEME_FIT_LINT_FIELDS, THEME_FIT_LINT_IDS, THEME_FIT_LINT_SEVERITIES, THEME_FIT_PAIRING_VALUES, THEME_FIT_REPORT_FIELDS, THEME_FIT_SUITE_FIELDS, THEME_FIT_TOKEN_FIELDS, themeFitReport, themeFitRows, themeFitLints, themeFitReportSuite, printThemeFitReport, type ThemeFitReport, type ThemeFitReportOptions, type ThemeFitToken, type ThemeFitApcaAction, type ThemeFitAnchor, type ThemeFitRow, type ThemeFitLint, type ThemeFitDataPaletteLint, type ThemeFitFieldDescriptor, type ThemeFitFieldKind, type ThemeFitSurfaceReport, type ThemeFitSuite, type ThemeFitSuiteOptions, } from "./shared/theme-fit-report.js";
|
|
86
|
+
export type { PaintFitPair, PaintFitReport, PaintFitSurface, PaintFitSurfaceReport, PaintScheme, } from "./shared/paint-types.js";
|
|
86
87
|
export { ICON_SPRITE, ICON_SPRITE_ID, installIconSprite } from "./icons/index.js";
|
|
87
88
|
export { deriveLightnessRamp, themeFromSwatches, type ThemeFromSwatchesOptions, type ThemeFromSwatchesResult, } from "./shared/theme-swatches.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var i=function(d,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,t,r);else for(var l=d.length-1;l>=0;l--)(h=d[l])&&(n=(a<3?h(n):a>3?h(e,t,n):h(e,t))||n);return a>3&&n&&Object.defineProperty(e,t,n),n},g;import{MENU_SOURCE_CHANGED as w}from"./menu-presentation.js";import{css as
|
|
1
|
+
var i=function(d,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,t,r);else for(var l=d.length-1;l>=0;l--)(h=d[l])&&(n=(a<3?h(n):a>3?h(e,t,n):h(e,t))||n);return a>3&&n&&Object.defineProperty(e,t,n),n},g;import{MENU_SOURCE_CHANGED as w}from"./menu-presentation.js";import{insetNavigationFocusOutline as x}from"./navigation-focus-outline.js";import{css as P,html as p,nothing as c}from"lit";import{customElement as k,property as s,state as S}from"lit/decorators.js";import{classMap as z}from"lit/directives/class-map.js";import{createRef as m,ref as u}from"lit/directives/ref.js";import{EspalierElementBase as f}from"../shared/esp-element-base.js";import{ESP_EVENTS as E}from"../shared/events.js";import{getIconHrefForHost as C}from"../shared/intent-values.js";import{pathStartsWithSegment as v,pathsMatch as $}from"../shared/path-matching.js";import{SlottedIconController as L}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as T}from"../shared/svgs/render-sprite-icon.js";import{DEFAULT_NEW_TAB_LABEL as D,renderNewTabCue as U}from"../shared/new-tab-cue.js";import{PopoverController as B}from"../shared/popover-controller.js";import{viewportSize as O}from"../shared/viewport.js";import{srOnly as _}from"../shared/style-fragments.js";import{EspalierMenuItem as M}from"./esp-menu-item.js";let o=g=class extends f{constructor(){super(...arguments),this.itemsSlot=m(),this.toggleButton=m(),this.panel=m(),this.scrollPanelPresented=!1,this.panelPosition=new B({host:this,closeStrategy:"source-identity",isOpen:()=>this.scrollPanelPresented&&this.open,onShouldClose:()=>{},onPositionUpdate:()=>this.positionScrollPanel(),getPositionElements:()=>[this.toggleButton.value,this.panel.value,this.parentElement],trackShadowScroll:!0}),this.iconSlot=new L(this),this.openedByUrlPrefix=!1,this.dismissedUrlPrefix=!1,this.label="",this.url="",this.target="",this.rel="",this.newTabLabel=D,this.icon="",this.open=!1,this.mode="vertical",this.depth=0,this.scrollPanelEnabled=!1,this.touchDevice=!1,this.fullScreenPresentation=!1,this.active=!1,this.urlPrefix="",this.globalListenersActive=!1,this.handleDocumentClick=e=>{this.open&&(e.composedPath().includes(this)||this.setOpen(!1))},this.handleDocumentKeydown=e=>{!this.open||e.key!=="Escape"||(e.preventDefault(),this.setOpen(!1),this.toggleButton.value?.focus())}}connectedCallback(){super.connectedCallback(),this.checkActive()}disconnectedCallback(){const e=this.scrollPanelEnabled||this.scrollPanelPresented;this.closeScrollPanel(),e&&(this.scrollPanelEnabled=!1,this.open=!1),super.disconnectedCallback(),this.removeGlobalDismissListeners()}willUpdate(e){super.willUpdate(e),!this.usesScrollPanel&&(this.scrollPanelPresented||e.get("scrollPanelEnabled")===!0)&&(this.closeScrollPanel(),this.setOpen(!1))}firstUpdated(e){super.firstUpdated(e),this.propagateToChildren()}updated(e){super.updated(e),["label","url","target","rel","newTabLabel","icon","open"].some(t=>e.has(t))&&this.dispatchEvent(new CustomEvent(w,{bubbles:!0,composed:!0})),(e.has("mode")||e.has("depth")||e.has("touchDevice"))&&this.propagateToChildren(),(e.has("mode")||e.has("depth")||e.has("urlPrefix"))&&this.syncUrlPrefixExpansion(),e.has("url")&&this.checkActive(),e.has("open")&&!this.open&&(this.openedByUrlPrefix=!1),this.syncScrollPanel(),(e.has("open")||e.has("mode")||e.has("depth"))&&(this.open&&this.isHorizontalTopLevel?this.addGlobalDismissListeners():this.removeGlobalDismissListeners())}checkActive(){if(!this.url){this.active=!1;return}this.active=$(this.url)}get isHorizontalTopLevel(){return this.mode==="horizontal"&&this.depth===0}get usesScrollPanel(){return this.scrollPanelEnabled&&this.isHorizontalTopLevel}syncScrollPanel(){if(!this.open||!this.usesScrollPanel||!this.isConnected){this.closeScrollPanel();return}const e=this.panel.value;if(!(!e||this.scrollPanelPresented)){try{e.showPopover()}catch{this.setOpen(!1);return}this.scrollPanelPresented=!0,this.positionScrollPanel(),this.panelPosition.startTracking()}}closeScrollPanel(){if(this.panelPosition.stopTracking(),!this.scrollPanelPresented)return;this.scrollPanelPresented=!1;const e=this.panel.value;try{e?.hidePopover()}catch{}e?.style.removeProperty("left"),e?.style.removeProperty("top"),e?.style.removeProperty("max-height")}positionScrollPanel(){const e=this.panel.value,t=this.toggleButton.value;if(!this.scrollPanelPresented||!e||!t)return;const r=t.getBoundingClientRect(),a=O(),n=Math.max(0,a.height-r.bottom),h=Math.max(0,r.top);e.style.maxHeight=`min(70vh, 36rem, ${Math.max(h,n)}px)`;const l=e.getBoundingClientRect(),b=getComputedStyle(this).direction==="rtl"?r.right-l.width:r.left,y=l.height<=n||n>=h?r.bottom:r.top-l.height;e.style.left=`${Math.max(0,Math.min(b,a.width-l.width))}px`,e.style.top=`${Math.max(0,Math.min(y,a.height-l.height))}px`}get childMode(){return this.mode==="horizontal"?"vertical":this.mode}syncUrlPrefixExpansion(){const e=v(location.pathname,this.urlPrefix);if(e||(this.dismissedUrlPrefix=!1),e&&!this.dismissedUrlPrefix&&!this.isHorizontalTopLevel){this.open||(this.open=!0,this.openedByUrlPrefix=!0);return}this.openedByUrlPrefix&&(this.open=!1,this.openedByUrlPrefix=!1)}getChildren(){return this.itemsSlot.value?Array.from(this.itemsSlot.value.assignedElements()):[]}propagateToChildren(){for(const e of this.getChildren())e instanceof M?(e.mode=this.childMode,e.depth=this.depth+1,e.touchDevice=this.touchDevice):e instanceof g&&(e.mode=this.childMode,e.depth=this.depth+1,e.touchDevice=this.touchDevice)}handleSlotChange(){this.propagateToChildren()}setOpen(e){this.open!==e&&(this.openedByUrlPrefix=!1,this.dismissedUrlPrefix=!e&&v(location.pathname,this.urlPrefix),this.open=e,this.dispatchEvent(new CustomEvent(E.MENU_GROUP_TOGGLE,{detail:{open:this.open},bubbles:!0,composed:!0})))}handleHeaderClick(e){this.mode==="drawer"&&!e.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("group-icon"))||this.toggleOpen()}handleLinkClick(e){e.stopPropagation()}handleToggleClick(e){e.stopPropagation(),this.toggleOpen()}toggleOpen(){this.setOpen(!this.open)}handleGroupKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),e.stopPropagation(),this.setOpen(!1),this.toggleButton.value?.focus())}addGlobalDismissListeners(){this.globalListenersActive||(document.addEventListener("click",this.handleDocumentClick,!0),document.addEventListener("keydown",this.handleDocumentKeydown),this.globalListenersActive=!0)}removeGlobalDismissListeners(){this.globalListenersActive&&(document.removeEventListener("click",this.handleDocumentClick,!0),document.removeEventListener("keydown",this.handleDocumentKeydown),this.globalListenersActive=!1)}renderIcon(){const e=C(this.icon,this),t=this.iconSlot.hasSlottedIcon();return p`
|
|
2
2
|
<slot
|
|
3
3
|
name="icon"
|
|
4
4
|
${u(this.iconSlot.slotRef)}
|
|
5
5
|
@slotchange=${this.iconSlot.handleSlotChange}
|
|
6
6
|
></slot>
|
|
7
|
-
${!t&&e
|
|
7
|
+
${!t&&e?T(e):c}
|
|
8
8
|
`}renderToggle(e){return p`<button
|
|
9
9
|
${u(this.toggleButton)}
|
|
10
10
|
class="group-toggle"
|
|
@@ -24,11 +24,11 @@ var i=function(d,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnP
|
|
|
24
24
|
target=${this.target||c}
|
|
25
25
|
rel=${this.rel||c}
|
|
26
26
|
@click=${this.handleLinkClick}
|
|
27
|
-
>${t}${
|
|
27
|
+
>${t}${U(this.target,this.newTabLabel)}</a
|
|
28
28
|
>
|
|
29
29
|
${this.renderToggle(p`<span class="sr-only">Toggle ${this.label}</span>`)}
|
|
30
30
|
`:this.renderToggle(t);return p`
|
|
31
|
-
<div class=${
|
|
31
|
+
<div class=${z(e)} @keydown=${this.handleGroupKeydown}>
|
|
32
32
|
<div class="group-header" @click=${this.handleHeaderClick}>
|
|
33
33
|
<span class="group-label">${r}</span>
|
|
34
34
|
<span class="group-icon" aria-hidden="true">${this.renderIcon()}</span>
|
|
@@ -47,7 +47,7 @@ var i=function(d,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnP
|
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
49
49
|
</div>
|
|
50
|
-
`}};o.styles=[...f.styles,
|
|
50
|
+
`}};o.styles=[...f.styles,_,P`
|
|
51
51
|
:host {
|
|
52
52
|
display: block;
|
|
53
53
|
position: relative;
|
|
@@ -183,8 +183,8 @@ var i=function(d,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnP
|
|
|
183
183
|
|
|
184
184
|
.group-toggle:focus-visible,
|
|
185
185
|
.group-link:focus-visible {
|
|
186
|
-
|
|
187
|
-
outline-
|
|
186
|
+
${x}
|
|
187
|
+
outline-color: var(--esp-color-link);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
.group-label-text {
|
|
@@ -304,4 +304,4 @@ var i=function(d,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnP
|
|
|
304
304
|
transition: none;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
`],i([s({type:String})],o.prototype,"label",void 0),i([s({type:String})],o.prototype,"url",void 0),i([s({type:String})],o.prototype,"target",void 0),i([s({type:String})],o.prototype,"rel",void 0),i([s({type:String,attribute:"new-tab-label"})],o.prototype,"newTabLabel",void 0),i([s({type:String})],o.prototype,"icon",void 0),i([s({type:Boolean,reflect:!0})],o.prototype,"open",void 0),i([s({attribute:!1,type:String})],o.prototype,"mode",void 0),i([s({attribute:!1,type:Number})],o.prototype,"depth",void 0),i([s({attribute:!1})],o.prototype,"scrollPanelEnabled",void 0),i([s({attribute:!1,type:Boolean})],o.prototype,"touchDevice",void 0),i([s({attribute:"full-screen-presentation",type:Boolean,reflect:!0})],o.prototype,"fullScreenPresentation",void 0),i([
|
|
307
|
+
`],i([s({type:String})],o.prototype,"label",void 0),i([s({type:String})],o.prototype,"url",void 0),i([s({type:String})],o.prototype,"target",void 0),i([s({type:String})],o.prototype,"rel",void 0),i([s({type:String,attribute:"new-tab-label"})],o.prototype,"newTabLabel",void 0),i([s({type:String})],o.prototype,"icon",void 0),i([s({type:Boolean,reflect:!0})],o.prototype,"open",void 0),i([s({attribute:!1,type:String})],o.prototype,"mode",void 0),i([s({attribute:!1,type:Number})],o.prototype,"depth",void 0),i([s({attribute:!1})],o.prototype,"scrollPanelEnabled",void 0),i([s({attribute:!1,type:Boolean})],o.prototype,"touchDevice",void 0),i([s({attribute:"full-screen-presentation",type:Boolean,reflect:!0})],o.prototype,"fullScreenPresentation",void 0),i([S()],o.prototype,"active",void 0),i([s({type:String,attribute:"url-prefix"})],o.prototype,"urlPrefix",void 0),o=g=i([k("esp-menu-group")],o);export{o as EspalierMenuGroup};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,r,s);else for(var c=d.length-1;c>=0;c--)(i=d[c])&&(n=(p<3?i(n):p>3?i(e,r,n):i(e,r))||n);return p>3&&n&&Object.defineProperty(e,r,n),n};import{css as g,html as l,nothing as h}from"lit";import{customElement as
|
|
1
|
+
var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,r,s);else for(var c=d.length-1;c>=0;c--)(i=d[c])&&(n=(p<3?i(n):p>3?i(e,r,n):i(e,r))||n);return p>3&&n&&Object.defineProperty(e,r,n),n};import{css as g,html as l,nothing as h}from"lit";import{insetNavigationFocusOutline as f}from"./navigation-focus-outline.js";import{customElement as w,property as a,state as u}from"lit/decorators.js";import{classMap as y}from"lit/directives/class-map.js";import{ref as m}from"lit/directives/ref.js";import{getIconHrefForHost as k}from"../shared/intent-values.js";import{EspalierElementBase as v}from"../shared/esp-element-base.js";import{ESP_EVENTS as z}from"../shared/events.js";import{pathsMatch as x}from"../shared/path-matching.js";import{SlottedIconController as $}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as E}from"../shared/svgs/render-sprite-icon.js";import{DEFAULT_NEW_TAB_LABEL as _,renderNewTabCue as S}from"../shared/new-tab-cue.js";import{srOnly as C}from"../shared/style-fragments.js";import{MENU_SOURCE_CHANGED as H,resolveMenuItemAppearance as b}from"./menu-presentation.js";import"../button/esp-button.js";let t=class extends v{constructor(){super(...arguments),this.iconSlot=new $(this),this.label="",this.url="",this.appearance="link",this.target="",this.rel="",this.newTabLabel=_,this.icon="",this.headerEnd=!1,this.promotedForHeader=!1,this.mode="vertical",this.depth=0,this.touchDevice=!1,this.active=!1}get headerEndPromoted(){return this.promotedForHeader}setHeaderEndPromoted(e){this.promotedForHeader=e,this.toggleAttribute("data-esp-header-end-promoted",e)}connectedCallback(){this.setHeaderEndPromoted(!1),super.connectedCallback(),this.checkActive()}disconnectedCallback(){this.setHeaderEndPromoted(!1),super.disconnectedCallback()}willUpdate(e){super.willUpdate(e),e.has("appearance")&&(this.appearance=b(this.appearance))}updated(e){super.updated(e),["label","url","target","rel","newTabLabel","icon","headerEnd","appearance"].some(r=>e.has(r))&&this.dispatchEvent(new CustomEvent(H,{bubbles:!0,composed:!0})),e.has("url")&&this.checkActive()}checkActive(){if(!this.url){this.active=!1;return}this.active=x(this.url)}handleButtonClick(){this.dispatchEvent(new CustomEvent(z.CLICKED,{detail:{},bubbles:!0,composed:!0}))}render(){const e=k(this.icon,this),r=this.iconSlot.hasSlottedIcon(":scope > :not([slot]), :scope > [slot='']"),s=r||e.length>0,p=b(this.appearance)==="button",n={item:!0,"button-appearance":p,"is-horizontal":this.mode==="horizontal"&&this.depth===0,"is-vertical":this.mode!=="horizontal"||this.depth>0,"is-drawer":this.mode==="drawer","is-nested":this.depth>0,"has-icon":s,"is-active":this.active},i=l`<span part="menu-text">${this.label}</span>`,c=l`<span class="icon-area" aria-hidden=${s?"true":h}>
|
|
2
2
|
<slot ${m(this.iconSlot.slotRef)} @slotchange=${this.iconSlot.handleSlotChange}></slot>
|
|
3
|
-
${!r&&e
|
|
4
|
-
</span>`;return l`<div class=${
|
|
3
|
+
${!r&&e?E(e):h}
|
|
4
|
+
</span>`;return l`<div class=${y(n)} ?hidden=${this.headerEndPromoted}>
|
|
5
5
|
${p?l`<esp-button
|
|
6
6
|
collapsed
|
|
7
7
|
exportparts="label: menu-text"
|
|
@@ -13,9 +13,9 @@ var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnP
|
|
|
13
13
|
.current=${this.active}
|
|
14
14
|
.icon=${this.icon}
|
|
15
15
|
><slot ${m(this.iconSlot.slotRef)} @slotchange=${this.iconSlot.handleSlotChange}></slot></esp-button>`:this.active?l`<span class="current-page" aria-current="page">${i}${c}</span>`:this.url?l`<a href=${this.url} target=${this.target||h} rel=${this.rel||h}
|
|
16
|
-
>${i}${c}${
|
|
16
|
+
>${i}${c}${S(this.target,this.newTabLabel)}</a
|
|
17
17
|
>`:l`<button type="button" @click=${this.handleButtonClick}>${i}${c}</button>`}
|
|
18
|
-
</div>`}};t.styles=[...v.styles,
|
|
18
|
+
</div>`}};t.styles=[...v.styles,C,g`
|
|
19
19
|
:host {
|
|
20
20
|
display: block;
|
|
21
21
|
}
|
|
@@ -144,8 +144,8 @@ var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnP
|
|
|
144
144
|
|
|
145
145
|
a:focus-visible,
|
|
146
146
|
button:focus-visible {
|
|
147
|
-
|
|
148
|
-
outline-
|
|
147
|
+
${f}
|
|
148
|
+
outline-color: var(--esp-color-link);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
[part="menu-text"] {
|
|
@@ -276,4 +276,4 @@ var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnP
|
|
|
276
276
|
width: var(--esp-menu-item-icon-size, calc(1 * var(--esp-size-font)));
|
|
277
277
|
object-fit: contain;
|
|
278
278
|
}
|
|
279
|
-
`],o([a({type:String})],t.prototype,"label",void 0),o([a({type:String})],t.prototype,"url",void 0),o([a({type:String,reflect:!0})],t.prototype,"appearance",void 0),o([a({type:String})],t.prototype,"target",void 0),o([a({type:String})],t.prototype,"rel",void 0),o([a({type:String,attribute:"new-tab-label"})],t.prototype,"newTabLabel",void 0),o([a({type:String})],t.prototype,"icon",void 0),o([a({type:Boolean,attribute:"header-end",reflect:!0})],t.prototype,"headerEnd",void 0),o([u()],t.prototype,"promotedForHeader",void 0),o([a({attribute:!1,type:String})],t.prototype,"mode",void 0),o([a({attribute:!1,type:Number})],t.prototype,"depth",void 0),o([a({attribute:!1,type:Boolean})],t.prototype,"touchDevice",void 0),o([u()],t.prototype,"active",void 0),t=o([
|
|
279
|
+
`],o([a({type:String})],t.prototype,"label",void 0),o([a({type:String})],t.prototype,"url",void 0),o([a({type:String,reflect:!0})],t.prototype,"appearance",void 0),o([a({type:String})],t.prototype,"target",void 0),o([a({type:String})],t.prototype,"rel",void 0),o([a({type:String,attribute:"new-tab-label"})],t.prototype,"newTabLabel",void 0),o([a({type:String})],t.prototype,"icon",void 0),o([a({type:Boolean,attribute:"header-end",reflect:!0})],t.prototype,"headerEnd",void 0),o([u()],t.prototype,"promotedForHeader",void 0),o([a({attribute:!1,type:String})],t.prototype,"mode",void 0),o([a({attribute:!1,type:Number})],t.prototype,"depth",void 0),o([a({attribute:!1,type:Boolean})],t.prototype,"touchDevice",void 0),o([u()],t.prototype,"active",void 0),t=o([w("esp-menu-item")],t);export{t as EspalierMenuItem};
|