"use strict";const l=require("./FetchConfigsUtils-c73b687c.js"),e=require("zod"),s=require("./useDiscoveryConfigs-367fb38f.js"),p=class{};let u=p;u.normalizeColor=t=>t>255?255:t<0?0:t;u.getHexWithoutHash=t=>{let a=t.replace("#","");return a.length===3&&(a=`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`),a};u.hexToRGB=t=>{const a=p.getHexWithoutHash(t),n=parseInt(a.substring(0,2),16),o=parseInt(a.substring(2,4),16),i=parseInt(a.substring(4,6),16);return`${n},${o},${i}`};u.shadeColor=(t,a)=>{const n=p.getHexWithoutHash(t),o=parseInt(n,16),i=p.normalizeColor((o>>16)+a),m=p.normalizeColor((o&255)+a),C=p.normalizeColor((o>>8&255)+a);return`#${(m|C<<8|i<<16).toString(16)}`};u.lightenColor=(t,a)=>p.shadeColor(t,a);u.darkenColor=(t,a)=>p.shadeColor(t,a*-1);const S="odin-styles",f=class{static bgOverlayToCss(t,a=":root"){let n="";return t.length>0&&(n=t.map(({id:o,opacity:i})=>!o||!i?null:`--od-overlay-${o}-opacity: ${i/100};`).filter(o=>!!o).join(`
`)),`${a} {${n}}`}static colorConfigToCss(t,a=":root"){const n=Object.entries(t).map(([o,i])=>{if(!(i!=null&&i.rgb))return null;const m=[],{r:C,g:L,b:I,a:D}=i.rgb,d=`${C},${L},${I}`;if(o==="primary"){const b=u.lightenColor(i.hex,90),F=u.hexToRGB(b),j=`--od-rgb-${o}-20: ${F};`,v=u.lightenColor(i.hex,70),T=u.hexToRGB(v),y=`--od-rgb-${o}-40: ${T};`,x=u.lightenColor(i.hex,50),E=u.hexToRGB(x),V=`--od-rgb-${o}-60: ${E};`;m.push(j,y,V)}if(o==="text"){const b=`--od-rgba-${o}-default: ${d}, 0.65;`;m.push(b)}const h=`
        --od-rgba-${o}: ${d},${D};
        --od-rgb-${o}: ${d};
        --od-a-${o}: ${D};
        `;return m.push(h),m.join(`
`)}).filter(o=>!!o).join(`
`);return`${a} {${n}}`}static fontConfigToCssVar(t,a=":root"){const n=["title","body"].map(o=>{const i=o==="body"?"customBodyFontUrl":"customTitleFontUrl";return`--od-font-${o}: "${this.extractFontNameFromFontUrl(t[i])||t[o]}";`}).join(`
`);return`${a} {${n}}`}static generateImports(t){return[(t==null?void 0:t.customBodyFontUrl)??"",(t==null?void 0:t.customTitleFontUrl)??""].filter(Boolean).map(a=>`@import url('${a}');`).join("")}};let g=f;g.injectCss=t=>{const a=document.getElementById(S),n=a??document.createElement("style");n.id=S,n.innerHTML=t,a||document.head.appendChild(n)};g.removeInjectedCss=()=>{const t=document.getElementById(S);t&&t.remove()};g.extractFontNameFromFontUrl=t=>{var a;try{return((a=new URL(t).searchParams.get("family"))==null?void 0:a.replace(/:.*/,""))||null}catch{return null}};g.convertConfigToCss=t=>{var d,h,b,F,j,v,T,y;const a=(h=(d=t==null?void 0:t.data)==null?void 0:d.global)==null?void 0:h.fonts,n=f.fontConfigToCssVar(a),o=f.generateImports(a),i=((F=(b=t==null?void 0:t.data)==null?void 0:b.global)==null?void 0:F.colors)??{},m=f.colorConfigToCss(i),C={id:"main",...(v=(j=t==null?void 0:t.data)==null?void 0:j.mainPage)==null?void 0:v.backgroundOverlay},L={id:"login",...(y=(T=t==null?void 0:t.data)==null?void 0:T.loginPage)==null?void 0:y.backgroundOverlay},I=f.bgOverlayToCss([C,L]);return[o,m,I,n].join(" ")};const k=e.z.object({isKnowledgeBaseEnabled:e.z.boolean()}),N=e.z.object({email:e.z.string(),isUseExternalSupportEnabled:e.z.boolean(),externalSupportURL:e.z.string()}),G=e.z.object({isPlayerPortalEnabled:e.z.boolean(),isLauncherEnabled:e.z.boolean()}),H=e.z.object({isDisabled:e.z.boolean(),redirectionURL:e.z.string(),siteBrandURL:e.z.string()}),R=e.z.object({id:e.z.string(),name:e.z.string(),link:e.z.string()}),B=e.z.object({links:e.z.array(R)});e.z.object({launcherDownloadLink:l.Config.merge(e.z.object({data:e.z.object({value:e.z.string()})})),metaData:l.Config.merge(e.z.object({data:e.z.object({description:e.z.string(),image:e.z.string(),title:e.z.string()})})),pageConfig:l.Config.merge(e.z.object({data:s.PageConfig})),footer:l.Config.merge(e.z.object({data:e.z.object({value:B})})),homepage:l.Config.merge(e.z.object({data:H})),logoVariant:l.Config.merge(e.z.object({data:s.LogoVariantConfig}))});const $=e.z.enum(["gameId","gameName","namespace","clientId"]),P=e.z.object({games:e.z.array(e.z.object({[$.enum.gameId]:e.z.string(),[$.enum.gameName]:e.z.string(),[$.enum.namespace]:e.z.string(),[$.enum.clientId]:e.z.string()}))}),U=e.z.object({isStreamButtonEnabled:e.z.boolean(),streamButton:e.z.object({label:e.z.string(),url:e.z.string()})});e.z.object({logoVariant:l.Config.merge(e.z.object({data:e.z.object({header:e.z.number().nullable()})})),gameList:l.Config.merge(e.z.object({data:P})),streamerInfo:l.Config.merge(e.z.object({data:U})),backgroundConfig:l.Config.merge(e.z.object({data:s.BackgroundConfig})),pageConfig:e.z.optional(l.Config.merge(e.z.object({data:s.PageConfig})))});const A=l.ppConfigJson,O=e.z.object({launcherDownloadLink:e.z.object({value:e.z.string()}),metaData:e.z.object({description:e.z.string(),image:e.z.string(),title:e.z.string()}).nullish(),footer:e.z.object({value:B}),logoVariant:s.LogoVariantConfig}),W=e.z.object({appId:e.z.object({value:e.z.string()}),avatarsList:e.z.object({value:e.z.array(e.z.string())}),brandName:e.z.object({value:e.z.string()}),pageTitle:e.z.object({value:e.z.string()}),companyLogo:s.CompanyLogoConfig,copyright:e.z.object({value:e.z.string()}),experimentalFeatureFlags:e.z.record(e.z.boolean()),globalPageConfig:s.GlobalStyleConfig,ppFeatureFlags:s.PlayerPortalFeatureFlagsConfig.omit({isNotificationsVisible:!0,isNewsVisible:!0,isSubscriptionsVisible:!0,isVirtualCurrencyVisible:!0,isNewsV2Visible:!0}).partial(),supportFeatureFlags:e.z.record(e.z.boolean()),socialLinks:e.z.object({value:e.z.array(s.SocialLinkConfig)}),templateConfig:e.z.object({value:e.z.union([e.z.literal(`${s.TemplateConfig.SINGLE}`),e.z.literal(`${s.TemplateConfig.MULTIPLE}`)])})}),_=e.z.object({logoVariant:e.z.object({header:e.z.number().nullable()}),gameList:P,streamerInfo:U,backgroundConfig:s.BackgroundConfig}),K=e.z.object({knowledgeBaseSettings:k,displayCTAButton:G,submissionForm:N}),w=class{};let c=w;c.createDiscoveryConfigs=t=>{if(t)return{appId:r(t.appId),avatarsList:r({value:t.avatarsList.value.join(`
`)}),brandName:r(t.brandName),pageTitle:r(t.pageTitle),companyLogo:r(t.companyLogo),copyright:r(t.copyright),experimentalFeatureFlags:r(t.experimentalFeatureFlags),favicon:r({value:""}),globalPageConfig:r(t.globalPageConfig),launcherFeatureFlags:r({}),launcherTemplateInfo:z(),legalTemplateInfo:z(),loginFeatureFlags:r({}),loginTemplateInfo:z(),paymentTemplateInfo:z(),ppFeatureFlags:r(s.PlayerPortalFeatureFlagsConfig.parse(t.ppFeatureFlags)),ppTemplateInfo:r({draft:"pp-default",published:"pp-default"}),supportFeatureFlags:r(t.supportFeatureFlags),socialLinks:r(t.socialLinks),templateConfig:r(t.templateConfig),twitchDropTemplateInfo:r({draft:"twitchdrop-default",published:"twitchdrop-default"}),supportTemplateInfo:z(),launcherIcon:r({value:""})}};c.createPlayerPortalConfigs=t=>{var a,n,o;if(t)return{footer:r(t.footer),homepage:r({isDisabled:!1,redirectionURL:"",siteBrandURL:""}),launcherDownloadLink:r(t.launcherDownloadLink),logoVariant:r(t.logoVariant),metaData:r({description:((a=t.metaData)==null?void 0:a.description)||"",image:((n=t.metaData)==null?void 0:n.image)||"",title:((o=t.metaData)==null?void 0:o.title)||""}),pageConfig:r(A.pageConfig.data)}};c.createTwitchDropConfigs=t=>{if(t)return{logoVariant:r(t.logoVariant),gameList:r(t.gameList),streamerInfo:r(t.streamerInfo),backgroundConfig:r(t.backgroundConfig)}};c.createSupportConfigs=t=>{if(t)return{knowledgeBaseSettings:r(t.knowledgeBaseSettings),displayCTAButton:r(t.displayCTAButton),submissionForm:r(t.submissionForm),pageConfig:r(l.supportConfigJson.pageConfig.data)}};c.getAppId=t=>(t==null?void 0:t.appId.data.value)||"";c.isSingleGame=t=>t===s.TemplateConfig.SINGLE;c.injectCss=(t,a)=>{const n=a.data.isLocalStyleEnabled,o=t.globalPageConfig;let i="";n?i=g.convertConfigToCss(a):o&&(i=g.convertConfigToCss(o)),w.isSingleGame(t.templateConfig.data.value)?g.injectCss(i):g.injectCss("")};c.getFeatureFlags=(t,a)=>{let n=null;switch(a){case l.AppName.WIDGET:n={...t.ppFeatureFlags.data,...t.experimentalFeatureFlags.data};break;case l.AppName.LAUNCHER:n={...t.launcherFeatureFlags.data,...t.experimentalFeatureFlags.data,...t.supportFeatureFlags.data};break}return n};function r(t){return{data:t,format:"",name:"",updatedAt:"",version:0}}function z(){return r({draft:"",published:""})}function q(t){return new Promise(a=>{setTimeout(()=>a(void 0),t)})}exports.AppBuilderUtils=g;exports.ConfigsUtils=c;exports.SimplifiedDiscoveryConfigData=W;exports.SimplifiedPlayerPortalConfigData=O;exports.SimplifiedSupportConfigData=K;exports.SimplifiedTwitchDropConfigData=_;exports.wait=q;
