diff --git a/web/public/consent/dg-consent.js b/web/public/consent/dg-consent.js new file mode 100644 index 00000000..0df2c7cb --- /dev/null +++ b/web/public/consent/dg-consent.js @@ -0,0 +1,2 @@ +/*! dg-consent: Deepgram cookie consent banner, consent-core v1.4.0 (94d1559). Generated from tools/consent-banner; do not edit. See tools/consent-banner/README.md. */ +"use strict";(()=>{var Ye=new Set(["gdpr"]),ie=null,O=e=>{e?.jurisdiction?.code&&(ie=e)},ze=e=>(e.purposes??[]).some(t=>!v(t.code,t.canonicalPurposeCode)&&(t.requiresOptIn===!0||t.legalBasisCode==="consent_optin")),_=(e,t=null)=>{if(!e)return!1;let n=[t,ie].find(s=>s?.jurisdiction?.code===e);return n?ze(n):Ye.has(e)},P=e=>typeof e=="string"&&e.startsWith("US_"),ae=e=>e&&P(e)?"opt-out":"opt-in",le=(e,t=null)=>_(e,t);var se=new Set(["essential_services","essential"]),v=(e,t)=>se.has(e)||(t?se.has(t):!1);var qe={title:"Opt Out of Sell/Share/Targeted Advertising",paragraphs:["We and our third-party partners use cookies, pixels, and similar technologies to collect information about your activity on our site. Under certain U.S. state privacy laws, this collection and disclosure may be considered a “sale,” “sharing,” or use of personal information for targeted advertising.","If you would like to opt out, click the opt-out button below. We will use a cookie to remember your choice. If you clear your cookies or use a different browser or device, you will need to opt out again. If you enable the Global Privacy Control (GPC) in your browser, we will treat that signal as a request to opt out for that and, where applicable, for your Deepgram account when we can associate the signal with you.","For more information about how we collect, use, and disclose your personal information, please see our"],trailingPeriod:!0,optOutSuccessNote:"Your changes have been saved. The page will reload to apply them."},Je={title:"Your Privacy Choices",paragraphs:["We and our partners use cookies and similar technologies to make our site work, improve your experience, analyze traffic, and advertise our products. Click “Accept All” to accept all cookies, “Reject All” to reject all non-essential cookies or “Customize” to adjust your preferences. To learn more about our privacy practices, review our"],trailingPeriod:!0},$e={title:"Your Privacy Choices",paragraphs:["We and our partners use cookies and similar technologies to make our site work, improve your experience, analyze traffic, and advertise our products. Click “Accept All” to accept all cookies, “Reject All” to reject all non-essential cookies or “Customize” to adjust your preferences. To learn more about our privacy practices, review our"],trailingPeriod:!0},ce="We and our partners use cookies and similar technologies to make our site work, improve your experience, analyze traffic, and advertise our products. Click “Accept All” to accept all cookies, “Reject All” to reject all non-essential cookies or adjust specific purpose categories in Cookie Settings, and click “Accept Selection” to save your choices. To learn more about our privacy practices, review our",I="Adjust the toggles below and click Accept Selection to save your choices. If you turn off a category you had allowed, the page will reload to apply it.",Xe={title:"Your Privacy Choices",intro:ce,trailingPeriod:!0,subtitle:I},Ze={title:"Your Privacy Choices",intro:"We and our partners use cookies and similar technologies to make our site work, improve your experience, analyze traffic, and advertise our products. Choose your preference below — click “Accept All,” “Reject All,” or adjust specific purpose categories — and then click “Accept Selection” to save your selection. To learn more about our privacy practices, review our",trailingPeriod:!0,subtitle:I},Qe={title:"Your Privacy Choices",intro:ce,trailingPeriod:!0,subtitle:I},pe=(e,t=null)=>P(e)?qe:_(e,t)?Je:$e,ue=(e,t=null)=>P(e)?Xe:_(e,t)?Ze:Qe;var x=()=>typeof window>"u"?void 0:window.ketch;var D=()=>{x()?.("emit","hideExperience")},R=e=>{x()?.("setConsent",{purposes:e},"userUpdate"),D()},de=e=>{x()?.("getFullConfig",t=>{let n=Object.fromEntries((t?.purposes??[]).map(({code:s,canonicalPurposeCode:a})=>[s,e||v(s,a)]));Object.keys(n).length>0?R(n):D()})},M=()=>de(!0),V=()=>de(!1);var F="dg_ketch_banner_shown";var U=()=>typeof document>"u"?!1:document.cookie.split(";").some(e=>e.trim().startsWith(`${F}=`)),H=()=>{if(typeof document>"u"||typeof window>"u")return;let t=window.location.hostname==="deepgram.com"||window.location.hostname.endsWith(".deepgram.com")?"Domain=.deepgram.com":"",n=window.location.protocol==="https:"?"Secure":"";document.cookie=[`${F}=1`,"Path=/","Max-Age=31536000","SameSite=Lax",t,n].filter(Boolean).join("; ")};var he=()=>typeof window>"u"?void 0:window.ketch,W=e=>{let t=he();if(!t)return()=>{};let n=[];return Object.entries(e).forEach(([s,a])=>{a&&(t("on",s,a),n.push(()=>t("off",s,a)))}),()=>{n.forEach(s=>{s()})}};var j=e=>{let t=he();if(!t)return()=>{};let n=null,s=null,a={},l=null,c=!1,r=!1,o=!1,i=h=>{n=h,d()},p=({purposes:h})=>{a=h??{},c=!0,d()},f=h=>{l=h,c=!0,d()},y=()=>{t("off","jurisdiction",i),t("off","consent",p),t("off","needsConsent",f)},d=()=>{r||o||n&&s&&c&&(r=!0,y(),e({jurisdiction:n,config:s,consent:a,needsConsent:l}))};return t("on","jurisdiction",i),t("on","consent",p),t("on","needsConsent",f),t("getFullConfig",h=>{O(h),!o&&(s=h,d())}),()=>{o=!0,r||y()}};var G=(e,t)=>(O(t),et(e,t)),et=(e,t)=>({variant:ae(e),optIn:_(e,t),bannerCopy:pe(e,t),privacyCenterCopy:ue(e,t),privacyPolicyUrl:t.privacyPolicy?.url??"",purposes:(t.purposes??[]).map(n=>({code:n.code,name:n.name,description:n.description??"",essential:v(n.code,n.canonicalPurposeCode),cookies:(n.cookies??[]).map(s=>({name:s.name,serviceProvider:s.serviceProvider??"",durationDays:s.durationDays??null}))}))}),Y=(e,t=null,n=null)=>le(e,n)?t===null?!U():t:!1;var fe=1e3,z=({delayMs:e=fe,reload:t=()=>window.location.reload()}={})=>{let n=x();if(!n)return()=>{};let s=new Set,a=!1,l,c=i=>{Object.entries(i).forEach(([p,f])=>{f&&!v(p)&&s.add(p)})},r=i=>{c(i?.purposes??{})},o=i=>{let p=i?.purposes??{},f=[...s].some(y=>p[y]===!1);c(p),!(!f||a)&&(a=!0,l=setTimeout(t,e))};return n("on","consent",r),n("on","userConsentUpdated",o),()=>{clearTimeout(l),n("off","consent",r),n("off","userConsentUpdated",o)}};var ye=e=>{let{key:t,shiftKey:n,modal:s,panel:a,items:l,active:c,nothingFocused:r}=e;if(t!=="Tab"||!s||l.length===0)return null;if(!(c!==null&&(c===a||l.includes(c))))return r?n?l[l.length-1]:l[0]:null;let i=l[0],p=l[l.length-1];return n&&(c===i||c===a)?p:!n&&c===p?i:null},me=(e,t,n)=>e==="Escape"&&t&&n,Ce=(e,t,n)=>e||t&&n,be=(e,t)=>!e&&!t,ge=(e,t,n)=>(e||t)&&n?.isConnected?n:null,ve=(e,t)=>e==="opt-out"&&t==="opted-out"||e==="opted-out"&&t==="opt-out",Se=(e,t,n)=>e&&!t&&n!=="opted-out";var Ee=':host{--dgc-bg: #ffffff;--dgc-fg: #232329;--dgc-fg-strong: #0b0b0c;--dgc-fg-soft: #4a4a52;--dgc-border: #e5e5e7;--dgc-accent: #00976e;--dgc-on-accent: #0b0b0c;--dgc-link: #00704f;--dgc-track-off: #6b6b73;--dgc-thumb-on: #ffffff;--dgc-disabled-bg: #e5e5e7;--dgc-disabled-fg: #232329;--dgc-shadow: 0 8px 24px rgba(11, 11, 12, .16)}:host([data-theme="dark"]){--dgc-bg: #1a1a1f;--dgc-fg: #e1e1e5;--dgc-fg-strong: #fbfbff;--dgc-fg-soft: #b4b4bb;--dgc-border: #2c2c33;--dgc-accent: #a1f9d4;--dgc-on-accent: #0b0b0c;--dgc-link: #a1f9d4;--dgc-track-off: #8a8a93;--dgc-thumb-on: #0b0b0c;--dgc-disabled-bg: #2c2c33;--dgc-disabled-fg: #e1e1e5;--dgc-shadow: 0 8px 24px rgba(0, 0, 0, .5)}',ke=':host{display:contents}[hidden]{display:none!important}.panel{position:fixed;z-index:100000;left:16px;bottom:16px;box-sizing:border-box;width:32rem;max-width:calc(100vw - 32px);max-height:calc(100vh - 32px);overflow:auto;overscroll-behavior:contain;padding:24px;border:1px solid var(--dgc-border);border-radius:8px;background:var(--dgc-bg);color:var(--dgc-fg);box-shadow:var(--dgc-shadow);font-family:inherit;font-size:14px;font-weight:400;line-height:1.5;letter-spacing:normal;text-align:left;outline:none}.panel:focus-visible{outline:2px solid var(--dgc-accent);outline-offset:2px}.header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.title{margin:0;color:var(--dgc-fg-strong);font-family:Roobert,Inter,ui-sans-serif,system-ui,sans-serif;font-size:20px;font-weight:600;line-height:1.25}.close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;margin:-2px -4px 0 0;padding:0;border:0;border-radius:4px;background:transparent;color:var(--dgc-fg);cursor:pointer}.close:hover{color:var(--dgc-fg-strong)}.body{margin-top:16px}.body p{margin:0 0 12px}.body p:last-child{margin-bottom:0}.body a{color:var(--dgc-link);font-weight:600;text-decoration:underline;text-underline-offset:2px}.list{display:grid;gap:16px;margin:16px 0 0;padding:0;list-style:none}.item{display:flex;align-items:flex-start;gap:12px}.item-text{min-width:0}.item-name{display:block;color:var(--dgc-fg-strong);font-size:15px;font-weight:600;cursor:pointer}.item-desc{margin:2px 0 0;color:var(--dgc-fg-soft);font-size:13px}.switch{-webkit-appearance:none;appearance:none;position:relative;flex:none;box-sizing:border-box;width:40px;height:24px;margin:0;border:0;border-radius:999px;background:var(--dgc-track-off);cursor:pointer}.switch:before{content:"";position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:#fff}.switch:checked{background:var(--dgc-accent)}.switch:checked:before{transform:translate(16px);background:var(--dgc-thumb-on)}.switch[aria-disabled=true]{cursor:not-allowed;opacity:.7}.switch:focus-visible{outline:2px solid var(--dgc-accent);outline-offset:2px}.actions{position:sticky;bottom:-24px;display:flex;flex-wrap:wrap;gap:12px;margin:8px -24px -24px;padding:12px 24px 24px;background:var(--dgc-bg)}.live{display:grid;gap:8px}.btn{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;min-height:44px;padding:10px 20px;border:0;border-radius:4px;font:inherit;font-size:15px;font-weight:600;line-height:1.2;cursor:pointer}.btn:focus-visible{outline:2px solid var(--dgc-accent);outline-offset:2px}.btn-primary{background:var(--dgc-accent);color:var(--dgc-on-accent)}.btn-secondary{background:transparent;color:var(--dgc-fg-strong);box-shadow:inset 0 0 0 1px var(--dgc-accent)}.btn-primary:hover,.btn-secondary:hover{filter:brightness(110%) contrast(105%)}.btn-disabled{background:var(--dgc-disabled-bg);color:var(--dgc-disabled-fg);cursor:default}.note{margin:0;color:var(--dgc-fg-soft);font-size:12px}.btn[aria-disabled=true]{cursor:progress}.status{flex:1 0 100%;margin:0;color:var(--dgc-fg-soft);font-size:12px}.status:empty{display:none}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(max-width:640px){.panel{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:70vh;max-height:70dvh;padding:20px 16px calc(16px + env(safe-area-inset-bottom,0px));border-width:1px 0 0;border-radius:12px 12px 0 0}.actions{bottom:calc(-16px - env(safe-area-inset-bottom,0px));margin:8px -16px calc(-16px - env(safe-area-inset-bottom,0px));padding:12px 16px calc(16px + env(safe-area-inset-bottom,0px))}.btn{flex:1 1 auto}}@media(prefers-reduced-motion:no-preference){.panel{animation:dgc-in .18s ease-out}.switch:before{transition:transform .12s ease-out}}@keyframes dgc-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}@media(forced-colors:active){.panel{border:1px solid CanvasText}.btn,.switch{border:1px solid ButtonText}.switch:checked{background:Highlight}}',we=":host{display:block}:host([hidden]){display:none}.wrap{display:flex;justify-content:center;padding:12px 16px 20px;font-family:inherit;font-size:14px;line-height:1.5}.link{display:inline-flex;align-items:center;gap:6px;min-height:24px;padding:0;border:0;background:transparent;color:var(--dgc-fg);font:inherit;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.link:hover{color:var(--dgc-fg-strong)}.link:focus-visible{outline:2px solid var(--dgc-accent);outline-offset:2px;border-radius:2px}.icon{flex:none;width:30px;height:14px}@media(forced-colors:active){.icon{forced-color-adjust:auto}}";var C={acceptAll:"Accept All",rejectAll:"Reject All",customize:"Customize",acceptSelection:"Accept Selection",optOut:"Opt-out",optOutSuccessful:"Opt-out successful",saving:"Saving…",saveFailed:"Your choice could not be saved yet. Please try again.",privacyPolicy:"Privacy Policy",close:"Close consent banner",alwaysOn:"(always on)",footerLink:"Your Privacy Choices",footerFallback:"Privacy Policy"};var L=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="boolean"),Te=(e,t)=>t&&(e==="opt-in"||e==="opt-out")?e:null,Oe={process:{kind:"closed"},content:null,purposes:{},dismissTimer:0,unavailable:!1,openedByUser:!1,saving:null,saveCount:0},_e={unavailable:"Ketch consent is unavailable",saveUnconfirmed:"Ketch never confirmed the consent choice"},Pe=25e3,$=1e4,T={kind:"closed"},tt=e=>[...e.filter(t=>t.essential),...e.filter(t=>!t.essential)],xe=(e,t)=>Object.fromEntries(t.map(({code:n,essential:s})=>[n,s?"required":e[n]===!0?"on":"off"])),nt=e=>e==="required"?"required":e==="on"?"off":"on",J=(e,t)=>t.some(n=>!n.essential)&&t.every(n=>n.essential||e[n.code]===!1),ot=(e,t,n)=>n??(e?t.variant:null),X=(e,t)=>{let n=e.dismissTimer+1;return{state:{...e,process:{kind:"opted-out",timer:n,savedHere:t},dismissTimer:n},effects:[{type:"schedule-dismiss",timer:n}]}},B=e=>e.saving!==null&&!e.saving.failed,Re=(e,t,n)=>{if(t!=="opt-out")return{state:{...e,process:T},effects:[]};if(e.process.kind==="closed")return{state:e,effects:[]};let s=X(e,n);return{state:s.state,effects:[...s.effects,{type:"focus-close-button"}]}},q=(e,t,n,s)=>{if(Object.entries(s).every(([l,c])=>e.purposes[l]===c)){let l=Re({...e,saving:null},t,!1);return{state:l.state,effects:[n,...l.effects]}}let a=e.saveCount+1;return{state:{...e,saving:{id:a,choice:t,failed:!1},saveCount:a},effects:[n,{type:"schedule-save-timeout",id:a}]}},Ae=(e,t,n,s)=>{let a={...n,openedByUser:s};return e==="opt-out"&&J(n.purposes,t.purposes)?X(a,!1):{state:{...a,process:{kind:"open",variant:e}},effects:[]}},Be=(e,t,n={})=>{switch(t.type){case"ready":{let s={...t.snapshot,purposes:tt(t.snapshot.purposes)},a={...e,content:s,purposes:t.purposes,unavailable:!1},l=ot(t.autoShow,s,n.forcedVariant),c=l?Ae(l,s,a,!1):{state:{...a,process:T},effects:[]};return{state:c.state,effects:[...c.effects,...t.autoShow?[{type:"mark-banner-shown"}]:[]]}}case"consent-updated":{let s={...e,purposes:t.purposes};return e.content?e.process.kind==="customize"?{state:{...s,process:{kind:"customize",groups:xe(t.purposes,e.content.purposes)}},effects:[]}:e.process.kind==="open"&&e.process.variant==="opt-out"&&e.saving===null&&J(t.purposes,e.content.purposes)?X(s,!1):{state:s,effects:[]}:{state:s,effects:[]}}case"saved":{let s=e.saving;return!s||!e.content?{state:e,effects:[]}:s.choice==="opt-out"&&!J(t.purposes,e.content.purposes)?{state:e,effects:[]}:Re({...e,purposes:t.purposes,saving:null},s.choice,!0)}case"save-timeout":{let s=e.saving;return!s||s.id!==t.id||s.failed?{state:e,effects:[]}:{state:{...e,saving:{...s,failed:!0}},effects:[{type:"report",message:_e.saveUnconfirmed,context:{choice:s.choice,timeoutMs:$,purposes:e.purposes,bannerOpen:e.process.kind!=="closed"}}]}}case"show":{if(!e.content)return{state:e,effects:[]};let s=e.saving?.failed?{...e,saving:null}:e;return Ae(e.content.variant,e.content,s,!0)}case"accept":{let s=e.content;if(!s||B(e))return{state:e,effects:[]};if(e.process.kind==="customize"){let a=Object.fromEntries(Object.entries(e.process.groups).map(([l,c])=>[l,c!=="off"]));return Object.keys(a).length===0?{state:e,effects:[]}:q(e,"accept-selection",{type:"set-consent",purposes:a},a)}return q(e,"accept-all",{type:"accept-all"},Object.fromEntries(s.purposes.map(({code:a})=>[a,!0])))}case"reject":{let s=e.content;if(!s||B(e))return{state:e,effects:[]};let a=e.process.kind==="open"&&e.process.variant==="opt-out";return q(e,a?"opt-out":"reject-all",{type:"reject-all"},Object.fromEntries(s.purposes.map(({code:l,essential:c})=>[l,c])))}case"close":return{state:{...e,process:T,saving:e.saving?.failed?null:e.saving},effects:[]};case"customize":return B(e)?{state:e,effects:[]}:e.content?{state:{...e,process:{kind:"customize",groups:xe(e.purposes,e.content.purposes)},openedByUser:!0},effects:[]}:{state:e,effects:[]};case"toggle":{if(e.process.kind!=="customize"||B(e))return{state:e,effects:[]};let s=e.process.groups[t.code];return s===void 0?{state:e,effects:[]}:{state:{...e,process:{kind:"customize",groups:{...e.process.groups,[t.code]:nt(s)}}},effects:[]}}case"opt-out-expired":return e.process.kind==="opted-out"&&e.process.timer===t.timer?{state:{...e,process:T},effects:[]}:{state:e,effects:[]};case"unavailable":return e.content||e.unavailable?{state:e,effects:[]}:{state:{...e,unavailable:!0,process:T},effects:[{type:"report",message:_e.unavailable,context:{reason:t.reason}}]};default:return t}},Le=e=>e.content!==null,Ke=e=>e.unavailable&&e.content===null,S="https://deepgram.com/privacy",Ne=e=>{if(!e)return S;try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.href:S}catch{return S}};var De=e=>({href:Ne(e.privacyPolicyUrl),label:C.privacyPolicy,trailingPeriod:e.bannerCopy.trailingPeriod!==!1}),Z=e=>e.saving===null?null:e.saving.failed?C.saveFailed:C.saving,A=(e,t,n,s)=>({kind:"action",label:t,primary:n,action:s,busy:e.saving!==null&&!e.saving.failed}),Ie=(e,t,n)=>({key:n===null?"opt-out":"opted-out",title:t.bannerCopy.title,closable:!0,paragraphs:t.bannerCopy.paragraphs,policy:De(t),subtitle:null,switches:[],buttons:n===null?[A(e,C.optOut,!0,{type:"reject"})]:[{kind:"disabled",label:C.optOutSuccessful}],liveButtons:!0,note:n===!0?t.bannerCopy.optOutSuccessNote??null:null,status:n===null?Z(e):null}),Me=e=>{let t=e.content;if(!t)return null;let{process:n}=e;switch(n.kind){case"closed":return null;case"open":return n.variant==="opt-in"?{key:"opt-in",title:t.bannerCopy.title,closable:!1,paragraphs:t.bannerCopy.paragraphs,policy:De(t),subtitle:null,switches:[],buttons:[A(e,C.rejectAll,!1,{type:"reject"}),A(e,C.customize,!1,{type:"customize"}),A(e,C.acceptAll,!0,{type:"accept"})],liveButtons:!1,note:null,status:Z(e)}:Ie(e,t,null);case"opted-out":return Ie(e,t,n.savedHere);case"customize":return{key:"customize",title:t.privacyCenterCopy.title,closable:!1,paragraphs:[],policy:null,subtitle:t.privacyCenterCopy.subtitle,switches:t.purposes.map(s=>{let a=n.groups[s.code]??"off";return{code:s.code,name:s.name,description:s.description,checked:a!=="off",required:a==="required"}}),buttons:[A(e,C.rejectAll,!1,{type:"reject"}),A(e,C.acceptSelection,!0,{type:"accept"})],liveButtons:!1,note:null,status:Z(e)};default:return null}};var K="dg-consent-banner",N="dg-privacy-choices",rt="http://www.w3.org/2000/svg",E=(e,t,n)=>{let s=e.createElementNS(rt,t);return Object.entries(n).forEach(([a,l])=>s.setAttribute(a,l)),s},st=e=>{let t=E(e,"svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false"});return t.appendChild(E(e,"path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round",fill:"none"})),t},it=e=>{let t=E(e,"svg",{class:"icon",viewBox:"0 0 30 14","aria-hidden":"true",focusable:"false"});return t.appendChild(E(e,"rect",{x:"0.75",y:"0.75",width:"28.5",height:"12.5",rx:"6.25",fill:"#ffffff",stroke:"#0066ff","stroke-width":"1.5"})),t.appendChild(E(e,"path",{d:"M17 0.75H23a6.25 6.25 0 0 1 0 12.5H12.5Z",fill:"#0066ff"})),t.appendChild(E(e,"path",{d:"M4.6 7.1l2.2 2.2 3.9-4.6",fill:"none",stroke:"#0066ff","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"})),t.appendChild(E(e,"path",{d:"M18.6 4.6l4.6 4.8M23.2 4.6l-4.6 4.8",fill:"none",stroke:"#ffffff","stroke-width":"1.6","stroke-linecap":"round"})),t},Ve=(e,t)=>{let n=new e.CSSStyleSheet;return n.replaceSync(t),n},Ue=e=>typeof e.customElements<"u"&&typeof e.CSSStyleSheet=="function"&&typeof e.ShadowRoot=="function"&&"adoptedStyleSheets"in e.ShadowRoot.prototype&&"replaceSync"in e.CSSStyleSheet.prototype,at=e=>{let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},Fe=(e,t)=>{let n=e.document.documentElement,s=typeof e.matchMedia=="function"?e.matchMedia("(prefers-color-scheme: dark)"):null,a=()=>{let c=n.classList.contains("dark")?!0:n.classList.contains("light")?!1:!!s?.matches;t.setAttribute("data-theme",c?"dark":"light")};a();let l=new e.MutationObserver(a);return l.observe(n,{attributes:!0,attributeFilter:["class"]}),s?.addEventListener?.("change",a),()=>{l.disconnect(),s?.removeEventListener?.("change",a)}},lt='button:not([disabled]), input:not([disabled]), a[href], [tabindex="0"]',He=e=>{let t=e.document,n=e.customElements,s=null,a=l=>(s=s??Ve(e,Ee),[s,Ve(e,l)]);if(!n.get(K)){class l extends e.HTMLElement{controller=null;panel;header;heading;body;actions;status;buttons=[];closeButton=null;live=null;viewKey=null;closable=!1;modal=!1;previousFocus=null;unfollowTheme=null;constructor(){super();let r=this.attachShadow({mode:"open"});r.adoptedStyleSheets=a(ke),this.panel=t.createElement("div"),this.panel.className="panel",this.panel.tabIndex=-1,this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-modal","false"),this.panel.setAttribute("aria-labelledby","dgc-title"),this.panel.setAttribute("aria-describedby","dgc-body"),this.panel.hidden=!0,this.header=t.createElement("div"),this.header.className="header",this.heading=t.createElement("h2"),this.heading.className="title",this.heading.id="dgc-title",this.header.appendChild(this.heading),this.body=t.createElement("div"),this.body.className="body",this.body.id="dgc-body",this.actions=t.createElement("div"),this.actions.className="actions",this.status=t.createElement("div"),this.status.className="status",this.status.setAttribute("role","status"),this.panel.append(this.header,this.body,this.actions),r.appendChild(this.panel),this.onKeyDown=this.onKeyDown.bind(this)}attach(r){this.controller||(this.controller=r,r.subscribe(o=>this.render(o)),this.render(r.getState()))}connectedCallback(){this.unfollowTheme?.(),this.unfollowTheme=Fe(e,this),t.addEventListener("keydown",this.onKeyDown),this.controller&&this.render(this.controller.getState())}disconnectedCallback(){this.unfollowTheme?.(),this.unfollowTheme=null,t.removeEventListener("keydown",this.onKeyDown)}focusClose(){this.closeButton?.focus()}dispatch(r){this.controller?.dispatch(r)}focusInside(){return this.shadowRoot?.activeElement!=null}nothingFocused(){return t.activeElement===null||t.activeElement===t.body}render(r){let o=Me(r);if(!o){this.hide();return}let i=this.panel.hidden;if(i){let p=at(t);this.previousFocus=p instanceof e.HTMLElement&&p!==t.body?p:null}if(o.key!==this.viewKey){let p=this.focusInside();ve(this.viewKey,o.key)&&this.live?this.fillLive(this.live,o):this.build(o),this.viewKey=o.key,Se(p,this.focusInside(),o.key)&&this.panel.focus()}else this.updateSwitches(o),this.syncButtons(o);this.status.textContent=o.status??"",i&&(this.modal=be(r.openedByUser,o.closable),this.panel.hidden=!1,Ce(r.openedByUser,this.modal,this.nothingFocused())&&this.panel.focus())}hide(){if(this.panel.hidden)return;let r=ge(this.focusInside(),this.nothingFocused(),this.previousFocus);this.panel.hidden=!0,this.modal=!1,this.viewKey=null,this.closeButton=null,this.live=null,this.buttons=[],this.status.textContent="",this.previousFocus=null,r?.focus()}build(r){if(this.closable=r.closable,this.heading.textContent=r.title,this.closeButton?.remove(),this.closeButton=null,r.closable){let o=t.createElement("button");o.type="button",o.className="close",o.setAttribute("aria-label",C.close),o.appendChild(st(t)),o.addEventListener("click",()=>this.dispatch({type:"close"})),this.header.appendChild(o),this.closeButton=o}if(this.body.replaceChildren(),r.paragraphs.forEach((o,i)=>{let p=t.createElement("p");if(p.textContent=o,i===r.paragraphs.length-1&&r.policy){let f=t.createElement("a");f.href=r.policy.href,f.target="_blank",f.rel="noopener noreferrer",f.textContent=r.policy.label,p.append(" ",f),r.policy.trailingPeriod&&p.append(".")}this.body.appendChild(p)}),r.subtitle){let o=t.createElement("p");o.textContent=r.subtitle,this.body.appendChild(o)}if(r.switches.length&&this.body.appendChild(this.buildSwitches(r)),this.actions.replaceChildren(),this.live=null,r.liveButtons){let o=t.createElement("div");o.className="live",o.setAttribute("aria-live","polite"),this.fillLive(o,r),this.actions.appendChild(o),this.live=o}else this.buttons=r.buttons.map(o=>this.buildButton(o)),this.actions.append(...this.buttons);this.actions.appendChild(this.status)}fillLive(r,o){if(this.buttons=o.buttons.map(i=>this.buildButton(i)),r.replaceChildren(...this.buttons),o.note){let i=t.createElement("p");i.className="note",i.textContent=o.note,r.appendChild(i)}}buildButton(r){let o=t.createElement("button");if(o.type="button",o.textContent=r.label,r.kind==="disabled")o.className="btn btn-disabled",o.disabled=!0;else{o.className=r.primary?"btn btn-primary":"btn btn-secondary",r.busy&&o.setAttribute("aria-disabled","true");let i=r.action;o.addEventListener("click",()=>{o.getAttribute("aria-disabled")!=="true"&&this.dispatch(i)})}return o}syncButtons(r){r.buttons.forEach((o,i)=>{let p=this.buttons[i];!p||o.kind!=="action"||(o.busy?p.setAttribute("aria-disabled","true"):p.removeAttribute("aria-disabled"))})}buildSwitches(r){let o=t.createElement("ul");return o.className="list",r.switches.forEach(i=>{let p=`dgc-purpose-${i.code}`,f=t.createElement("li");f.className="item";let y=t.createElement("input");y.type="checkbox",y.className="switch",y.id=p,y.setAttribute("role","switch"),y.checked=i.checked,y.dataset.code=i.code,i.required&&y.setAttribute("aria-disabled","true"),i.description&&y.setAttribute("aria-describedby",`${p}-desc`),y.addEventListener("click",m=>{i.required&&m.preventDefault()}),y.addEventListener("change",()=>this.dispatch({type:"toggle",code:i.code}));let d=t.createElement("div");d.className="item-text";let h=t.createElement("label");if(h.className="item-name",h.htmlFor=p,h.textContent=i.name,i.required){let m=t.createElement("span");m.className="sr-only",m.textContent=` ${C.alwaysOn}`,h.appendChild(m)}if(d.appendChild(h),i.description){let m=t.createElement("p");m.className="item-desc",m.id=`${p}-desc`,m.textContent=i.description,d.appendChild(m)}f.append(y,d),o.appendChild(f)}),o}updateSwitches(r){r.switches.forEach(o=>{let i=this.shadowRoot?.getElementById(`dgc-purpose-${o.code}`);i&&i.checked!==o.checked&&(i.checked=o.checked)})}focusables(){return Array.from(this.panel.querySelectorAll(lt))}onKeyDown(r){let o=!this.panel.hidden;if(me(r.key,o,this.closable)){this.dispatch({type:"close"});return}if(!o)return;let i=ye({key:r.key,shiftKey:r.shiftKey,modal:this.modal,panel:this.panel,items:this.focusables(),active:this.shadowRoot?.activeElement??null,nothingFocused:this.nothingFocused()});i&&(r.preventDefault(),i.focus())}}n.define(K,l)}if(!n.get(N)){class l extends e.HTMLElement{controller=null;fallbackHref="";status=null;wrap;unfollowTheme=null;constructor(){super();let r=this.attachShadow({mode:"open"});r.adoptedStyleSheets=a(we),this.wrap=t.createElement("div"),this.wrap.className="wrap",r.appendChild(this.wrap)}attach(r,o){this.controller||(this.controller=r,this.fallbackHref=o,r.subscribe(()=>this.render()),this.render())}connectedCallback(){this.unfollowTheme?.(),this.unfollowTheme=Fe(e,this)}disconnectedCallback(){this.unfollowTheme?.(),this.unfollowTheme=null}render(){let r=this.controller?.getStatus()??"loading";if(r!==this.status){if(this.status=r,this.wrap.replaceChildren(),this.hidden=r==="loading",r==="ready"){let o=t.createElement("button");o.type="button",o.className="link",o.setAttribute("data-dg-consent","privacy-choices"),o.append(it(t),C.footerLink),o.addEventListener("click",()=>this.controller?.dispatch({type:"show"})),this.wrap.appendChild(o)}else if(r==="unavailable"){let o=t.createElement("a");o.className="link",o.href=this.fallbackHref,o.target="_blank",o.rel="noopener noreferrer",o.setAttribute("data-dg-consent","privacy-policy"),o.textContent=C.footerFallback,this.wrap.appendChild(o)}}}}n.define(N,l)}};var ct="#dg-privacy-choices",pt="#fern-footer";var Q=e=>{let{win:t,footer:n}=e,s=e.banner??null,a=t.document,l=e.footerSelector??pt,c=!1,r=new t.MutationObserver(()=>f()),o=()=>{if(r.disconnect(),c)return;let d=a.documentElement,h=a.body;if(r.observe(d,{childList:!0}),!h)return;let m=a.querySelector(l);if(!m){r.observe(h,{childList:!0,subtree:!0});return}r.observe(h,{childList:!0});for(let u=m.parentNode;u&&u!==h;u=u.parentNode)r.observe(u,{childList:!0});n.parentNode===m&&r.observe(m,{childList:!0})},i=()=>{if(c)return;let d=a.body;s&&d&&!s.isConnected&&d.insertBefore(s,d.firstChild);let h=a.querySelector(l);h&&n.parentNode!==h&&h.appendChild(n),o()},p=null,f=()=>{p!==null||c||(p=t.setTimeout(()=>{p=null,i()},50))},y=d=>{let h=d.target,m=h&&typeof h.closest=="function"?h.closest("a"):null;!m||m.getAttribute("href")!==ct||(d.preventDefault(),e.onPrivacyChoicesLink())};return a.addEventListener("click",y),t.addEventListener("astro:after-swap",i),t.addEventListener("astro:page-load",i),i(),{ensure:i,stop:()=>{c=!0,r.disconnect(),p!==null&&t.clearTimeout(p),p=null,a.removeEventListener("click",y),t.removeEventListener("astro:after-swap",i),t.removeEventListener("astro:page-load",i)}}};var ut="[Consent] ",dt="dg-consent-reported:";var ht=e=>!!(e&&typeof e.captureMessage=="function"&&typeof e.getClient=="function"&&e.getClient()),ee=e=>{let t=new Set,n=c=>dt+c,s=c=>{try{return!!e.sessionStorage?.getItem(n(c))}catch{return!1}},a=c=>{try{e.sessionStorage?.setItem(n(c),"1")}catch{}},l=(c,r,o,i)=>{try{let p=e.Sentry;if(ht(p)){p.captureMessage(r,{level:"warning",extra:o,tags:{surface:"developers",component:"dg-consent"}}),a(c);return}}catch{}try{if(e.setTimeout&&i<2e4){e.setTimeout(()=>l(c,r,o,i+250),250);return}e.console?.warn(r,o)}catch{}};return(c,r={})=>{try{if(t.has(c)||(t.add(c),s(c)))return;l(c,ut+c,r,0)}catch{}}};var We=15e3,ft=150,yt=e=>Le(e)?"ready":Ke(e)?"unavailable":"loading",je=e=>{let{core:t,report:n}=e,s=e.setTimeout??((u,b)=>setTimeout(u,b)),a=e.clearTimeout??(u=>clearTimeout(u)),l=Oe,c=null,r=!1,o=new Set,i=new Set,p=[],f=(u,b)=>{let g=s(()=>{i.delete(g),b()},u);i.add(g)},y=u=>{switch(u.type){case"accept-all":t.acceptAll();break;case"reject-all":t.rejectAll();break;case"set-consent":t.setConsent(u.purposes);break;case"mark-banner-shown":t.setBannerShownCookie();break;case"schedule-dismiss":f(Pe,()=>d({type:"opt-out-expired",timer:u.timer}));break;case"schedule-save-timeout":f($,()=>d({type:"save-timeout",id:u.id}));break;case"focus-close-button":f(ft,()=>e.focusCloseButton?.());break;case"report":n(u.message,u.context);break;default:}},d=u=>{let{state:b,effects:g}=Be(l,u,{forcedVariant:e.forcedVariant??null});l=b,g.forEach(k=>{try{y(k)}catch(w){n(`Consent effect "${k.type}" threw`,{error:String(w)})}}),o.forEach(k=>{try{k(l)}catch(w){n("Consent view update threw",{error:String(w)})}})};return{getState:()=>l,getStatus:()=>yt(l),getReadyInfo:()=>c,dispatch:d,subscribe:u=>(o.add(u),()=>o.delete(u)),start:()=>{if(!r){if(r=!0,!e.hasKetch()){d({type:"unavailable",reason:"window.ketch is missing"});return}try{p.push(t.reloadOnWithdrawal())}catch(u){n("Consent reload on withdrawal failed to start",{error:String(u)})}p.push(t.onConsentReady(({jurisdiction:u,config:b,consent:g,needsConsent:k})=>{let w=L(g);w||n("Ketch ready payload had non-boolean purposes; treating as none granted",{consent:g});let te=e.recordedNeedsConsent?.(),ne=k??(typeof te=="boolean"?te:null),oe=t.buildBannerSnapshot(u,b),re=t.shouldAutoOpenBanner(u,ne,b);c={jurisdiction:u,optIn:oe.optIn,needsConsent:ne,autoShow:re},d({type:"ready",snapshot:oe,purposes:w?g:{},autoShow:re})})),p.push(t.subscribeKetchEvents({consent:({purposes:u})=>{L(u)?d({type:"consent-updated",purposes:u}):n("Ketch consent event had missing or non-boolean purposes; keeping previous",{purposes:u})},userConsentUpdated:({purposes:u})=>{L(u)?d({type:"saved",purposes:u}):n("Ketch userConsentUpdated had missing or non-boolean purposes; ignored",{purposes:u})}})),e.onBootFailure&&p.push(e.onBootFailure(u=>d({type:"unavailable",reason:u}))),f(We,()=>{l.content||d({type:"unavailable",reason:`config not resolved within ${We}ms`})})}},stop:()=>{p.splice(0).forEach(u=>u()),i.forEach(a),i.clear(),o.clear()}}};var mt="developers.deepgram.com",Ct="Browser lacks custom elements or constructable stylesheets; banner not shown",Ge="Consent banner failed to start",bt='script[src*="ketchcdn.com/web/v3/config/"]',gt=e=>{if(e.__dgConsentDisabled===!0||e.DeepgramConsent)return;let t=ee(e),n=e.document,s=Te(new URLSearchParams(e.location.search).get("dg_consent_variant")??void 0,e.location.hostname!==mt),a=null,l=je({core:{acceptAll:M,rejectAll:V,setConsent:R,setBannerShownCookie:H,onConsentReady:j,subscribeKetchEvents:W,buildBannerSnapshot:G,shouldAutoOpenBanner:Y,reloadOnWithdrawal:z},report:t,hasKetch:()=>typeof e.ketch=="function",recordedNeedsConsent:()=>{let o=e.dgKetchNeedsConsent;if(typeof o!="function")return null;let i=o();return typeof i=="boolean"?i:null},forcedVariant:s,focusCloseButton:()=>a?.focusClose(),onBootFailure:o=>{let i=n.querySelector(bt);if(!i)return()=>{};let p=()=>o("Ketch boot script failed to load");return i.addEventListener("error",p),()=>i.removeEventListener("error",p)}});e.DeepgramConsent={consentCore:"v1.4.0",get status(){return l.getStatus()},get readyInfo(){return l.getReadyInfo()},open:()=>l.dispatch({type:"show"})};let c;if(Ue(e)){He(e),a=n.createElement(K),a.attach(l);let o=n.createElement(N);o.attach(l,S),c=()=>{Q({win:e,banner:a,footer:o,onPrivacyChoicesLink:()=>e.DeepgramConsent?.open()}),l.start()}}else{t(Ct,{});let o=n.createElement("a");o.href=S,o.target="_blank",o.rel="noopener noreferrer",o.textContent=C.footerFallback,o.setAttribute("data-dg-consent","privacy-policy-fallback"),c=()=>{Q({win:e,footer:o,onPrivacyChoicesLink:()=>{e.open(S,"_blank","noopener")}})}}let r=()=>{try{c()}catch(o){t(Ge,{error:String(o)})}};n.body?r():n.addEventListener("DOMContentLoaded",r,{once:!0})};if(typeof window<"u")try{gt(window)}catch(e){ee(window)(Ge,{error:String(e)})}})(); diff --git a/web/src/consent/SOURCE.json b/web/src/consent/SOURCE.json new file mode 100644 index 00000000..e4167f5a --- /dev/null +++ b/web/src/consent/SOURCE.json @@ -0,0 +1,13 @@ +{ + "note": "Vendored verbatim from deepgram/deepgram-docs so cli.deepgram.com matches developers.deepgram.com. Do not edit by hand; re-copy both files from the same docs commit.", + "repo": "https://github.com/deepgram/deepgram-docs", + "commit": "b807ab4613f9b138c761a7f21339975108c2e00b", + "files": { + "web/src/consent/ketch.js": "fern/assets/ketch.js", + "web/public/consent/dg-consent.js": "fern/assets/dg-consent.js (built from tools/consent-banner)" + }, + "sha256": { + "ketch.js": "00348a71e084e22ca2096d50f5d9179f572b7a753220436203c2c2590224f2b0", + "dg-consent.js": "a9ba240426d3299fde1bc365897c677dfde1cf7403ac11e5ae5a56fb6d30eee0" + } +} diff --git a/web/src/consent/ketch.js b/web/src/consent/ketch.js new file mode 100644 index 00000000..41031135 --- /dev/null +++ b/web/src/consent/ketch.js @@ -0,0 +1,96 @@ +// Ketch consent manager loader. Must run before Google Tag Manager and every +// other tracking script, so it is the first `beforeInteractive` entry in +// docs.yml and GTM is loaded from ./gtm.js right after it (not from Fern's +// built-in `analytics.gtm`, which Fern always renders ahead of custom JS). +// The line below is Ketch's snippet verbatim, minus the @@ -438,20 +446,8 @@ const commandCards: CommandCard[] = [ ] })} /> - - - - - - + +
@@ -913,10 +909,14 @@ const commandCards: CommandCard[] = [