View file File name : 100.js Content :"use strict";(globalThis.webpackChunknewfold_Onboarding=globalThis.webpackChunknewfold_Onboarding||[]).push([[100],{1100:(e,t,a)=>{a.r(t),a.d(t,{default:()=>E});var o=a(1609),n=a(8468),l=a(7143),c=a(6427),r=a(3957),s=a(8744),i=a(1056),m=a(2202);const d=({idx:e,label:t,selectedPalette:a,setSelectedPalette:n,setSelectedColor:l,colors:c,setShowCustomColors:r=null})=>{const d=`conic-gradient(${c[e].primary} 90deg, ${c[e].secondary} 90deg 150deg, ${c[e].tertiary} 150deg 330deg, ${c[e].primary} 330deg 360deg)`,u="nfd-onboarding-sidebar--customize__color-palette-icon";return(0,o.createElement)("div",{className:`${u}__container`},(0,o.createElement)("div",{role:"presentation",className:a===e?`${u}__container__icon__selected`:`${u}__container__icon`,style:{background:d},onClick:()=>{n(e),l(c[e]);const{isDefault:t,...a}=c[e];(0,i.v)(new i.iC(m.Ep,"generated",{colors:a,source:s.d0})),r&&r(!1)}}),(0,o.createElement)("p",null,t))};var u=a(7723);const _=({onChange:e,palettePrimaryColors:t})=>{const[a,l]=(0,n.useState)(t[0].color),r=[{colors:t,name:(0,u.__)("THEME","wp-module-onboarding")}];return(0,o.createElement)(c.Popover,{placement:"left"},(0,o.createElement)("div",{className:"nfd-onboarding-sidebar--customize__custom-color-palette__container"},(0,o.createElement)(c.ColorPalette,{colors:r,value:a,onChange:t=>{l(t),e(t)}})))};var p=a(7675),g=a(6087);const E=(0,o.forwardRef)((({baseClassName:e="nfd-onboarding-sidebar--customize__design-colors-panel",heading:t},a)=>{const E=()=>{R(0),N(S[0]),O(!1)};(0,o.useImperativeHandle)(a,(()=>({resetToDefaultColors:E})));const{currentData:b,customizeSidebarData:h,themeColors:C}=(0,l.useSelect)((e=>({currentData:e(p.M).getCurrentOnboardingData(),customizeSidebarData:e(p.M).getCustomizeSidebarData(),themeColors:e(p.M).getPreviewSettings().settings.colors})));(0,n.useEffect)((()=>{const e=b.sitegen?.homepages?.active?.slug;let t=b.sitegen.homepages.active.color.defaultPalette;t||(t=(0,g.cloneDeep)(b.sitegen.homepages.active.color.palette),b.sitegen.homepages.data[e].color.defaultPalette=t,b.sitegen.homepages.active.color.defaultPalette=t,H(b))}),[b]);const y=h?.colorPalettes;let f=C?.map((e=>({name:e.name,color:e.color})));f||(f=Object.entries(y[0]).map((([,e])=>({name:(0,u.__)("Custom","wp-module-onboarding"),color:e}))));const v=(()=>{const e=[],t=b?.sitegen?.homepages?.active?.color?.defaultPalette||b?.sitegen?.homepages?.active?.color?.palette;return y.forEach((a=>{let o=!0;["primary","base","tertiary"].forEach((e=>{const n=a[e],l=t.find((t=>t.slug===e))?.color;n!==l&&(o=!1)}));const n={primary:a?.primary,secondary:a?.secondary||a?.base,tertiary:a?.tertiary||a?.primary,isDefault:o};o?e.unshift(n):e.push(n)})),e})(),[S]=(0,n.useState)(v),[w,P]=(0,n.useState)(null),[$,N]=(0,n.useState)({}),[k,O]=(0,n.useState)(!1),[D,M]=(0,n.useState)(!1),[x,z]=(0,n.useState)(!1),[T,R]=(0,n.useState)(null),[j,A]=(0,n.useState)(""),[B,U]=(0,n.useState)(!1);(0,n.useEffect)((()=>{const e=b.sitegen.homepages.active.color;if(!w){const t=e.customColors;P(t||v[0])}if(!T&&0!==T){const t=e.selectedPalette||0;R(t),"custom"===t&&(O(!0),z(!0))}}),[b]);const L=e=>{U(!B),A(B?"":e)},{setCurrentOnboardingData:H}=(0,l.useDispatch)(p.M);(0,n.useEffect)((()=>{0!==Object.keys($).length&&null!==T&&(()=>{const e=b.sitegen?.homepages?.active?.slug;if(!e)return;const t=b.sitegen.homepages.active.color;"custom"===T&&(t.customColors=$),t.selectedPalette=T;const a=y["custom"===T?0:T];a.primary=$.primary,a.secondary=$.secondary,a.base=$.secondary,a.tertiary=$.tertiary,t.palette=(e=>{const t=[];for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)){const o=a.replace(/_/g,"-"),n=e[a],l=a.split("_").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" ");t.push({slug:o,color:n,name:l})}return t})(a),b.sitegen.homepages.data[e].color=t,H(b)})()}),[$,T]);return(0,o.createElement)(c.PanelBody,{className:e,initialOpen:!0},(0,o.createElement)(c.PanelRow,null,(0,o.createElement)("div",{className:`${e}__container`},(0,o.createElement)("div",{className:`${e}__container__text`},(0,o.createElement)("p",{className:`${e}__container__text__heading`},(0,o.createElement)("strong",null,t)),(0,o.createElement)("div",{className:`${e}__container__color__palette__icon`},S.map(((e,t)=>(0,o.createElement)(d,{key:t,idx:t,label:0===t?(0,u.__)("Default","wp-module-onboarding"):"",selectedPalette:T,setSelectedPalette:R,setSelectedColor:N,colors:S,setShowCustomColors:O}))))))),(0,o.createElement)(c.PanelRow,null,!k&&(0,o.createElement)("div",{className:`${e}__custom__colors__button__container`},(0,o.createElement)(c.Button,{onClick:()=>(R("custom"),N(w),O(!0),void(x||M(!0)))},(0,u.__)("Pick your own colors","wp-module-onboarding"))),k&&D&&(0,o.createElement)("div",{className:`${e}__custom__colors__container`},(0,o.createElement)("h5",{className:`${e}__heading`},(0,u.__)("CUSTOM COLORS","wp-module-onboarding")),(0,o.createElement)("div",null,["primary","secondary","tertiary"].map(((e,t)=>(0,o.createElement)(r.A,{key:t,isColorSelected:$,color:$[e],slug:e,name:e.charAt(0).toUpperCase()+e.slice(1),callback:L})))),(0,o.createElement)("div",{className:`${e}__custom__colors__container__buttons`},(0,o.createElement)(c.Button,{onClick:()=>{x?M(!1):O(!1)},className:"cancel"},(0,u.__)("Cancel","wp-module-onboarding")),(0,o.createElement)(c.Button,{onClick:()=>{z(!0),M(!1),R("custom"),P($);const{isDefault:e,...t}=$;(0,i.v)(new i.iC(m.Ep,"custom",{colors:t,source:s.d0}))},variant:"primary"},(0,u.__)("Apply","wp-module-onboarding"))),B&&(0,o.createElement)(_,{onChange:e=>{const t={...$};t[j]=e,N(t)},palettePrimaryColors:f})),k&&!D&&(0,o.createElement)("div",{className:`${e}__custom-color-palette__container`},(0,o.createElement)("div",{className:`${e}__custom-color-palette__container__header`},(0,o.createElement)("h5",{className:`${e}__heading`},(0,o.createElement)("span",null,(0,u.__)("CUSTOM COLORS","wp-module-onboarding"))),(0,o.createElement)("button",{onClick:()=>(R("custom"),N(w),void M(!0))},(0,u.__)("Edit colors","wp-module-onboarding"))),(0,o.createElement)("div",{style:{marginLeft:"5px"}},(0,o.createElement)(d,{key:"custom",idx:"custom",selectedPalette:T,setSelectedPalette:R,setSelectedColor:N,colors:{custom:w}})))))}))}}]);