Changeset 3079624
- Timestamp:
- 04/30/2024 07:23:13 PM (21 months ago)
- Location:
- coblocks
- Files:
-
- 14 edited
- 1 copied
-
tags/3.1.9 (copied) (copied from coblocks/trunk)
-
tags/3.1.9/class-coblocks.php (modified) (2 diffs)
-
tags/3.1.9/dist/coblocks-extensions.asset.php (modified) (1 diff)
-
tags/3.1.9/dist/coblocks-extensions.js (modified) (1 diff)
-
tags/3.1.9/readme.txt (modified) (2 diffs)
-
tags/3.1.9/src/blocks/events/index.php (modified) (2 diffs)
-
tags/3.1.9/src/blocks/post-carousel/index.php (modified) (1 diff)
-
tags/3.1.9/src/blocks/posts/index.php (modified) (1 diff)
-
trunk/class-coblocks.php (modified) (2 diffs)
-
trunk/dist/coblocks-extensions.asset.php (modified) (1 diff)
-
trunk/dist/coblocks-extensions.js (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/blocks/events/index.php (modified) (2 diffs)
-
trunk/src/blocks/post-carousel/index.php (modified) (1 diff)
-
trunk/src/blocks/posts/index.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
coblocks/tags/3.1.9/class-coblocks.php
r3062838 r3079624 5 5 * Author: GoDaddy 6 6 * Author URI: https://www.godaddy.com 7 * Version: 3.1. 87 * Version: 3.1.9 8 8 * Text Domain: coblocks 9 9 * Domain Path: /languages … … 27 27 } 28 28 29 define( 'COBLOCKS_VERSION', '3.1. 8' );29 define( 'COBLOCKS_VERSION', '3.1.9' ); 30 30 define( 'COBLOCKS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 31 31 define( 'COBLOCKS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
coblocks/tags/3.1.9/dist/coblocks-extensions.asset.php
r3042794 r3079624 1 <?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-primitives', 'wp-rich-text', 'wp-token-list'), 'version' => ' d26d885b084d3e421c8b');1 <?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-primitives', 'wp-rich-text', 'wp-token-list'), 'version' => '07e78ed2fd9aae93aa49'); -
coblocks/tags/3.1.9/dist/coblocks-extensions.js
r3042794 r3079624 59 59 (0,c.__)("Could not create a new %s.","coblocks"),e.labels.singular_name))}))}onActivateRename=e=>{const{setRenameMode:t}=this.props;t(e.id).then((()=>{this.inputRefs[e.id].focus(),document.execCommand("selectAll",!1,null),document.getSelection().collapseToEnd()}))};onCompleteRename=e=>{const{props:t}=this,o=this.inputRefs[e.id].textContent;e.title.raw!==o&&Dt()({data:{title:o},method:"POST",path:`/wp/v2/${t.postType.rest_base}/${e.id}`}).then((e=>{t.receiveEntityRecords("postType",t.postType.slug,e,{},!0)})),this.onResetRename()};onResetRename=e=>{const{cancelRenameMode:t}=this.props;e&&(this.inputRefs[e.id].textContent=e.title.raw),t()};onPin(e){const{props:t}=this;Dt()({data:{sticky:!e.sticky},method:"POST",path:`/wp/v2/${t.postType.rest_base}/${e.id}`}).then((e=>{t.receiveEntityRecords("postType",t.postType.slug,e,{},!0)}))}onSetAsHome=e=>{const{props:t}=this;Dt()({data:{page_on_front:e.id},method:"POST",path:t.settingsEntity.baseURL}).then((o=>{t.receiveEntityRecords("root","site",o,{},!0),t.createSuccessNotice((0,c.sprintf)( 60 60 // translators: %s is the page title. 61 (0,c.__)('"%s" set as the homepage.',"coblocks"),e.title.raw),{type:"snackbar"})}))};handleInputKeys=(e,t)=>{switch(e.key){case"Enter":e.preventDefault(),this.onCompleteRename(t);break;case"Escape":this.onResetRename(t);break;case" ":e.stopPropagation(),e.preventDefault()}};getOrderedPublishedPages=()=>{const{entities:e,homepageId:t,homepostId:o}=this.props,l=e.filter((e=>"draft"!==e.status&&e.id!==o));return l.sort(((e,o)=>e.id===t?-1:o.id===t?1:0)),l};getOrderedPublishedPosts=()=>{const{entities:e}=this.props;return[...e.filter((e=>"draft"!==e.status&&e.sticky)),...e.filter((e=>"draft"!==e.status&&!e.sticky))]};getOrderedDrafts=()=>{const{entities:e}=this.props;return e.filter((e=>"draft"===e.status)).reverse()};renderIcon=e=>{const{homepageId:t,homepageType:o}=this.props;return e.sticky?Yr:e.id===t&&"page"===o?Wr:"post"===e.type?qr:$r};renderPageTitle=e=>{const{isInRenameMode:t}=this.props;return e.id===t?this.inputRefs[e.id]?.textContent!==(0,c.__)("(no title)","coblocks")?this.inputRefs[e.id].textContent:"":e.title.raw?e.title.raw:(0,c.__)("(no title)","coblocks")};renderRow=(e,t)=>{const{currentPostId:o,homepageId:l,homepageType:n,loadPostIntoEditor:r,isInRenameMode:s}=this.props,c=this.renderPageTitle(e),u=e.id===s;return(0,a.createElement)(i.PanelRow,{className:J()("content-management__panel__row",{current:o===e.id,"is-renaming":u}),key:t},(0,a.createElement)(i.Button,{className:J()("content-management__panel__button"),isLink:!0,onClick:()=>!s&&r(e.type,e.id)},(0,a.createElement)(a.Fragment,null,this.renderIcon(e),(0,a.createElement)("span",{contentEditable:u,onKeyUp:t=>this.handleInputKeys(t,e),ref:t=>this.inputRefs[e.id]=t,role:"textbox"},c))),(0,a.createElement)(Qr,{isSticky:e.sticky,onDeletePost:()=>this.onDelete(e),onDuplicatePost:()=>this.onDuplicate(e),onPinPost:()=>this.onPin(e),onRenamePost:()=>this.onActivateRename(e,t),onSetAsHomePost:()=>this.onSetAsHome(e),postType:e.type,shouldDiplayPinAction:"post"===e.type&&"publish"===e.status,shouldDisplayHomepageAction:"page"===n&&"page"===e.type&&"publish"===e.status&&e.id!==l}),u&&(0,a.createElement)("div",{className:"content-management__panel__rename-actions"},(0,a.createElement)(i.Button,{className:"content-management__panel__rename-action content-management__panel__rename-action--confirm",onClick:()=>this.onCompleteRename(e)},(0,a.createElement)(i.Icon,{icon:ae,size:22})),(0,a.createElement)(i.Button,{className:"content-management__panel__rename-action content-management__panel__rename-action--cancel",onClick:()=>this.onResetRename(e)},(0,a.createElement)(i.Icon,{icon:Dr,size:20}))))};render(){const{props:e}=this,t="page"===e.postType.slug?this.getOrderedPublishedPages():this.getOrderedPublishedPosts(),o=this.getOrderedDrafts();return(0,a.createElement)(i.PanelBody,{className:J()("content-management__panel",{"is-renaming":e.isInRenameMode}),initialOpen:e.postType.slug===e.currentPostType,key:e.postType.slug,title:e.postType.name},t&&t.map(this.renderRow),o&&o.length>0&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h3",{className:"content-management__panel__separator"},(0,a.createElement)("span",null,(0,c.__)("Drafts","coblocks"))),o.map(this.renderRow)),(0,a.createElement)(i.Tooltip,{text:e.postType.labels.add_new_item},(0,a.createElement)(i.Button,{className:"content-management__add-new-button",onClick:()=>this.onCreateNew(e.postType)},(0,a.createElement)(i.Icon,{icon:jr,size:28}))))}}var Jr=(0,ie.compose)([(0,$.withSelect)(((e,t)=>{const{getCurrentPostId:o,getCurrentPostType:l}=e("core/editor"),{getEntityRecords:n,getEntityRecord:r,getEntity:s}=e("core"),a={};(n("postType",t.postType.slug,{per_page:-1,status:["publish","future","pending","private","draft"]})||[]).forEach((e=>a[e.id]=e));const{page_on_front:c,page_for_posts:i,show_on_front:u}=r("root","site")||{},{isInRenameMode:m}=e("coblocks/site-content");return{currentPostId:o(),currentPostType:l(),entities:Object.values(a),homepageId:c,homepageType:u,homepostId:i,isInRenameMode:m(),settingsEntity:s("root","site")}})),(0,$.withDispatch)((e=>{const{editEntityRecord:t,receiveEntityRecords:o,saveEntityRecord:l}=e("core"),{savePost:n}=e("core/editor"),{createErrorNotice:r,createSuccessNotice:s}=e("core/notices"),{cancelRenameMode:a,setRenameMode:c}=e("coblocks/site-content"),{openTemplateSelector:i}=e("coblocks/template-selector");return{cancelRenameMode:a,createErrorNotice:r,createSuccessNotice:s,editEntityRecord:t,openTemplateSelector:i,receiveEntityRecords:o,saveEntityRecord:l,savePost:n,setRenameMode:c}}))])(Kr);const es="coblocks_site_content_controls_enabled",ts="undefined"!=typeof coblocksLabs?coblocksLabs:{},os=()=>{const{isGoThemeActive:e,isGoThemeInstalled:t,goThemeDetailsUri:o,goThemeInstallUri:l}=ts;return e&&t?(0,c.__)("This feature requires the Go Theme.","coblocks"):t?(0,a.createElement)(a.Fragment,null," ",(0,c.__)("This feature requires the Go Theme - ","coblocks"),(0,a.createElement)("a",{href:o,rel:"noopener noreferrer",target:"_blank"},(0,c.__)("Activate","coblocks"))):(0,a.createElement)(a.Fragment,null," ",(0,c.__)("This feature requires the Go Theme - ","coblocks"),(0,a.createElement)("a",{href:l,rel:"noopener noreferrer",target:"_blank"},(0,c.__)("Install now","coblocks")))},ls=()=>{const{isGoThemeActive:e,isGoThemeInstalled:t}=ts;return!e||!t};var ns=function({label:e,help:t,description:o,imageSrc:l,imageAlt:n,settingsKey:r,showGoHelp:s,conditionalDisable:c=!1}){const[u,m]=(0,ce.useEntityProp)("root","site",r);return(0,a.createElement)(Xt,null,(0,a.createElement)("section",{className:"coblocks-labs-modal__section"},(0,a.createElement)("div",{className:"coblocks-labs-modal__section__vertical-group"},(0,a.createElement)("h2",{className:"coblocks-labs-modal__section__heading"},e),o&&(0,a.createElement)("p",{className:"coblocks-labs-modal__section__description"},o),(0,a.createElement)(i.ToggleControl,{checked:!!u,disabled:!!c&&ls(),help:s?os():"",onChange:m})),(0,a.createElement)("figure",null,(0,a.createElement)("img",{alt:n,src:l}))),(0,a.createElement)("hr",null))},rs=o.p+"images/site-content.da68e2d6.png";(0,he.registerPlugin)("coblocks-site-content-control",{render:()=>(0,a.createElement)(ns,{description:(0,c.__)("Quickly and easily manage your websites pages and posts from inside the editor.","coblocks"),imageAlt:(0,c.__)("Site content example","coblocks"),imageSrc:rs,label:(0,c.__)("Site Content","coblocks"),settingsKey:es})}),(0,he.registerPlugin)("coblocks-site-content",{icon:z,render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const [e]=(0,ce.useEntityProp)("root","site",es),t=!!(0,$.select)("core/editor");return e&&t})),(0,$.withSelect)((e=>{const{getCurrentPostId:t,getEditedPostAttribute:o}=e("core/editor"),{getPostTypes:l}=e("core"),n=(l()||[]).filter((e=>!0===e.viewable&&["post","page"].includes(e.slug)));return{currentPageMeta:o("meta"),currentPostId:t(),postTypes:(0,re.sortBy)(n,["name"])}})),(0,$.withDispatch)((e=>{const{editPost:t}=e("core/editor");return{editPost:t}}))])((e=>{(0,m.useEffect)((()=>{const{currentPageMeta:t,editPost:o}=e;t&&"enabled"===t.hide_page_title&&wp.domReady((()=>{document.getElementsByClassName("edit-post-visual-editor__post-title-wrapper")[0]&&(document.getElementsByClassName("edit-post-visual-editor__post-title-wrapper")[0].style.display="none",o({meta:{hide_page_title:"enabled"}}))}))}),[]);const t=(e,t)=>{window.location.href=`/wp-admin/post.php?post=${t}&action=edit`},{postTypes:o}=e;return(0,a.createElement)("span",{"data-test":"site-content__container"},(0,a.createElement)(Ut.PluginSidebar,{className:"content-management",icon:(0,a.createElement)(Fr,{icon:z,label:(0,c.__)("Site content","coblocks"),slug:"site-content"}),title:(0,c.__)("Site contents","coblocks")},o.map((e=>(0,a.createElement)("span",{"data-test":"post-type-panel",key:e.slug},(0,a.createElement)(Jr,{loadPostIntoEditor:t,postType:e}))))))}))});var ss="coblocks/site-design";function as({slug:e,palette:t,isActive:o}){const l=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),n=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]),{updateColorPalette:r}=(0,$.useDispatch)(ss),s=J()("color-palette",{"is-selected":o}),c=(0,m.useCallback)((()=>{n!==e&&r(e)}),[e,n,l]);return(0,a.createElement)(i.Button,{className:s,onClick:c},Object.entries(t).reverse().map((([e,t])=>"background"!==e?(0,a.createElement)(i.ColorIndicator,{colorValue:t,key:`color-preview-${e}`}):null)))}function cs({previousPalette:e,onUpdateColors:t,onDismissCustom:o}){const l=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),n=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]);return l&&"custom"===n?(0,a.createElement)("div",{className:"color-palette-custom components-site-design__custom"},(0,a.createElement)("div",{className:"color-palette-custom__title"},(0,c.__)("Custom Colors","coblocks")),e&&(0,a.createElement)("button",{className:"components-site-design__custom__dismiss",onClick:o},(0,a.createElement)("span",null,(0,c.__)("Dismiss custom color","coblocks"))),Object.entries(l).map((([e,o])=>(0,a.createElement)(i.Dropdown,{key:`color-picker-${e}`,position:"bottom center",renderContent:()=>(0,a.createElement)(i.ColorPicker,{color:is(l,e,o),disableAlpha:!0,onChangeComplete:o=>{const l=document.getElementsByClassName(`has-${e}-background-color`);if(l.length)for(let e=0;e<l.length;e++)l[e].style.backgroundColor=o.hex;const n=document.getElementsByClassName(`has-${e}-color`);if(n.length)for(let e=0;e<n.length;e++)n[e].style.color=o.hex;t({[e]:o.hex})}}),renderToggle:({isOpen:t,onToggle:n})=>(0,a.createElement)(i.Button,{"aria-expanded":t,className:"color-palette-custom__color",isLink:!0,onClick:n},(0,a.createElement)(i.ColorIndicator,{colorValue:is(l,e,o),key:`color-${e}`}),us(e))})))):null}const is=(e,t,o)=>void 0!==Object.keys(e).shift()&&e[t]?e[t].includes("#")?e[t]:`#${e[t]}`:o,us=e=>{const t=e.toLowerCase().split(" ");for(let e=0;e<t.length;e++)t[e]=t[e].charAt(0).toUpperCase()+t[e].substring(1);return t.join(" ")};var ms=function(){const e=(0,$.useSelect)((e=>e("core/block-editor").getSettings),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),o=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),l=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]),n=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),r=(0,$.useSelect)((e=>e(ss).isColorsPanelOpen()),[]),s=(0,$.useDispatch)("core/block-editor").updateSettings,{updateCustomColors:u,updateColorPalette:d,toggleColorsPanel:h}=(0,$.useDispatch)(ss),[p,f]=(0,m.useState)(null);(0,m.useEffect)((()=>{n&&(g(),Object.entries(n).forEach((([e,t])=>{document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty(`--go--color--${e}`,t)})))}),[n]);const g=(t={})=>{const o={...n,...t};"custom"===l&&f(null),s({...e(),colors:Object.entries(o).map((([e,t])=>({name:e,slug:e,color:t})))}),u({...n,...t})};return(0,a.createElement)(i.PanelBody,{className:"site-design--colors__panel",onToggle:h,opened:r,title:(0,c.__)("Colors","coblocks")},(0,a.createElement)(i.BaseControl,{className:"components-site-design-color-palettes"},(0,a.createElement)(cs,{onDismissCustom:()=>d(p),onUpdateColors:g,previousPalette:p}),(0,a.createElement)("div",{className:"color-palettes"},(0,a.createElement)("div",{className:"color-palettes__title"},(0,a.createElement)("span",null,(0,c.__)("Color Palettes","coblocks")),"custom"!==l&&(0,a.createElement)("button",{className:"color-palettes__custom-button",onClick:()=>{f(l),d("custom"),g()}},(0,c.__)("Custom","coblocks"))),(0,a.createElement)("div",{className:"color-palettes__palettes"},t&&t.palettes.map((([e,t])=>(0,a.createElement)(as,{isActive:l.replace(`${o}-`,"")===e,key:`palette-${e}`,palette:t,slug:e})))))))},ds=function(){const e=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyles()),[]),o=(0,$.useSelect)((e=>e(ss).isDesignsPanelOpen()),[]),l=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),n=(0,$.useSelect)((e=>e(ss).isUpdating()),[]),r=t?.find((t=>t.slug===e)),{updateDesign:s,toggleDesignsPanel:u}=(0,$.useDispatch)(ss),m=(e,t)=>{const o=[e.tertiary,e.secondary,e.primary];return(0,a.createElement)("div",{className:"components-site-design-designs__design__colors"},o.map(((e,o)=>(0,a.createElement)("li",{className:"components-site-design-designs__design__color",key:`components-site-design-designs__design__color-${t}-${o}`,style:{backgroundColor:e}}))))};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.PanelBody,{className:"site-design--designs__panel components-site-design-designs",onToggle:u,opened:o,title:(0,c.__)("Design Styles","coblocks")},(0,a.createElement)("p",null,(0,c.__)("Easily explore curated design styles, then customize your colors and fonts to get the perfect fit.","coblocks")),(0,a.createElement)(Ir,null,t&&t.map(((t,o)=>(0,a.createElement)("button",{className:J()("components-site-design-designs__design",{"components-site-design-designs__design--selected":t.slug===e,"components-site-design-designs__design--updating":n}),"data-test":`design-button-${t.slug}`,key:`design-button-${t.slug}`,onClick:()=>(t=>{t!==e&&s({designStyle:t})})(t.slug)},(0,a.createElement)("div",{className:"components-site-design-designs__design__content"},(0,a.createElement)("div",{className:"components-site-design-designs__design__label",style:{fontFamily:Object.entries(t.fonts)[0][0]}},t.label),m(t.slug!==e||n?t.palettes[0][1]:l,o))))))),!o&&!!r&&(0,a.createElement)("div",{className:"components-site-design-design components-panel__body is-opened"},(0,a.createElement)("button",{className:"components-site-design-designs__design components-site-design-designs__design--current",onClick:u},(0,a.createElement)("div",{className:"components-site-design-designs__design__content"},(0,a.createElement)("div",{className:"components-site-design-designs__design__label",style:{fontFamily:Object.entries(r.fonts)[0][0]}},r.label),m(l,9999)))))},hs=function(){const e=(0,$.useSelect)((e=>e(ss).getFontSize()),[]),t=Number(e?.replace("rem","")),o=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),l=Number(o?.font_size?.replace("rem",""));return(0,m.useEffect)((()=>{t&&document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty("--go--font-size",`${t}rem`)}),[t]),[t,l]},ps=function(){const e=(0,$.useSelect)((e=>e(ss).getTypeRatio()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),o=t?.type_ratio;return(0,m.useEffect)((()=>{e&&document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty("--go--type-ratio",e)}),[e]),[e,o]};const fs="custom";var gs=function e(){const[t,o]=hs(),[l,n]=ps(),{updateFontSize:r,updateTypeRatio:s}=(0,$.useDispatch)(ss),u=(0,ie.useInstanceId)(e),d=(0,m.useMemo)((()=>function(e){return e?[{key:"small",name:(0,c.__)("Small","coblocks"),style:{fontSize:`${(.8*e).toFixed(2)}rem`}},{key:"normal",name:(0,c.__)("Normal","coblocks"),style:{fontSize:`${e.toFixed(2)}rem`}},{key:"large",name:(0,c.__)("Large","coblocks"),style:{fontSize:`${(1.3*e).toFixed(2)}rem`}},{key:fs,name:(0,c.__)("Custom")}]:[]}(o)),[o]),h=(0,m.useMemo)((()=>function(e,t){if(t){const o=e.find((e=>e.style?.fontSize===`${t.toFixed(2)}rem`));return o?o.key:fs}return"normal"}(d,t)),[d,t]),p=(0,m.useCallback)((({selectedItem:e})=>{const t=e?.style?.fontSize;t&&r(t)}));if(!d)return null;const f=`components-font-size-picker__number#${u}`;return(0,a.createElement)("fieldset",{className:"components-font-size-picker"},(0,a.createElement)(i.VisuallyHidden,{as:"legend"},(0,c.__)("Base size","coblocks")),(0,a.createElement)("div",{className:"components-font-size-picker__controls"},t&&(0,a.createElement)(i.CustomSelectControl,{className:"components-font-size-picker__select",label:(0,c.__)("Font size","coblocks"),onChange:p,options:d,value:d.find((e=>e.key===h))}),(0,a.createElement)("div",{className:"components-font-size-picker__number-container"},(0,a.createElement)("input",{"aria-label":(0,c.__)("Custom"),className:"components-font-size-picker__number",id:f,max:5,min:0,onChange:e=>{r(`${e.target.value}rem`)},step:.01,type:"number",value:t||""}))),(0,a.createElement)("div",{className:"components-font-size-picker__heading-container"},(0,a.createElement)(i.RangeControl,{className:"components-font-size-picker__heading-scale",initialPosition:l,label:(0,c.__)("Heading Scale","coblocks"),max:1.15*n,min:.9*n,onChange:s,showTooltip:!1,step:.01,value:l||"",withInputField:!1})))},vs=function(){const e=(0,$.useSelect)((e=>e(ss).getFonts()),[]),t=(0,$.useSelect)((e=>e(ss).getSelectedFonts()),[]);return(0,m.useEffect)((()=>{if(!t)return;const[e,o]=t[0],[l,n]=t[1],r=document.getElementsByClassName(siteDesign.editorClass)[0];r&&(r.style.setProperty("--go-heading--font-family",e),r.style.setProperty("--go-heading--font-weight",o[0]),r.style.setProperty("--go--font-family",l),r.style.setProperty("--go--font-weight",n[0]))}),[t]),[e,t]},ws=function(e){const[t,o]=hs(),[l,n]=ps(),[r,s]=vs(),{updateFontSize:u,updateTypeRatio:d,updateSelectedFonts:h}=(0,$.useDispatch)(ss),p=(0,m.useMemo)((()=>(e=>e.flat().sort().filter(((e,t,o)=>o.findIndex((t=>t[0]===e[0]))===t)).map((e=>({key:e[0],name:e[0],style:{fontFamily:e[0]},weights:e[1],weightsOptions:e[1].map((t=>({key:t,name:t,style:{fontWeight:t,fontFamily:e[0]}})))}))))(r)),[r]),[f,g]=s[0],[v,w]=s[1],y=p.find((e=>e.key===f)),b=y.weightsOptions.find((e=>e.key===g[0])),E=p.find((e=>e.key===v)),k=E.weightsOptions.find((e=>e.key===w[0])),{onClose:_}=e;return(0,a.createElement)("div",{className:"components-site-design__custom"},(0,a.createElement)("strong",null,(0,c.__)("Custom Font Options","coblocks")),(0,a.createElement)("button",{className:"components-site-design__custom__dismiss",onClick:_},(0,a.createElement)("span",null,"Dismiss custom color")),(0,a.createElement)("fieldset",{className:"components-site-design__custom__body"},(0,a.createElement)("strong",null,(0,c.__)("HEADING","coblocks")),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Font","coblocks"),onChange:({selectedItem:e})=>h([[e.key,e.weights],s[1]]),options:p,value:y}),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Weight","coblocks"),onChange:({selectedItem:e})=>h([[f,[e.key]],s[1]]),options:y.weightsOptions,value:b}),(0,a.createElement)(i.RangeControl,{initialPosition:l,label:(0,c.__)("Size","coblocks"),max:1.15*n,min:.9*n,onChange:d,showTooltip:!1,step:.01,value:l||"",withInputField:!1})),(0,a.createElement)("hr",{className:"components-site-design-fonts__advanced__separator"}),(0,a.createElement)("fieldset",{className:"components-site-design-fonts__advanced__heading"},(0,a.createElement)(i.VisuallyHidden,{as:"legend"},(0,c.__)("Heading font size","coblocks")),(0,a.createElement)("strong",null,(0,c.__)("BODY","coblocks")),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Font","coblocks"),onChange:({selectedItem:e})=>h([s[0],[e.key,e.weights]]),options:p,style:{fontFamily:E.key},value:E}),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Weight","coblocks"),onChange:({selectedItem:e})=>h([s[0],[v,[e.key]]]),options:E.weightsOptions,value:k}),(0,a.createElement)(i.RangeControl,{initialPosition:0,label:(0,c.__)("Size","coblocks"),max:(2*o).toFixed(2),min:(.8*o).toFixed(2),onChange:e=>u(`${e}rem`),showTooltip:!1,step:.01,value:t,withInputField:!1})))},ys=window.wp.dataControls;const bs="TOGGLE_COLORS_PANEL",Es="TOGGLE_DESIGNS_PANEL",ks="TOGGLE_FONTS_PANEL",_s="TOGGLE_IS_UPDATING",xs="UPDATE_COLOR_PALETTE",Cs="UPDATE_CUSTOM_COLORS",zs="UPDATE_DESIGN",Ss="UPDATE_DESIGN_STYLE",Ps="UPDATE_FONT_SIZE",Bs="UPDATE_REF_STATE",Vs="UPDATE_SELECTED_FONTS",Ms="UPDATE_TYPE_RATIO",{resolveSelect:Gs}=$.controls;function*Ts({designStyle:e="none",saveChanges:t=!1,initialLoad:o=!1}){const l=yield Gs(ss,"getColorPalette");let{colorPalette:n=("custom"===l?"custom":"one"),customColors:r=("custom"===l?yield Gs(ss,"getCurrentColors"):null),fonts:s=!1,fontSize:a=!1,typeRatio:c=!1}={};t&&(e=yield Gs(ss,"getDesignStyle"),n=yield Gs(ss,"getColorPalette"),r=yield Gs(ss,"getCurrentColors"),s=yield Gs(ss,"getSelectedFonts"),s=(0,re.cloneDeep)(s),siteDesign.isAdvancedFontsEnabled&&(s[0][0]=`${s[0][0]}_heading`,s[1][0]=`${s[1][0]}_body`),s=JSON.stringify(Object.fromEntries(s)),a=yield Gs(ss,"getFontSize"),c=yield Gs(ss,"getTypeRatio"));const i=new FormData;let u;i.append("action","site_design_update_design_style"),i.append("nonce",coblocksBlockData.labsSiteDesignNonce),i.append("design_style",e),i.append("color_palette",n),i.append("fonts",s),i.append("font_size",a),i.append("type_ratio",c),i.append("should_update",t),i.append("initial_load",o),r&&Object.keys(r).forEach((e=>i.append(`${e}_color`,r[e]))),o||(yield Hs()),yield Ns(e);try{u=yield(0,ys.apiFetch)({body:i,method:"POST",path:`${coblocksBlockData.baseApiNamespace}/${siteDesign.apiRoute}`})}catch(e){return void console.log("Error updating design",e)}if(u&&(yield{newState:{designResp:u},type:zs},!o)){if(yield Os(n),!1===s){const e=yield Gs(ss,"getDesignStyleObj");yield Is(Object.entries(e.fonts)),yield Ls(e.font_size),yield As(e.type_ratio)}yield Hs(),t&&(yield Ws())}}const Ns=e=>({newState:{designStyle:e},type:Ss});function*Os(e){const t=yield Gs(ss,"getDesignStyleObj"),o=Object.fromEntries(t.palettes)[e];if("custom"!==e&&(yield Rs(o)),null==o||!Object.entries(o).length)return{newState:{colorPalette:e},type:xs};for(const[e,t]of Object.entries(o)){const o=document.getElementsByClassName(`has-${e}-background-color`);if(o.length)for(let e=0;e<o.length;e++)o[e].style.backgroundColor=t;const l=document.getElementsByClassName(`has-${e}-color`);if(l.length)for(let e=0;e<l.length;e++)l[e].style.color=t}return{newState:{colorPalette:e},type:xs}}const Rs=e=>({newState:{currentColors:e},type:Cs}),Ls=e=>({newState:{fontSize:e},type:Ps}),As=e=>({newState:{typeRatio:e},type:Ms}),Is=e=>({newState:{selectedFonts:e},type:Vs}),Fs=()=>({stateProp:"fontsPanelOpen",type:ks}),Ds=()=>({stateProp:"colorsPanelOpen",type:bs}),js=()=>({stateProp:"designsPanelOpen",type:Es}),Hs=()=>({stateProp:"isUpdating",type:_s}),Ws=()=>({type:Bs}),{resolveSelect:$s}=$.controls;function*Us(){const e=yield $s(ss,"getDesignStyle"),t=yield $s(ss,"getColorPalette"),o=yield $s(ss,"getCurrentColors");yield Ts({designStyle:e,colorPalette:t,customColors:o,initialLoad:!0})}function qs(e,t){if(!e)return-1;const o=e.map((e=>e[0]));return t.map((e=>[e[0][0],e[1][0]])).findIndex((e=>0===(0,re.difference)(e,o).length))}function Zs({selected:e}){const[t,o]=(0,m.useState)(!1);return(0,m.useEffect)((()=>{-1===e&&o(!0)}),[e]),siteDesign.isAdvancedFontsEnabled?(0,a.createElement)(a.Fragment,null,t&&(0,a.createElement)(ws,{onClose:()=>o(!1)}),!t&&(0,a.createElement)("button",{className:J()("components-site-design-fonts__heading__custom",{"components-site-design-fonts__heading__custom--open":t}),onClick:()=>o((e=>!e))},(0,c.__)("Custom","coblocks"))):null}function Ys({font:e,isSelected:t}){const{updateSelectedFonts:o}=(0,$.useDispatch)(ss),[l,n]=(0,m.useState)(!1),r=(0,m.useCallback)((()=>{o(e),n(!1)}),[e,n]),s=t?"div":"button",u={};return"button"===s&&(u.onClick=r),(0,a.createElement)("li",{className:J()("components-site-design-fonts__option",{"is-selected":t})},(0,a.createElement)(s,{...u,className:"components-site-design-fonts__option__section"},(0,a.createElement)("p",{className:"components-site-design-fonts__option__primary",style:{fontFamily:e[0][0]}},e[0][0]),(0,a.createElement)("p",{className:"components-site-design-fonts__option__secondary",style:{fontFamily:e[1][0]}},(0,c.__)("The quick brown fox jumped over the lazy dog.","coblocks")),t&&(0,a.createElement)("button",{className:"components-site-design-fonts__option__edit",onClick:()=>n((e=>!e))},(0,a.createElement)("span",{className:"icon"},(0,a.createElement)(i.Icon,{icon:S})),l?(0,c.__)("Hide font sizes","coblocks"):(0,c.__)("Edit font sizes","coblocks"))),t&&l&&(0,a.createElement)("div",{className:"components-site-design-fonts__option__settings components-site-design-fonts__option__section"},(0,a.createElement)(gs,null)))}var Qs=function e(){const t=`font-preview-${(0,ie.useInstanceId)(e)}`,[o,l]=vs(),n=(0,$.useSelect)((e=>e(ss).isFontsPanelOpen()),[]),{toggleFontsPanel:r}=(0,$.useDispatch)(ss);if(!o)return null;const s=qs(l,o);return(0,a.createElement)(i.PanelBody,{className:"components-site-design components-site-design-fonts site-design--fonts__panel",onToggle:r,opened:n,title:(0,c.__)("Fonts","coblocks")},(0,a.createElement)("div",{className:"components-site-design-fonts__heading"},(0,a.createElement)(Zs,{selected:s}),(0,a.createElement)("p",null,(0,c.__)("Font Pairings","coblocks"))),(0,a.createElement)("ul",{className:"components-site-design-fonts__options"},o.map(((e,o)=>(0,a.createElement)(Ys,{font:e,isSelected:o===s,key:`${t}-${o}`})))))};const Xs=(e,t)=>Object.keys(t).some((o=>!(0,re.isEqual)(e[o],t[o])));const Ks=e=>e.designResp,Js=e=>e.designStyle,ea=e=>e.designStyles,ta=e=>e.designStyles?.find((t=>t.slug===e.designStyle)),oa=e=>e.colorPalette,la=e=>e.currentColors,na=e=>e.fontSize,ra=e=>e.typeRatio,sa=e=>e.fonts,aa=e=>e.showSaveBtn,ca=e=>e.selectedFonts,ia=e=>e.fontsPanelOpen,ua=e=>e.colorsPanelOpen,ma=e=>e.designsPanelOpen,da=e=>e.isUpdating;(0,$.registerStore)(ss,{reducer:(e={},t)=>{switch((0,$.use)($.plugins.persistence,e),(0,re.isEmpty)(e)&&(e=(()=>{if("undefined"==typeof siteDesign||(0,re.isEmpty)(siteDesign))return{};const e=e=>Object.entries(e).map((e=>(e[0]=e[0].replace(/_(heading|body)/,""),e))),t=siteDesign?.fonts?.map((t=>e(t))),o=Object.entries(siteDesign?.availableDesignStyles).map((([,e])=>({...e,palettes:Object.entries(e.color_schemes).map((([e,t])=>[e,Object.fromEntries(["primary","secondary","tertiary","background"].map((e=>[e,t[e]])))]))}))),l={colorPalette:siteDesign.currentColorScheme,colorsPanelOpen:!0,currentColors:Object.fromEntries(Object.entries(siteDesign.currentColors).filter((e=>e[1]))),designStyle:siteDesign.currentDesignStyle,designStyles:o,designsPanelOpen:!0,fontSize:siteDesign?.fontSize,fonts:t,fontsPanelOpen:!0,isUpdating:!1,selectedFonts:(()=>{const t=siteDesign?.currentFonts;return t?e(t):null})(),showSaveBtn:!1,typeRatio:siteDesign?.typeRatio};return l.refState={...l},l})()),t.type){case zs:return{...e,...t.newState};case Ss:case xs:case Vs:case Cs:case Ps:case Ms:return{...e,...t.newState,showSaveBtn:Xs(e.refState,{colorPalette:e.colorPalette,currentColors:e.currentColors,designStyle:e.designStyle,fontSize:e.fontSize,selectedFonts:e.selectedFonts,typeRatio:e.typeRatio,...t.newState})};case ks:case bs:case Es:case _s:return{...e,[t.stateProp]:!e[t.stateProp]};case Bs:const o={...e};return delete o.refState,{...e,refState:o,showSaveBtn:!1};default:return e}},actions:l,selectors:r,controls:ys.controls,resolvers:n,persist:["fontsPanelOpen","colorsPanelOpen","designsPanelOpen"]});const ha="coblocks_site_design_controls_enabled";var pa=o.p+"images/site-design.0ce62606.png";(0,he.registerPlugin)("coblocks-site-design-control",{render:()=>(0,a.createElement)(ns,{conditionalDisable:!0,description:(0,c.__)("Easily explore curated design styles, then customize your colors and fonts inside the editor to get the perfect fit.","coblocks"),imageAlt:(0,c.__)("Site design example","coblocks"),imageSrc:pa,label:(0,c.__)("Site Design","coblocks"),settingsKey:ha,showGoHelp:!0})});const fa=C?.outlined;let ga=!1,va=!1;const wa="_coblocks_non_existing_meta",ya=(0,c.__)("Site design","coblocks");function ba(){const e=(0,$.useSelect)((e=>e(ss).isUpdating()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignResp()),[]);return vs(),hs(),ps(),(0,m.useEffect)((()=>{if(!t||e)return;const o=document.getElementById("site-design-styles");ga=ga||t.fontStyles,o.innerHTML=[t.stylesheet,ga].join(" "),o.closest("div.is-desktop-preview")||document.querySelectorAll(".is-desktop-preview style:last-of-type")?.[0].after(o)}),[e,t]),(0,m.useEffect)((()=>{const t=document.getElementsByClassName("interface-interface-skeleton__content");t.length>0&&t[0].classList.toggle("site-design-updating",e)}),[e]),null}function Ea(){const e=(0,$.useSelect)((e=>e(ss).showSaveBtn()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),{updateDesign:o}=(0,$.useDispatch)(ss),l=()=>o({saveChanges:!0}),n=(0,$.useSelect)((e=>e("core/editor").getCurrentPostType()),[]),r=(0,$.useSelect)((e=>e("core/editor").getCurrentPostId()),[]),{editEntityRecord:s}=(0,$.useDispatch)("core"),[c]=(0,ce.useEntityProp)("postType",n,"meta");return(0,m.useEffect)((()=>{if(e){if(va=document.getElementsByClassName("editor-post-publish-button")[0]||!1,va)return s("postType",n,r,{meta:{...c,[wa]:!0}},{undoIgnore:!0}),va.addEventListener("click",l),function(){va&&va.removeEventListener("click",l)}}else va&&(delete c[wa],s("postType",n,r,{meta:{...c}},{undoIgnore:!0}),va.removeEventListener("click",l),va=!1)}),[e]),t?(0,a.createElement)(a.Fragment,null,(0,a.createElement)(ds,null),(0,a.createElement)(ms,null),(0,a.createElement)(Qs,null)):null}const ka=C?.outlined;(0,he.registerPlugin)("coblocks-site-design",{icon:ka,render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const[e]=(0,ce.useEntityProp)("root","site",ha);return e}))])((()=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(Ut.PluginSidebar,{icon:(0,a.createElement)(Fr,{icon:fa,label:(0,c.__)("Site design","coblocks"),slug:"site-design"}),title:ya},(0,a.createElement)(Ea,null)),(0,a.createElement)(ba,null))))});const _a="coblocks_layout_selector_controls_enabled",xa=({layouts:e,category:t,onInsert:o})=>{const l=(0,$.useSelect)((e=>e("core").getEntityRecord),[]),n=l("root","site")?.image_category||"",r=(0,m.useMemo)((()=>e.filter((e=>e.category===t&&!!e.parsedBlocks?.length)).map((e=>({...e,blocks:(0,Gt.applyFilters)("coblocks.layoutPreviewBlocks",e.parsedBlocks)})))),[JSON.stringify(e),t,n]),s=(0,ie.useAsyncList)(r);return t&&r.length?(0,a.createElement)("div",{className:"coblocks-layout-selector__layouts"},(0,a.createElement)(Pa,{layouts:r,onClickLayout:o,shownLayouts:s})):(0,a.createElement)("p",null,(0,a.createElement)("em",null,(0,c.__)("No layouts are available for this category.","coblocks")))},Ca=({layout:e,onClick:t})=>{const o=za(e.blocks);return(0,a.createElement)(i.Button,{className:J()("coblocks-layout-selector__layout"),"data-testid":"coblocks-layout-selector__layout-button",onClick:()=>t(e)},(0,a.createElement)(i.Spinner,null),(0,a.createElement)("div",{className:"coblocks-layout-selector__layout-preview-container"},(0,a.createElement)(U.BlockPreview,{blocks:o,viewportWidth:700})))},za=e=>e.map((e=>(e?.attributes?.animation&&(e.attributes.animation=""),e?.innerBlocks?.length>0&&(e.innerBlocks=za(e.innerBlocks)),e))),Sa=()=>(0,a.createElement)("div",{className:"coblocks-layout-selector__layout is-placeholder","data-testid":"coblocks-layout-selector__layout-placeholder"},(0,a.createElement)(i.Spinner,null)),Pa=({layouts:e,shownLayouts:t,onClickLayout:o})=>e.map(((e,l)=>t.includes(e)?(0,a.createElement)(Ca,{key:l,layout:e,onClick:o}):(0,a.createElement)(Sa,{key:l})));var Ba=o(9588),Va=o.n(Ba);const Ma={categories:coblocksLayoutSelector.categories||[],computedLayouts:[],layoutUsage:{},layouts:coblocksLayoutSelector.layouts||[],selectedCategory:"most-used",templateSelector:!1},Ga=Va()(((e,t)=>{if(!e)return t;const o=Date.now()-e;switch(!0){case o<36e5:return 4*t;case o<864e5:return 2*t;case o<6048e5:return t/2;default:return t/4}})),Ta={closeTemplateSelector:()=>({type:"CLOSE_TEMPLATE_SELECTOR"}),incrementLayoutUsage:e=>({layout:e,time:Date.now(),type:"INCREMENT_LAYOUT_USAGE"}),openTemplateSelector:()=>({type:"OPEN_TEMPLATE_SELECTOR"}),updateCategories:e=>({categories:e,type:"UPDATE_CATEGORIES"}),updateComputedLayouts:e=>({computedLayouts:e,type:"UPDATE_COMPUTED_LAYOUTS"}),updateLayouts:e=>({layouts:e,type:"UPDATE_LAYOUTS"}),updateSelectedCategory:e=>({selectedCategory:e,type:"UPDATE_CATEGORY"})};var Na=(0,$.createReduxStore)("coblocks/template-selector",{actions:Ta,controls:ys.controls,persist:["layoutUsage"],reducer(e=Ma,t){switch(t.type){case"OPEN_TEMPLATE_SELECTOR":return{...e,templateSelector:!0};case"CLOSE_TEMPLATE_SELECTOR":return{...e,templateSelector:!1};case"UPDATE_LAYOUTS":return{...e,layouts:t.layouts};case"UPDATE_COMPUTED_LAYOUTS":return{...e,computedLayouts:t.computedLayouts};case"UPDATE_CATEGORIES":return{...e,categories:t.categories};case"UPDATE_CATEGORY":return{...e,selectedCategory:t.selectedCategory};case"INCREMENT_LAYOUT_USAGE":const o=(0,re.kebabCase)(t.layout.label);return{...e,layoutUsage:{...e.layoutUsage,[o]:{count:e.layoutUsage[o]?e.layoutUsage[o].count+1:1,time:t.time}}}}return e},resolvers:{*isTemplateSelectorActive(){const e=(0,$.select)("core/editor").isCleanNewPost(),t=(0,$.select)("core/editor").isEditedPostEmpty();return(e||t)&&Ta.openTemplateSelector()}},selectors:{getCategories:e=>e.categories||[],getComputedLayouts:e=>e.computedLayouts,getLayoutUsage:e=>e.layoutUsage,getLayouts:e=>(e.layouts||[]).map((t=>{const{time:o,count:l=0}=e.layoutUsage[(0,re.kebabCase)(t.label)]||{};return{...t,frequency:Ga(o,l)}})),getSelectedCategory:e=>e.selectedCategory,hasCategories:e=>!!e.categories.length,hasLayouts:e=>!!e.layouts.length,isTemplateSelectorActive:e=>e.templateSelector}}),Oa=function(e){const t=(0,$.select)("coblocks/template-selector").getCategories();return(0,m.useMemo)((()=>t.filter((t=>(t=>!!(t=>e.filter((e=>e.category===t))||[])(t).length)(t.slug)))),[JSON.stringify(e)])};function Ra(e,t){var o;return window.requestIdleCallback?window.requestIdleCallback(e,t):setTimeout((()=>{e({didTimeout:!0,timeRemaining:()=>1})}),null!==(o=t.timeout)&&void 0!==o?o:0)}const La=(e,t,o=[])=>(0,u.createBlock)(e,t,o&&o.map((([e,t,o])=>La(e,t,o))));let Aa=null,Ia=[],Fa=[],Da=[];const{Fill:ja,Slot:Ha}=(0,i.createSlotFill)("CoBlocksLayoutSelectorFill");function Wa({children:e}){return(0,a.createElement)(ja,null,e)}(0,he.registerPlugin)("coblocks-layout-selector-control",{render:()=>(0,Gt.applyFilters)("coblocks-show-layout-selector",!0)&&(0,a.createElement)(ye,{help:(0,c.__)("Allow layout selection on new pages","coblocks"),label:(0,c.__)("Layout selector","coblocks"),settingsKey:_a,shouldDisable:(()=>{const e="undefined"!=typeof coblocksLabs?coblocksLabs:{};return!e.isGoThemeActive||!e.isGoThemeInstalled})()})});var $a=o.p+"images/layout-selector.69de142d.png";(0,he.registerPlugin)("coblocks-labs-layout-selector-control",{render:()=>(0,a.createElement)(ns,{conditionalDisable:!0,description:(0,c.__)("Get access to high-quality, professionally designed layouts when creating new pages to make page creation easier.","coblocks"),imageAlt:(0,c.__)("Layout selector example","coblocks"),imageSrc:$a,label:(0,c.__)("Layout Selector","coblocks"),settingsKey:_a,showGoHelp:!0})}),(0,$.register)(Na);const Ua=({slug:e,title:t,isSelected:o,onClick:l})=>(0,a.createElement)("li",{className:"coblocks-layout-selector__sidebar__item",key:e},(0,a.createElement)("a",{className:J()({"is-selected":o}),href:`#${e}`,onClick:e=>{e.preventDefault(),l()}},t));class qa extends m.Component{render(){const{categories:e,selectedCategory:t,updateSelectedCategory:o,isActive:l,isMobile:n,useEmptyTemplateLayout:r,useTemplateLayout:s,layouts:u}=this.props,d=(0,Gt.applyFilters)("coblocks-layout-selector-controls",[]),h=(0,a.createElement)(a.Fragment,null,(0,a.createElement)(Ha,null),Array.isArray(d)&&d.map(((e,t)=>{let o=e;return["function","object"].includes(typeof o)?((0,m.isValidElement)(o)||(o=(0,a.createElement)(o,null)),(0,a.createElement)(Wa,{key:`layout-control-${t}`},o)):null})));return l?(0,a.createElement)(i.Modal,{className:"coblocks-layout-selector-modal",onRequestClose:r,title:(0,a.createElement)(a.Fragment,null,(0,a.createElement)("div",null,(0,c.__)("Add New Page","coblocks")),(0,a.createElement)("span",null,(0,c.__)("Pick one of these layouts or start with a blank page.","coblocks")))},(0,a.createElement)("div",{className:"coblocks-layout-selector"},n&&(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar"},(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left"},(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left__settings"},h),(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left__category"},(0,a.createElement)("strong",null,(0,c.__)("Layouts","coblocks"),":")," ",e.find((e=>e.slug===t))?.title,(0,a.createElement)(i.DropdownMenu,{label:"Select a layout category"},(({onClose:t})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.MenuGroup,{onClick:t},e.map(((e,l)=>(0,a.createElement)(i.MenuItem,{key:l,onClick:()=>{o(e.slug),t()}},e.title))))))))),(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__right"},(0,a.createElement)(i.Button,{className:"coblocks-layout-selector__add-button",isLink:!0,onClick:r},(0,a.createElement)("span",null,(0,a.createElement)(i.Icon,{icon:"plus",size:16}))," ",(0,c.__)("Add blank page","coblocks")))),!n&&(0,a.createElement)("aside",{className:"coblocks-layout-selector__sidebar"},h,(0,a.createElement)("ul",{className:"coblocks-layout-selector__sidebar__items"},e.map(((e,l)=>(0,a.createElement)(Ua,{isSelected:e.slug===t,key:l,onClick:()=>o(e.slug),slug:e.slug,title:e.title})))),(0,a.createElement)(i.Button,{className:"coblocks-layout-selector__add-button",isLink:!0,onClick:r},(0,a.createElement)("span",null,(0,a.createElement)(i.SVG,{"aria-hidden":"true",focusable:"false",height:"24",role:"img",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)(i.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"}))),(0,c.__)("Add blank page","coblocks"))),(0,a.createElement)("div",{className:"coblocks-layout-selector__content"},(0,a.createElement)(xa,{category:t,layouts:u,onInsert:e=>s(e)})))):null}}"undefined"!=typeof coblocksLayoutSelector&&coblocksLayoutSelector.postTypeEnabled&&(0,he.registerPlugin)("coblocks-layout-selector",{render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const[e]=(0,ce.useEntityProp)("root","site",_a),t=!!document.getElementsByClassName("coblocks-labs-modal")?.[0],{hasLayouts:o,hasCategories:l}=(0,$.useSelect)((e=>e("coblocks/template-selector")));return e&&!t&&o()&&l()})),(0,$.withSelect)((e=>{const{getSelectedCategory:t,isTemplateSelectorActive:o}=e("coblocks/template-selector"),{isViewportMatch:l}=e("core/viewport"),n=function(){const e=(0,$.select)("coblocks/template-selector").getLayouts(),t=(0,$.select)("coblocks/template-selector").getComputedLayouts(),o=(0,$.select)("coblocks/template-selector").getSelectedCategory(),{updateComputedLayouts:l}=(0,$.useDispatch)("coblocks/template-selector"),n=e=>[o].includes(e.category)?e.blocks?e.blocks.map((e=>Array.isArray(e)?La(e[0],e[1],e[2]):e)):(0,u.rawHandler)({HTML:e.postContent})||[]:e.parsedBlocks?e.parsedBlocks:[],r=e=>({...e,parsedBlocks:n(e)}),s=e=>{for(;(e.timeRemaining()>0||e.didTimeout)&&Ia.length;)Fa.push(r(Ia.shift()));Ia.length?Ra(s,{timeout:1e3}):l(Fa)};return(0,m.useEffect)((()=>{var t;t=Aa,window.cancelIdleCallback?window.cancelIdleCallback(t):clearTimeout(t),Fa=[];const l=(0,re.orderBy)(e,["frequency"],["desc"]).slice(0,6).map((e=>({...e,category:"most-used"})));Ia=[...l,...e],Da=[o],Aa=Ra(s,{timeout:1e3})}),[JSON.stringify(e)]),(0,m.useEffect)((()=>{Da.includes(o)||(Da.push(o),l(t.map(r)))}),[o]),t}();return{categories:Oa(n),isActive:o(),isMobile:l("< medium"),layouts:n,selectedCategory:t()}})),(0,$.withDispatch)((e=>{const{closeTemplateSelector:t,incrementLayoutUsage:o,updateSelectedCategory:l}=e("coblocks/template-selector"),{editPost:n}=e("core/editor"),{createWarningNotice:r,createSuccessNotice:s}=e("core/notices");return{closeTemplateSelector:t,createSuccessNotice:s,createWarningNotice:r,editPost:n,updateSelectedCategory:l,useEmptyTemplateLayout:()=>{n({blocks:[],title:""}),t()},useTemplateLayout:e=>{n({blocks:e.blocks,title:e.label}),t(),o(e),s((0,c.sprintf)(61 (0,c.__)('"%s" set as the homepage.',"coblocks"),e.title.raw),{type:"snackbar"})}))};handleInputKeys=(e,t)=>{switch(e.key){case"Enter":e.preventDefault(),this.onCompleteRename(t);break;case"Escape":this.onResetRename(t);break;case" ":e.stopPropagation(),e.preventDefault()}};getOrderedPublishedPages=()=>{const{entities:e,homepageId:t,homepostId:o}=this.props,l=e.filter((e=>"draft"!==e.status&&e.id!==o));return l.sort(((e,o)=>e.id===t?-1:o.id===t?1:0)),l};getOrderedPublishedPosts=()=>{const{entities:e}=this.props;return[...e.filter((e=>"draft"!==e.status&&e.sticky)),...e.filter((e=>"draft"!==e.status&&!e.sticky))]};getOrderedDrafts=()=>{const{entities:e}=this.props;return e.filter((e=>"draft"===e.status)).reverse()};renderIcon=e=>{const{homepageId:t,homepageType:o}=this.props;return e.sticky?Yr:e.id===t&&"page"===o?Wr:"post"===e.type?qr:$r};renderPageTitle=e=>{const{isInRenameMode:t}=this.props;return e.id===t?this.inputRefs[e.id]?.textContent!==(0,c.__)("(no title)","coblocks")?this.inputRefs[e.id].textContent:"":e.title.raw?e.title.raw:(0,c.__)("(no title)","coblocks")};renderRow=(e,t)=>{const{currentPostId:o,homepageId:l,homepageType:n,loadPostIntoEditor:r,isInRenameMode:s}=this.props,c=this.renderPageTitle(e),u=e.id===s;return(0,a.createElement)(i.PanelRow,{className:J()("content-management__panel__row",{current:o===e.id,"is-renaming":u}),key:t},(0,a.createElement)(i.Button,{className:J()("content-management__panel__button"),isLink:!0,onClick:()=>!s&&r(e.type,e.id)},(0,a.createElement)(a.Fragment,null,this.renderIcon(e),(0,a.createElement)("span",{contentEditable:u,onKeyUp:t=>this.handleInputKeys(t,e),ref:t=>this.inputRefs[e.id]=t,role:"textbox"},c))),(0,a.createElement)(Qr,{isSticky:e.sticky,onDeletePost:()=>this.onDelete(e),onDuplicatePost:()=>this.onDuplicate(e),onPinPost:()=>this.onPin(e),onRenamePost:()=>this.onActivateRename(e,t),onSetAsHomePost:()=>this.onSetAsHome(e),postType:e.type,shouldDiplayPinAction:"post"===e.type&&"publish"===e.status,shouldDisplayHomepageAction:"page"===n&&"page"===e.type&&"publish"===e.status&&e.id!==l}),u&&(0,a.createElement)("div",{className:"content-management__panel__rename-actions"},(0,a.createElement)(i.Button,{className:"content-management__panel__rename-action content-management__panel__rename-action--confirm",onClick:()=>this.onCompleteRename(e)},(0,a.createElement)(i.Icon,{icon:ae,size:22})),(0,a.createElement)(i.Button,{className:"content-management__panel__rename-action content-management__panel__rename-action--cancel",onClick:()=>this.onResetRename(e)},(0,a.createElement)(i.Icon,{icon:Dr,size:20}))))};render(){const{props:e}=this,t="page"===e.postType.slug?this.getOrderedPublishedPages():this.getOrderedPublishedPosts(),o=this.getOrderedDrafts();return(0,a.createElement)(i.PanelBody,{className:J()("content-management__panel",{"is-renaming":e.isInRenameMode}),initialOpen:e.postType.slug===e.currentPostType,key:e.postType.slug,title:e.postType.name},t&&t.map(this.renderRow),o&&o.length>0&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h3",{className:"content-management__panel__separator"},(0,a.createElement)("span",null,(0,c.__)("Drafts","coblocks"))),o.map(this.renderRow)),(0,a.createElement)(i.Tooltip,{text:e.postType.labels.add_new_item},(0,a.createElement)(i.Button,{className:"content-management__add-new-button",onClick:()=>this.onCreateNew(e.postType)},(0,a.createElement)(i.Icon,{icon:jr,size:28}))))}}var Jr=(0,ie.compose)([(0,$.withSelect)(((e,t)=>{const{getCurrentPostId:o,getCurrentPostType:l}=e("core/editor"),{getEntityRecords:n,getEntityRecord:r,getEntity:s}=e("core"),a={};(n("postType",t.postType.slug,{per_page:-1,status:["publish","future","pending","private","draft"]})||[]).forEach((e=>a[e.id]=e));const{page_on_front:c,page_for_posts:i,show_on_front:u}=r("root","site")||{},{isInRenameMode:m}=e("coblocks/site-content");return{currentPostId:o(),currentPostType:l(),entities:Object.values(a),homepageId:c,homepageType:u,homepostId:i,isInRenameMode:m(),settingsEntity:s("root","site")}})),(0,$.withDispatch)((e=>{const{editEntityRecord:t,receiveEntityRecords:o,saveEntityRecord:l}=e("core"),{savePost:n}=e("core/editor"),{createErrorNotice:r,createSuccessNotice:s}=e("core/notices"),{cancelRenameMode:a,setRenameMode:c}=e("coblocks/site-content"),{openTemplateSelector:i}=e("coblocks/template-selector");return{cancelRenameMode:a,createErrorNotice:r,createSuccessNotice:s,editEntityRecord:t,openTemplateSelector:i,receiveEntityRecords:o,saveEntityRecord:l,savePost:n,setRenameMode:c}}))])(Kr);const es="coblocks_site_content_controls_enabled",ts="undefined"!=typeof coblocksLabs?coblocksLabs:{},os=()=>{const{isGoThemeActive:e,isGoThemeInstalled:t,goThemeDetailsUri:o,goThemeInstallUri:l}=ts;return e&&t?(0,c.__)("This feature requires the Go Theme.","coblocks"):t?(0,a.createElement)(a.Fragment,null," ",(0,c.__)("This feature requires the Go Theme - ","coblocks"),(0,a.createElement)("a",{href:o,rel:"noopener noreferrer",target:"_blank"},(0,c.__)("Activate","coblocks"))):(0,a.createElement)(a.Fragment,null," ",(0,c.__)("This feature requires the Go Theme - ","coblocks"),(0,a.createElement)("a",{href:l,rel:"noopener noreferrer",target:"_blank"},(0,c.__)("Install now","coblocks")))},ls=()=>{const{isGoThemeActive:e,isGoThemeInstalled:t}=ts;return!e||!t};var ns=function({label:e,help:t,description:o,imageSrc:l,imageAlt:n,settingsKey:r,showGoHelp:s,conditionalDisable:c=!1}){const[u,m]=(0,ce.useEntityProp)("root","site",r);return(0,a.createElement)(Xt,null,(0,a.createElement)("section",{className:"coblocks-labs-modal__section"},(0,a.createElement)("div",{className:"coblocks-labs-modal__section__vertical-group"},(0,a.createElement)("h2",{className:"coblocks-labs-modal__section__heading"},e),o&&(0,a.createElement)("p",{className:"coblocks-labs-modal__section__description"},o),(0,a.createElement)(i.ToggleControl,{checked:!!u,disabled:!!c&&ls(),help:s?os():"",onChange:m})),(0,a.createElement)("figure",null,(0,a.createElement)("img",{alt:n,src:l}))),(0,a.createElement)("hr",null))},rs=o.p+"images/site-content.da68e2d6.png";(0,he.registerPlugin)("coblocks-site-content-control",{render:()=>(0,a.createElement)(ns,{description:(0,c.__)("Quickly and easily manage your websites pages and posts from inside the editor.","coblocks"),imageAlt:(0,c.__)("Site content example","coblocks"),imageSrc:rs,label:(0,c.__)("Site Content","coblocks"),settingsKey:es})}),(0,he.registerPlugin)("coblocks-site-content",{icon:z,render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const e=window.location.pathname.includes("post-new.php"),[t]=(0,ce.useEntityProp)("root","site",es),o=!!(0,$.select)("core/editor");return e&&t&&o})),(0,$.withSelect)((e=>{const{getCurrentPostId:t,getEditedPostAttribute:o}=e("core/editor"),{getPostTypes:l}=e("core"),n=(l()||[]).filter((e=>!0===e.viewable&&["post","page"].includes(e.slug)));return{currentPageMeta:o("meta"),currentPostId:t(),postTypes:(0,re.sortBy)(n,["name"])}})),(0,$.withDispatch)((e=>{const{editPost:t}=e("core/editor");return{editPost:t}}))])((e=>{(0,m.useEffect)((()=>{const{currentPageMeta:t,editPost:o}=e;t&&"enabled"===t.hide_page_title&&wp.domReady((()=>{document.getElementsByClassName("edit-post-visual-editor__post-title-wrapper")[0]&&(document.getElementsByClassName("edit-post-visual-editor__post-title-wrapper")[0].style.display="none",o({meta:{hide_page_title:"enabled"}}))}))}),[]);const t=(e,t)=>{window.location.href=`/wp-admin/post.php?post=${t}&action=edit`},{postTypes:o}=e;return(0,a.createElement)("span",{"data-test":"site-content__container"},(0,a.createElement)(Ut.PluginSidebar,{className:"content-management",icon:(0,a.createElement)(Fr,{icon:z,label:(0,c.__)("Site content","coblocks"),slug:"site-content"}),title:(0,c.__)("Site contents","coblocks")},o.map((e=>(0,a.createElement)("span",{"data-test":"post-type-panel",key:e.slug},(0,a.createElement)(Jr,{loadPostIntoEditor:t,postType:e}))))))}))});var ss="coblocks/site-design";function as({slug:e,palette:t,isActive:o}){const l=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),n=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]),{updateColorPalette:r}=(0,$.useDispatch)(ss),s=J()("color-palette",{"is-selected":o}),c=(0,m.useCallback)((()=>{n!==e&&r(e)}),[e,n,l]);return(0,a.createElement)(i.Button,{className:s,onClick:c},Object.entries(t).reverse().map((([e,t])=>"background"!==e?(0,a.createElement)(i.ColorIndicator,{colorValue:t,key:`color-preview-${e}`}):null)))}function cs({previousPalette:e,onUpdateColors:t,onDismissCustom:o}){const l=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),n=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]);return l&&"custom"===n?(0,a.createElement)("div",{className:"color-palette-custom components-site-design__custom"},(0,a.createElement)("div",{className:"color-palette-custom__title"},(0,c.__)("Custom Colors","coblocks")),e&&(0,a.createElement)("button",{className:"components-site-design__custom__dismiss",onClick:o},(0,a.createElement)("span",null,(0,c.__)("Dismiss custom color","coblocks"))),Object.entries(l).map((([e,o])=>(0,a.createElement)(i.Dropdown,{key:`color-picker-${e}`,position:"bottom center",renderContent:()=>(0,a.createElement)(i.ColorPicker,{color:is(l,e,o),disableAlpha:!0,onChangeComplete:o=>{const l=document.getElementsByClassName(`has-${e}-background-color`);if(l.length)for(let e=0;e<l.length;e++)l[e].style.backgroundColor=o.hex;const n=document.getElementsByClassName(`has-${e}-color`);if(n.length)for(let e=0;e<n.length;e++)n[e].style.color=o.hex;t({[e]:o.hex})}}),renderToggle:({isOpen:t,onToggle:n})=>(0,a.createElement)(i.Button,{"aria-expanded":t,className:"color-palette-custom__color",isLink:!0,onClick:n},(0,a.createElement)(i.ColorIndicator,{colorValue:is(l,e,o),key:`color-${e}`}),us(e))})))):null}const is=(e,t,o)=>void 0!==Object.keys(e).shift()&&e[t]?e[t].includes("#")?e[t]:`#${e[t]}`:o,us=e=>{const t=e.toLowerCase().split(" ");for(let e=0;e<t.length;e++)t[e]=t[e].charAt(0).toUpperCase()+t[e].substring(1);return t.join(" ")};var ms=function(){const e=(0,$.useSelect)((e=>e("core/block-editor").getSettings),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),o=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),l=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]),n=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),r=(0,$.useSelect)((e=>e(ss).isColorsPanelOpen()),[]),s=(0,$.useDispatch)("core/block-editor").updateSettings,{updateCustomColors:u,updateColorPalette:d,toggleColorsPanel:h}=(0,$.useDispatch)(ss),[p,f]=(0,m.useState)(null);(0,m.useEffect)((()=>{n&&(g(),Object.entries(n).forEach((([e,t])=>{document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty(`--go--color--${e}`,t)})))}),[n]);const g=(t={})=>{const o={...n,...t};"custom"===l&&f(null),s({...e(),colors:Object.entries(o).map((([e,t])=>({name:e,slug:e,color:t})))}),u({...n,...t})};return(0,a.createElement)(i.PanelBody,{className:"site-design--colors__panel",onToggle:h,opened:r,title:(0,c.__)("Colors","coblocks")},(0,a.createElement)(i.BaseControl,{className:"components-site-design-color-palettes"},(0,a.createElement)(cs,{onDismissCustom:()=>d(p),onUpdateColors:g,previousPalette:p}),(0,a.createElement)("div",{className:"color-palettes"},(0,a.createElement)("div",{className:"color-palettes__title"},(0,a.createElement)("span",null,(0,c.__)("Color Palettes","coblocks")),"custom"!==l&&(0,a.createElement)("button",{className:"color-palettes__custom-button",onClick:()=>{f(l),d("custom"),g()}},(0,c.__)("Custom","coblocks"))),(0,a.createElement)("div",{className:"color-palettes__palettes"},t&&t.palettes.map((([e,t])=>(0,a.createElement)(as,{isActive:l.replace(`${o}-`,"")===e,key:`palette-${e}`,palette:t,slug:e})))))))},ds=function(){const e=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyles()),[]),o=(0,$.useSelect)((e=>e(ss).isDesignsPanelOpen()),[]),l=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),n=(0,$.useSelect)((e=>e(ss).isUpdating()),[]),r=t?.find((t=>t.slug===e)),{updateDesign:s,toggleDesignsPanel:u}=(0,$.useDispatch)(ss),m=(e,t)=>{const o=[e.tertiary,e.secondary,e.primary];return(0,a.createElement)("div",{className:"components-site-design-designs__design__colors"},o.map(((e,o)=>(0,a.createElement)("li",{className:"components-site-design-designs__design__color",key:`components-site-design-designs__design__color-${t}-${o}`,style:{backgroundColor:e}}))))};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.PanelBody,{className:"site-design--designs__panel components-site-design-designs",onToggle:u,opened:o,title:(0,c.__)("Design Styles","coblocks")},(0,a.createElement)("p",null,(0,c.__)("Easily explore curated design styles, then customize your colors and fonts to get the perfect fit.","coblocks")),(0,a.createElement)(Ir,null,t&&t.map(((t,o)=>(0,a.createElement)("button",{className:J()("components-site-design-designs__design",{"components-site-design-designs__design--selected":t.slug===e,"components-site-design-designs__design--updating":n}),"data-test":`design-button-${t.slug}`,key:`design-button-${t.slug}`,onClick:()=>(t=>{t!==e&&s({designStyle:t})})(t.slug)},(0,a.createElement)("div",{className:"components-site-design-designs__design__content"},(0,a.createElement)("div",{className:"components-site-design-designs__design__label",style:{fontFamily:Object.entries(t.fonts)[0][0]}},t.label),m(t.slug!==e||n?t.palettes[0][1]:l,o))))))),!o&&!!r&&(0,a.createElement)("div",{className:"components-site-design-design components-panel__body is-opened"},(0,a.createElement)("button",{className:"components-site-design-designs__design components-site-design-designs__design--current",onClick:u},(0,a.createElement)("div",{className:"components-site-design-designs__design__content"},(0,a.createElement)("div",{className:"components-site-design-designs__design__label",style:{fontFamily:Object.entries(r.fonts)[0][0]}},r.label),m(l,9999)))))},hs=function(){const e=(0,$.useSelect)((e=>e(ss).getFontSize()),[]),t=Number(e?.replace("rem","")),o=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),l=Number(o?.font_size?.replace("rem",""));return(0,m.useEffect)((()=>{t&&document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty("--go--font-size",`${t}rem`)}),[t]),[t,l]},ps=function(){const e=(0,$.useSelect)((e=>e(ss).getTypeRatio()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),o=t?.type_ratio;return(0,m.useEffect)((()=>{e&&document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty("--go--type-ratio",e)}),[e]),[e,o]};const fs="custom";var gs=function e(){const[t,o]=hs(),[l,n]=ps(),{updateFontSize:r,updateTypeRatio:s}=(0,$.useDispatch)(ss),u=(0,ie.useInstanceId)(e),d=(0,m.useMemo)((()=>function(e){return e?[{key:"small",name:(0,c.__)("Small","coblocks"),style:{fontSize:`${(.8*e).toFixed(2)}rem`}},{key:"normal",name:(0,c.__)("Normal","coblocks"),style:{fontSize:`${e.toFixed(2)}rem`}},{key:"large",name:(0,c.__)("Large","coblocks"),style:{fontSize:`${(1.3*e).toFixed(2)}rem`}},{key:fs,name:(0,c.__)("Custom")}]:[]}(o)),[o]),h=(0,m.useMemo)((()=>function(e,t){if(t){const o=e.find((e=>e.style?.fontSize===`${t.toFixed(2)}rem`));return o?o.key:fs}return"normal"}(d,t)),[d,t]),p=(0,m.useCallback)((({selectedItem:e})=>{const t=e?.style?.fontSize;t&&r(t)}));if(!d)return null;const f=`components-font-size-picker__number#${u}`;return(0,a.createElement)("fieldset",{className:"components-font-size-picker"},(0,a.createElement)(i.VisuallyHidden,{as:"legend"},(0,c.__)("Base size","coblocks")),(0,a.createElement)("div",{className:"components-font-size-picker__controls"},t&&(0,a.createElement)(i.CustomSelectControl,{className:"components-font-size-picker__select",label:(0,c.__)("Font size","coblocks"),onChange:p,options:d,value:d.find((e=>e.key===h))}),(0,a.createElement)("div",{className:"components-font-size-picker__number-container"},(0,a.createElement)("input",{"aria-label":(0,c.__)("Custom"),className:"components-font-size-picker__number",id:f,max:5,min:0,onChange:e=>{r(`${e.target.value}rem`)},step:.01,type:"number",value:t||""}))),(0,a.createElement)("div",{className:"components-font-size-picker__heading-container"},(0,a.createElement)(i.RangeControl,{className:"components-font-size-picker__heading-scale",initialPosition:l,label:(0,c.__)("Heading Scale","coblocks"),max:1.15*n,min:.9*n,onChange:s,showTooltip:!1,step:.01,value:l||"",withInputField:!1})))},vs=function(){const e=(0,$.useSelect)((e=>e(ss).getFonts()),[]),t=(0,$.useSelect)((e=>e(ss).getSelectedFonts()),[]);return(0,m.useEffect)((()=>{if(!t)return;const[e,o]=t[0],[l,n]=t[1],r=document.getElementsByClassName(siteDesign.editorClass)[0];r&&(r.style.setProperty("--go-heading--font-family",e),r.style.setProperty("--go-heading--font-weight",o[0]),r.style.setProperty("--go--font-family",l),r.style.setProperty("--go--font-weight",n[0]))}),[t]),[e,t]},ws=function(e){const[t,o]=hs(),[l,n]=ps(),[r,s]=vs(),{updateFontSize:u,updateTypeRatio:d,updateSelectedFonts:h}=(0,$.useDispatch)(ss),p=(0,m.useMemo)((()=>(e=>e.flat().sort().filter(((e,t,o)=>o.findIndex((t=>t[0]===e[0]))===t)).map((e=>({key:e[0],name:e[0],style:{fontFamily:e[0]},weights:e[1],weightsOptions:e[1].map((t=>({key:t,name:t,style:{fontWeight:t,fontFamily:e[0]}})))}))))(r)),[r]),[f,g]=s[0],[v,w]=s[1],y=p.find((e=>e.key===f)),b=y.weightsOptions.find((e=>e.key===g[0])),E=p.find((e=>e.key===v)),k=E.weightsOptions.find((e=>e.key===w[0])),{onClose:_}=e;return(0,a.createElement)("div",{className:"components-site-design__custom"},(0,a.createElement)("strong",null,(0,c.__)("Custom Font Options","coblocks")),(0,a.createElement)("button",{className:"components-site-design__custom__dismiss",onClick:_},(0,a.createElement)("span",null,"Dismiss custom color")),(0,a.createElement)("fieldset",{className:"components-site-design__custom__body"},(0,a.createElement)("strong",null,(0,c.__)("HEADING","coblocks")),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Font","coblocks"),onChange:({selectedItem:e})=>h([[e.key,e.weights],s[1]]),options:p,value:y}),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Weight","coblocks"),onChange:({selectedItem:e})=>h([[f,[e.key]],s[1]]),options:y.weightsOptions,value:b}),(0,a.createElement)(i.RangeControl,{initialPosition:l,label:(0,c.__)("Size","coblocks"),max:1.15*n,min:.9*n,onChange:d,showTooltip:!1,step:.01,value:l||"",withInputField:!1})),(0,a.createElement)("hr",{className:"components-site-design-fonts__advanced__separator"}),(0,a.createElement)("fieldset",{className:"components-site-design-fonts__advanced__heading"},(0,a.createElement)(i.VisuallyHidden,{as:"legend"},(0,c.__)("Heading font size","coblocks")),(0,a.createElement)("strong",null,(0,c.__)("BODY","coblocks")),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Font","coblocks"),onChange:({selectedItem:e})=>h([s[0],[e.key,e.weights]]),options:p,style:{fontFamily:E.key},value:E}),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Weight","coblocks"),onChange:({selectedItem:e})=>h([s[0],[v,[e.key]]]),options:E.weightsOptions,value:k}),(0,a.createElement)(i.RangeControl,{initialPosition:0,label:(0,c.__)("Size","coblocks"),max:(2*o).toFixed(2),min:(.8*o).toFixed(2),onChange:e=>u(`${e}rem`),showTooltip:!1,step:.01,value:t,withInputField:!1})))},ys=window.wp.dataControls;const bs="TOGGLE_COLORS_PANEL",Es="TOGGLE_DESIGNS_PANEL",ks="TOGGLE_FONTS_PANEL",_s="TOGGLE_IS_UPDATING",xs="UPDATE_COLOR_PALETTE",Cs="UPDATE_CUSTOM_COLORS",zs="UPDATE_DESIGN",Ss="UPDATE_DESIGN_STYLE",Ps="UPDATE_FONT_SIZE",Bs="UPDATE_REF_STATE",Vs="UPDATE_SELECTED_FONTS",Ms="UPDATE_TYPE_RATIO",{resolveSelect:Gs}=$.controls;function*Ts({designStyle:e="none",saveChanges:t=!1,initialLoad:o=!1}){const l=yield Gs(ss,"getColorPalette");let{colorPalette:n=("custom"===l?"custom":"one"),customColors:r=("custom"===l?yield Gs(ss,"getCurrentColors"):null),fonts:s=!1,fontSize:a=!1,typeRatio:c=!1}={};t&&(e=yield Gs(ss,"getDesignStyle"),n=yield Gs(ss,"getColorPalette"),r=yield Gs(ss,"getCurrentColors"),s=yield Gs(ss,"getSelectedFonts"),s=(0,re.cloneDeep)(s),siteDesign.isAdvancedFontsEnabled&&(s[0][0]=`${s[0][0]}_heading`,s[1][0]=`${s[1][0]}_body`),s=JSON.stringify(Object.fromEntries(s)),a=yield Gs(ss,"getFontSize"),c=yield Gs(ss,"getTypeRatio"));const i=new FormData;let u;i.append("action","site_design_update_design_style"),i.append("nonce",coblocksBlockData.labsSiteDesignNonce),i.append("design_style",e),i.append("color_palette",n),i.append("fonts",s),i.append("font_size",a),i.append("type_ratio",c),i.append("should_update",t),i.append("initial_load",o),r&&Object.keys(r).forEach((e=>i.append(`${e}_color`,r[e]))),o||(yield Hs()),yield Ns(e);try{u=yield(0,ys.apiFetch)({body:i,method:"POST",path:`${coblocksBlockData.baseApiNamespace}/${siteDesign.apiRoute}`})}catch(e){return void console.log("Error updating design",e)}if(u&&(yield{newState:{designResp:u},type:zs},!o)){if(yield Os(n),!1===s){const e=yield Gs(ss,"getDesignStyleObj");yield Is(Object.entries(e.fonts)),yield Ls(e.font_size),yield As(e.type_ratio)}yield Hs(),t&&(yield Ws())}}const Ns=e=>({newState:{designStyle:e},type:Ss});function*Os(e){const t=yield Gs(ss,"getDesignStyleObj"),o=Object.fromEntries(t.palettes)[e];if("custom"!==e&&(yield Rs(o)),null==o||!Object.entries(o).length)return{newState:{colorPalette:e},type:xs};for(const[e,t]of Object.entries(o)){const o=document.getElementsByClassName(`has-${e}-background-color`);if(o.length)for(let e=0;e<o.length;e++)o[e].style.backgroundColor=t;const l=document.getElementsByClassName(`has-${e}-color`);if(l.length)for(let e=0;e<l.length;e++)l[e].style.color=t}return{newState:{colorPalette:e},type:xs}}const Rs=e=>({newState:{currentColors:e},type:Cs}),Ls=e=>({newState:{fontSize:e},type:Ps}),As=e=>({newState:{typeRatio:e},type:Ms}),Is=e=>({newState:{selectedFonts:e},type:Vs}),Fs=()=>({stateProp:"fontsPanelOpen",type:ks}),Ds=()=>({stateProp:"colorsPanelOpen",type:bs}),js=()=>({stateProp:"designsPanelOpen",type:Es}),Hs=()=>({stateProp:"isUpdating",type:_s}),Ws=()=>({type:Bs}),{resolveSelect:$s}=$.controls;function*Us(){const e=yield $s(ss,"getDesignStyle"),t=yield $s(ss,"getColorPalette"),o=yield $s(ss,"getCurrentColors");yield Ts({designStyle:e,colorPalette:t,customColors:o,initialLoad:!0})}function qs(e,t){if(!e)return-1;const o=e.map((e=>e[0]));return t.map((e=>[e[0][0],e[1][0]])).findIndex((e=>0===(0,re.difference)(e,o).length))}function Zs({selected:e}){const[t,o]=(0,m.useState)(!1);return(0,m.useEffect)((()=>{-1===e&&o(!0)}),[e]),siteDesign.isAdvancedFontsEnabled?(0,a.createElement)(a.Fragment,null,t&&(0,a.createElement)(ws,{onClose:()=>o(!1)}),!t&&(0,a.createElement)("button",{className:J()("components-site-design-fonts__heading__custom",{"components-site-design-fonts__heading__custom--open":t}),onClick:()=>o((e=>!e))},(0,c.__)("Custom","coblocks"))):null}function Ys({font:e,isSelected:t}){const{updateSelectedFonts:o}=(0,$.useDispatch)(ss),[l,n]=(0,m.useState)(!1),r=(0,m.useCallback)((()=>{o(e),n(!1)}),[e,n]),s=t?"div":"button",u={};return"button"===s&&(u.onClick=r),(0,a.createElement)("li",{className:J()("components-site-design-fonts__option",{"is-selected":t})},(0,a.createElement)(s,{...u,className:"components-site-design-fonts__option__section"},(0,a.createElement)("p",{className:"components-site-design-fonts__option__primary",style:{fontFamily:e[0][0]}},e[0][0]),(0,a.createElement)("p",{className:"components-site-design-fonts__option__secondary",style:{fontFamily:e[1][0]}},(0,c.__)("The quick brown fox jumped over the lazy dog.","coblocks")),t&&(0,a.createElement)("button",{className:"components-site-design-fonts__option__edit",onClick:()=>n((e=>!e))},(0,a.createElement)("span",{className:"icon"},(0,a.createElement)(i.Icon,{icon:S})),l?(0,c.__)("Hide font sizes","coblocks"):(0,c.__)("Edit font sizes","coblocks"))),t&&l&&(0,a.createElement)("div",{className:"components-site-design-fonts__option__settings components-site-design-fonts__option__section"},(0,a.createElement)(gs,null)))}var Qs=function e(){const t=`font-preview-${(0,ie.useInstanceId)(e)}`,[o,l]=vs(),n=(0,$.useSelect)((e=>e(ss).isFontsPanelOpen()),[]),{toggleFontsPanel:r}=(0,$.useDispatch)(ss);if(!o)return null;const s=qs(l,o);return(0,a.createElement)(i.PanelBody,{className:"components-site-design components-site-design-fonts site-design--fonts__panel",onToggle:r,opened:n,title:(0,c.__)("Fonts","coblocks")},(0,a.createElement)("div",{className:"components-site-design-fonts__heading"},(0,a.createElement)(Zs,{selected:s}),(0,a.createElement)("p",null,(0,c.__)("Font Pairings","coblocks"))),(0,a.createElement)("ul",{className:"components-site-design-fonts__options"},o.map(((e,o)=>(0,a.createElement)(Ys,{font:e,isSelected:o===s,key:`${t}-${o}`})))))};const Xs=(e,t)=>Object.keys(t).some((o=>!(0,re.isEqual)(e[o],t[o])));const Ks=e=>e.designResp,Js=e=>e.designStyle,ea=e=>e.designStyles,ta=e=>e.designStyles?.find((t=>t.slug===e.designStyle)),oa=e=>e.colorPalette,la=e=>e.currentColors,na=e=>e.fontSize,ra=e=>e.typeRatio,sa=e=>e.fonts,aa=e=>e.showSaveBtn,ca=e=>e.selectedFonts,ia=e=>e.fontsPanelOpen,ua=e=>e.colorsPanelOpen,ma=e=>e.designsPanelOpen,da=e=>e.isUpdating;(0,$.registerStore)(ss,{reducer:(e={},t)=>{switch((0,$.use)($.plugins.persistence,e),(0,re.isEmpty)(e)&&(e=(()=>{if("undefined"==typeof siteDesign||(0,re.isEmpty)(siteDesign))return{};const e=e=>Object.entries(e).map((e=>(e[0]=e[0].replace(/_(heading|body)/,""),e))),t=siteDesign?.fonts?.map((t=>e(t))),o=Object.entries(siteDesign?.availableDesignStyles).map((([,e])=>({...e,palettes:Object.entries(e.color_schemes).map((([e,t])=>[e,Object.fromEntries(["primary","secondary","tertiary","background"].map((e=>[e,t[e]])))]))}))),l={colorPalette:siteDesign.currentColorScheme,colorsPanelOpen:!0,currentColors:Object.fromEntries(Object.entries(siteDesign.currentColors).filter((e=>e[1]))),designStyle:siteDesign.currentDesignStyle,designStyles:o,designsPanelOpen:!0,fontSize:siteDesign?.fontSize,fonts:t,fontsPanelOpen:!0,isUpdating:!1,selectedFonts:(()=>{const t=siteDesign?.currentFonts;return t?e(t):null})(),showSaveBtn:!1,typeRatio:siteDesign?.typeRatio};return l.refState={...l},l})()),t.type){case zs:return{...e,...t.newState};case Ss:case xs:case Vs:case Cs:case Ps:case Ms:return{...e,...t.newState,showSaveBtn:Xs(e.refState,{colorPalette:e.colorPalette,currentColors:e.currentColors,designStyle:e.designStyle,fontSize:e.fontSize,selectedFonts:e.selectedFonts,typeRatio:e.typeRatio,...t.newState})};case ks:case bs:case Es:case _s:return{...e,[t.stateProp]:!e[t.stateProp]};case Bs:const o={...e};return delete o.refState,{...e,refState:o,showSaveBtn:!1};default:return e}},actions:l,selectors:r,controls:ys.controls,resolvers:n,persist:["fontsPanelOpen","colorsPanelOpen","designsPanelOpen"]});const ha="coblocks_site_design_controls_enabled";var pa=o.p+"images/site-design.0ce62606.png";(0,he.registerPlugin)("coblocks-site-design-control",{render:()=>(0,a.createElement)(ns,{conditionalDisable:!0,description:(0,c.__)("Easily explore curated design styles, then customize your colors and fonts inside the editor to get the perfect fit.","coblocks"),imageAlt:(0,c.__)("Site design example","coblocks"),imageSrc:pa,label:(0,c.__)("Site Design","coblocks"),settingsKey:ha,showGoHelp:!0})});const fa=C?.outlined;let ga=!1,va=!1;const wa="_coblocks_non_existing_meta",ya=(0,c.__)("Site design","coblocks");function ba(){const e=(0,$.useSelect)((e=>e(ss).isUpdating()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignResp()),[]);return vs(),hs(),ps(),(0,m.useEffect)((()=>{if(!t||e)return;const o=document.getElementById("site-design-styles");if(ga=ga||t.fontStyles,o.innerHTML=[t.stylesheet,ga].join(" "),!o.closest("div.is-desktop-preview")){var l;const e=null!==(l=document.querySelectorAll(".is-desktop-preview style:last-of-type")?.[0])&&void 0!==l?l:document.querySelectorAll(".is-desktop-preview div")?.[0];e&&e?.after?.(o)}}),[e,t]),(0,m.useEffect)((()=>{const t=document.getElementsByClassName("interface-interface-skeleton__content");t.length>0&&t[0].classList.toggle("site-design-updating",e)}),[e]),null}function Ea(){const e=(0,$.useSelect)((e=>e(ss).showSaveBtn()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),{updateDesign:o}=(0,$.useDispatch)(ss),l=()=>o({saveChanges:!0}),n=(0,$.useSelect)((e=>e("core/editor").getCurrentPostType()),[]),r=(0,$.useSelect)((e=>e("core/editor").getCurrentPostId()),[]),{editEntityRecord:s}=(0,$.useDispatch)("core"),[c]=(0,ce.useEntityProp)("postType",n,"meta");return(0,m.useEffect)((()=>{if(e){if(va=document.getElementsByClassName("editor-post-publish-button")[0]||!1,va)return s("postType",n,r,{meta:{...c,[wa]:!0}},{undoIgnore:!0}),va.addEventListener("click",l),function(){va&&va.removeEventListener("click",l)}}else va&&(delete c[wa],s("postType",n,r,{meta:{...c}},{undoIgnore:!0}),va.removeEventListener("click",l),va=!1)}),[e]),t?(0,a.createElement)(a.Fragment,null,(0,a.createElement)(ds,null),(0,a.createElement)(ms,null),(0,a.createElement)(Qs,null)):null}const ka=C?.outlined;(0,he.registerPlugin)("coblocks-site-design",{icon:ka,render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const[e]=(0,ce.useEntityProp)("root","site",ha);return e}))])((()=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(Ut.PluginSidebar,{icon:(0,a.createElement)(Fr,{icon:fa,label:(0,c.__)("Site design","coblocks"),slug:"site-design"}),title:ya},(0,a.createElement)(Ea,null)),(0,a.createElement)(ba,null))))});const _a="coblocks_layout_selector_controls_enabled",xa=({layouts:e,category:t,onInsert:o})=>{const l=(0,$.useSelect)((e=>e("core").getEntityRecord),[]),n=l("root","site")?.image_category||"",r=(0,m.useMemo)((()=>e.filter((e=>e.category===t&&!!e.parsedBlocks?.length)).map((e=>({...e,blocks:(0,Gt.applyFilters)("coblocks.layoutPreviewBlocks",e.parsedBlocks)})))),[JSON.stringify(e),t,n]),s=(0,ie.useAsyncList)(r);return t&&r.length?(0,a.createElement)("div",{className:"coblocks-layout-selector__layouts"},(0,a.createElement)(Pa,{layouts:r,onClickLayout:o,shownLayouts:s})):(0,a.createElement)("p",null,(0,a.createElement)("em",null,(0,c.__)("No layouts are available for this category.","coblocks")))},Ca=({layout:e,onClick:t})=>{const o=za(e.blocks);return(0,a.createElement)(i.Button,{className:J()("coblocks-layout-selector__layout"),"data-testid":"coblocks-layout-selector__layout-button",onClick:()=>t(e)},(0,a.createElement)(i.Spinner,null),(0,a.createElement)("div",{className:"coblocks-layout-selector__layout-preview-container"},(0,a.createElement)(U.BlockPreview,{blocks:o,viewportWidth:700})))},za=e=>e.map((e=>(e?.attributes?.animation&&(e.attributes.animation=""),e?.innerBlocks?.length>0&&(e.innerBlocks=za(e.innerBlocks)),e))),Sa=()=>(0,a.createElement)("div",{className:"coblocks-layout-selector__layout is-placeholder","data-testid":"coblocks-layout-selector__layout-placeholder"},(0,a.createElement)(i.Spinner,null)),Pa=({layouts:e,shownLayouts:t,onClickLayout:o})=>e.map(((e,l)=>t.includes(e)?(0,a.createElement)(Ca,{key:l,layout:e,onClick:o}):(0,a.createElement)(Sa,{key:l})));var Ba=o(9588),Va=o.n(Ba);const Ma={categories:coblocksLayoutSelector.categories||[],computedLayouts:[],layoutUsage:{},layouts:coblocksLayoutSelector.layouts||[],selectedCategory:"most-used",templateSelector:!1},Ga=Va()(((e,t)=>{if(!e)return t;const o=Date.now()-e;switch(!0){case o<36e5:return 4*t;case o<864e5:return 2*t;case o<6048e5:return t/2;default:return t/4}})),Ta={closeTemplateSelector:()=>({type:"CLOSE_TEMPLATE_SELECTOR"}),incrementLayoutUsage:e=>({layout:e,time:Date.now(),type:"INCREMENT_LAYOUT_USAGE"}),openTemplateSelector:()=>({type:"OPEN_TEMPLATE_SELECTOR"}),updateCategories:e=>({categories:e,type:"UPDATE_CATEGORIES"}),updateComputedLayouts:e=>({computedLayouts:e,type:"UPDATE_COMPUTED_LAYOUTS"}),updateLayouts:e=>({layouts:e,type:"UPDATE_LAYOUTS"}),updateSelectedCategory:e=>({selectedCategory:e,type:"UPDATE_CATEGORY"})};var Na=(0,$.createReduxStore)("coblocks/template-selector",{actions:Ta,controls:ys.controls,persist:["layoutUsage"],reducer(e=Ma,t){switch(t.type){case"OPEN_TEMPLATE_SELECTOR":return{...e,templateSelector:!0};case"CLOSE_TEMPLATE_SELECTOR":return{...e,templateSelector:!1};case"UPDATE_LAYOUTS":return{...e,layouts:t.layouts};case"UPDATE_COMPUTED_LAYOUTS":return{...e,computedLayouts:t.computedLayouts};case"UPDATE_CATEGORIES":return{...e,categories:t.categories};case"UPDATE_CATEGORY":return{...e,selectedCategory:t.selectedCategory};case"INCREMENT_LAYOUT_USAGE":const o=(0,re.kebabCase)(t.layout.label);return{...e,layoutUsage:{...e.layoutUsage,[o]:{count:e.layoutUsage[o]?e.layoutUsage[o].count+1:1,time:t.time}}}}return e},resolvers:{*isTemplateSelectorActive(){const e=(0,$.select)("core/editor").isCleanNewPost(),t=(0,$.select)("core/editor").isEditedPostEmpty();return(e||t)&&Ta.openTemplateSelector()}},selectors:{getCategories:e=>e.categories||[],getComputedLayouts:e=>e.computedLayouts,getLayoutUsage:e=>e.layoutUsage,getLayouts:e=>(e.layouts||[]).map((t=>{const{time:o,count:l=0}=e.layoutUsage[(0,re.kebabCase)(t.label)]||{};return{...t,frequency:Ga(o,l)}})),getSelectedCategory:e=>e.selectedCategory,hasCategories:e=>!!e.categories.length,hasLayouts:e=>!!e.layouts.length,isTemplateSelectorActive:e=>e.templateSelector}}),Oa=function(e){const t=(0,$.select)("coblocks/template-selector").getCategories();return(0,m.useMemo)((()=>t.filter((t=>(t=>!!(t=>e.filter((e=>e.category===t))||[])(t).length)(t.slug)))),[JSON.stringify(e)])};function Ra(e,t){var o;return window.requestIdleCallback?window.requestIdleCallback(e,t):setTimeout((()=>{e({didTimeout:!0,timeRemaining:()=>1})}),null!==(o=t.timeout)&&void 0!==o?o:0)}const La=(e,t,o=[])=>(0,u.createBlock)(e,t,o&&o.map((([e,t,o])=>La(e,t,o))));let Aa=null,Ia=[],Fa=[],Da=[];const{Fill:ja,Slot:Ha}=(0,i.createSlotFill)("CoBlocksLayoutSelectorFill");function Wa({children:e}){return(0,a.createElement)(ja,null,e)}(0,he.registerPlugin)("coblocks-layout-selector-control",{render:()=>(0,Gt.applyFilters)("coblocks-show-layout-selector",!0)&&(0,a.createElement)(ye,{help:(0,c.__)("Allow layout selection on new pages","coblocks"),label:(0,c.__)("Layout selector","coblocks"),settingsKey:_a,shouldDisable:(()=>{const e="undefined"!=typeof coblocksLabs?coblocksLabs:{};return!e.isGoThemeActive||!e.isGoThemeInstalled})()})});var $a=o.p+"images/layout-selector.69de142d.png";(0,he.registerPlugin)("coblocks-labs-layout-selector-control",{render:()=>(0,a.createElement)(ns,{conditionalDisable:!0,description:(0,c.__)("Get access to high-quality, professionally designed layouts when creating new pages to make page creation easier.","coblocks"),imageAlt:(0,c.__)("Layout selector example","coblocks"),imageSrc:$a,label:(0,c.__)("Layout Selector","coblocks"),settingsKey:_a,showGoHelp:!0})}),(0,$.register)(Na);const Ua=({slug:e,title:t,isSelected:o,onClick:l})=>(0,a.createElement)("li",{className:"coblocks-layout-selector__sidebar__item",key:e},(0,a.createElement)("a",{className:J()({"is-selected":o}),href:`#${e}`,onClick:e=>{e.preventDefault(),l()}},t));class qa extends m.Component{render(){const{categories:e,selectedCategory:t,updateSelectedCategory:o,isActive:l,isMobile:n,useEmptyTemplateLayout:r,useTemplateLayout:s,layouts:u}=this.props,d=(0,Gt.applyFilters)("coblocks-layout-selector-controls",[]),h=(0,a.createElement)(a.Fragment,null,(0,a.createElement)(Ha,null),Array.isArray(d)&&d.map(((e,t)=>{let o=e;return["function","object"].includes(typeof o)?((0,m.isValidElement)(o)||(o=(0,a.createElement)(o,null)),(0,a.createElement)(Wa,{key:`layout-control-${t}`},o)):null})));return l?(0,a.createElement)(i.Modal,{className:"coblocks-layout-selector-modal",onRequestClose:r,title:(0,a.createElement)(a.Fragment,null,(0,a.createElement)("div",null,(0,c.__)("Add New Page","coblocks")),(0,a.createElement)("span",null,(0,c.__)("Pick one of these layouts or start with a blank page.","coblocks")))},(0,a.createElement)("div",{className:"coblocks-layout-selector"},n&&(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar"},(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left"},(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left__settings"},h),(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left__category"},(0,a.createElement)("strong",null,(0,c.__)("Layouts","coblocks"),":")," ",e.find((e=>e.slug===t))?.title,(0,a.createElement)(i.DropdownMenu,{label:"Select a layout category"},(({onClose:t})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.MenuGroup,{onClick:t},e.map(((e,l)=>(0,a.createElement)(i.MenuItem,{key:l,onClick:()=>{o(e.slug),t()}},e.title))))))))),(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__right"},(0,a.createElement)(i.Button,{className:"coblocks-layout-selector__add-button",isLink:!0,onClick:r},(0,a.createElement)("span",null,(0,a.createElement)(i.Icon,{icon:"plus",size:16}))," ",(0,c.__)("Add blank page","coblocks")))),!n&&(0,a.createElement)("aside",{className:"coblocks-layout-selector__sidebar"},h,(0,a.createElement)("ul",{className:"coblocks-layout-selector__sidebar__items"},e.map(((e,l)=>(0,a.createElement)(Ua,{isSelected:e.slug===t,key:l,onClick:()=>o(e.slug),slug:e.slug,title:e.title})))),(0,a.createElement)(i.Button,{className:"coblocks-layout-selector__add-button",isLink:!0,onClick:r},(0,a.createElement)("span",null,(0,a.createElement)(i.SVG,{"aria-hidden":"true",focusable:"false",height:"24",role:"img",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)(i.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"}))),(0,c.__)("Add blank page","coblocks"))),(0,a.createElement)("div",{className:"coblocks-layout-selector__content"},(0,a.createElement)(xa,{category:t,layouts:u,onInsert:e=>s(e)})))):null}}"undefined"!=typeof coblocksLayoutSelector&&coblocksLayoutSelector.postTypeEnabled&&(0,he.registerPlugin)("coblocks-layout-selector",{render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const[e]=(0,ce.useEntityProp)("root","site",_a),t=!!document.getElementsByClassName("coblocks-labs-modal")?.[0],{hasLayouts:o,hasCategories:l}=(0,$.useSelect)((e=>e("coblocks/template-selector")));return e&&!t&&o()&&l()})),(0,$.withSelect)((e=>{const{getSelectedCategory:t,isTemplateSelectorActive:o}=e("coblocks/template-selector"),{isViewportMatch:l}=e("core/viewport"),n=function(){const e=(0,$.select)("coblocks/template-selector").getLayouts(),t=(0,$.select)("coblocks/template-selector").getComputedLayouts(),o=(0,$.select)("coblocks/template-selector").getSelectedCategory(),{updateComputedLayouts:l}=(0,$.useDispatch)("coblocks/template-selector"),n=e=>[o].includes(e.category)?e.blocks?e.blocks.map((e=>Array.isArray(e)?La(e[0],e[1],e[2]):e)):(0,u.rawHandler)({HTML:e.postContent})||[]:e.parsedBlocks?e.parsedBlocks:[],r=e=>({...e,parsedBlocks:n(e)}),s=e=>{for(;(e.timeRemaining()>0||e.didTimeout)&&Ia.length;)Fa.push(r(Ia.shift()));Ia.length?Ra(s,{timeout:1e3}):l(Fa)};return(0,m.useEffect)((()=>{var t;t=Aa,window.cancelIdleCallback?window.cancelIdleCallback(t):clearTimeout(t),Fa=[];const l=(0,re.orderBy)(e,["frequency"],["desc"]).slice(0,6).map((e=>({...e,category:"most-used"})));Ia=[...l,...e],Da=[o],Aa=Ra(s,{timeout:1e3})}),[JSON.stringify(e)]),(0,m.useEffect)((()=>{Da.includes(o)||(Da.push(o),l(t.map(r)))}),[o]),t}();return{categories:Oa(n),isActive:o(),isMobile:l("< medium"),layouts:n,selectedCategory:t()}})),(0,$.withDispatch)((e=>{const{closeTemplateSelector:t,incrementLayoutUsage:o,updateSelectedCategory:l}=e("coblocks/template-selector"),{editPost:n}=e("core/editor"),{createWarningNotice:r,createSuccessNotice:s}=e("core/notices");return{closeTemplateSelector:t,createSuccessNotice:s,createWarningNotice:r,editPost:n,updateSelectedCategory:l,useEmptyTemplateLayout:()=>{n({blocks:[],title:""}),t()},useTemplateLayout:e=>{n({blocks:e.blocks,title:e.label}),t(),o(e),s((0,c.sprintf)( 62 62 // translators: %s is the post title. 63 63 (0,c.__)('"%s" layout has been added to the page.',"coblocks"),e.label),{type:"snackbar"})}}}))])(qa)});const Za={};Za.uppercase=(0,a.createElement)(i.SVG,{height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)(i.Path,{d:"m0 0v2.5h4.16666667v10.5h2.5v-10.5h4.16666663v-2.5zm16 4.5h-7.5v2.5h2.5v6h2.5v-6h2.5z",transform:"translate(2 3)"}));var Ya=Za,Qa=window.wp.richText;const Xa="coblocks/uppercase",Ka={title:(0,c.__)("Uppercase","coblocks"),tagName:"span",className:"uppercase",edit:({isActive:e,value:t,onChange:o})=>{const l=()=>o((0,Qa.toggleFormat)(t,{type:Xa}));return(0,a.createElement)(m.Fragment,null,(0,a.createElement)(U.RichTextShortcut,{type:"access",character:"u",onUse:l}),(0,a.createElement)(U.RichTextToolbarButton,{icon:Ya.uppercase,title:(0,c.__)("Uppercase","coblocks"),onClick:l,isActive:e,shortcutType:"access",shortcutCharacter:"u"}))}};[s].forEach((({name:e,settings:t})=>{(0,Qa.registerFormatType)(e,t)})),[{label:(0,c.__)("Info","coblocks"),name:"info"},{label:(0,c.__)("Success","coblocks"),name:"success"},{label:(0,c.__)("Warning","coblocks"),name:"warning"},{label:(0,c.__)("error","coblocks"),name:"error"}].forEach((e=>(0,u.registerBlockStyle)("core/paragraph",e))),(0,u.registerBlockStyle)("core/image",{name:"default", -
coblocks/tags/3.1.9/readme.txt
r3062838 r3079624 6 6 Tested up to: 6.5 7 7 Requires PHP: 7.4 8 Stable tag: 3.1. 88 Stable tag: 3.1.9 9 9 License: GPL-2.0 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 126 126 == Changelog == 127 127 128 = 3.1.9 / 2024-04-30 = 129 # Bug fix 130 * Prevent local URLs from loading with events block [#2607](https://github.com/godaddy-wordpress/coblocks/pull/2607) 131 * Fix Site Content extension loading outside of editor [#2609](https://github.com/godaddy-wordpress/coblocks/pull/2609) 132 * Fix Site Design extension failing dom operations [#2610](https://github.com/godaddy-wordpress/coblocks/pull/2610) 133 128 134 = 3.1.8 / 2024-04-02 = 129 135 # Enhancements -
coblocks/tags/3.1.9/src/blocks/events/index.php
r2949408 r3079624 18 18 if ( empty( $attributes['externalCalendarUrl'] ) ) { 19 19 return $content; 20 } 21 22 // If externalCalendarUrl contains a localhost URL, return an error message. 23 if ( strpos( $attributes['externalCalendarUrl'], 'localhost' ) !== false || strpos( $attributes['externalCalendarUrl'], '127.0' ) !== false ) { 24 return '<div class="components-placeholder"><div class="notice notice-error">' . __( 'An error has occurred. localhost URLs are not permitted.', 'coblocks' ) . '</div></div>'; 20 25 } 21 26 … … 35 40 ) 36 41 ); 37 $ical->init_url( $attributes['externalCalendarUrl']);42 $ical->init_url( esc_url_raw( $attributes['externalCalendarUrl'] ) ); 38 43 39 44 if ( 'all' === $attributes['eventsRange'] ) { -
coblocks/tags/3.1.9/src/blocks/post-carousel/index.php
r2949408 r3079624 23 23 'orderby' => $attributes['orderBy'], 24 24 'suppress_filters' => false, 25 'post__not_in' => array( $post->ID),25 'post__not_in' => ! is_null( $post ) ? array( $post->ID ) : array(), 26 26 ); 27 27 -
coblocks/tags/3.1.9/src/blocks/posts/index.php
r2949408 r3079624 23 23 'orderby' => $attributes['orderBy'], 24 24 'suppress_filters' => false, 25 'post__not_in' => array( $post->ID),25 'post__not_in' => ! is_null( $post ) ? array( $post->ID ) : array(), 26 26 ); 27 27 -
coblocks/trunk/class-coblocks.php
r3062838 r3079624 5 5 * Author: GoDaddy 6 6 * Author URI: https://www.godaddy.com 7 * Version: 3.1. 87 * Version: 3.1.9 8 8 * Text Domain: coblocks 9 9 * Domain Path: /languages … … 27 27 } 28 28 29 define( 'COBLOCKS_VERSION', '3.1. 8' );29 define( 'COBLOCKS_VERSION', '3.1.9' ); 30 30 define( 'COBLOCKS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 31 31 define( 'COBLOCKS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
coblocks/trunk/dist/coblocks-extensions.asset.php
r3042794 r3079624 1 <?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-primitives', 'wp-rich-text', 'wp-token-list'), 'version' => ' d26d885b084d3e421c8b');1 <?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-primitives', 'wp-rich-text', 'wp-token-list'), 'version' => '07e78ed2fd9aae93aa49'); -
coblocks/trunk/dist/coblocks-extensions.js
r3042794 r3079624 59 59 (0,c.__)("Could not create a new %s.","coblocks"),e.labels.singular_name))}))}onActivateRename=e=>{const{setRenameMode:t}=this.props;t(e.id).then((()=>{this.inputRefs[e.id].focus(),document.execCommand("selectAll",!1,null),document.getSelection().collapseToEnd()}))};onCompleteRename=e=>{const{props:t}=this,o=this.inputRefs[e.id].textContent;e.title.raw!==o&&Dt()({data:{title:o},method:"POST",path:`/wp/v2/${t.postType.rest_base}/${e.id}`}).then((e=>{t.receiveEntityRecords("postType",t.postType.slug,e,{},!0)})),this.onResetRename()};onResetRename=e=>{const{cancelRenameMode:t}=this.props;e&&(this.inputRefs[e.id].textContent=e.title.raw),t()};onPin(e){const{props:t}=this;Dt()({data:{sticky:!e.sticky},method:"POST",path:`/wp/v2/${t.postType.rest_base}/${e.id}`}).then((e=>{t.receiveEntityRecords("postType",t.postType.slug,e,{},!0)}))}onSetAsHome=e=>{const{props:t}=this;Dt()({data:{page_on_front:e.id},method:"POST",path:t.settingsEntity.baseURL}).then((o=>{t.receiveEntityRecords("root","site",o,{},!0),t.createSuccessNotice((0,c.sprintf)( 60 60 // translators: %s is the page title. 61 (0,c.__)('"%s" set as the homepage.',"coblocks"),e.title.raw),{type:"snackbar"})}))};handleInputKeys=(e,t)=>{switch(e.key){case"Enter":e.preventDefault(),this.onCompleteRename(t);break;case"Escape":this.onResetRename(t);break;case" ":e.stopPropagation(),e.preventDefault()}};getOrderedPublishedPages=()=>{const{entities:e,homepageId:t,homepostId:o}=this.props,l=e.filter((e=>"draft"!==e.status&&e.id!==o));return l.sort(((e,o)=>e.id===t?-1:o.id===t?1:0)),l};getOrderedPublishedPosts=()=>{const{entities:e}=this.props;return[...e.filter((e=>"draft"!==e.status&&e.sticky)),...e.filter((e=>"draft"!==e.status&&!e.sticky))]};getOrderedDrafts=()=>{const{entities:e}=this.props;return e.filter((e=>"draft"===e.status)).reverse()};renderIcon=e=>{const{homepageId:t,homepageType:o}=this.props;return e.sticky?Yr:e.id===t&&"page"===o?Wr:"post"===e.type?qr:$r};renderPageTitle=e=>{const{isInRenameMode:t}=this.props;return e.id===t?this.inputRefs[e.id]?.textContent!==(0,c.__)("(no title)","coblocks")?this.inputRefs[e.id].textContent:"":e.title.raw?e.title.raw:(0,c.__)("(no title)","coblocks")};renderRow=(e,t)=>{const{currentPostId:o,homepageId:l,homepageType:n,loadPostIntoEditor:r,isInRenameMode:s}=this.props,c=this.renderPageTitle(e),u=e.id===s;return(0,a.createElement)(i.PanelRow,{className:J()("content-management__panel__row",{current:o===e.id,"is-renaming":u}),key:t},(0,a.createElement)(i.Button,{className:J()("content-management__panel__button"),isLink:!0,onClick:()=>!s&&r(e.type,e.id)},(0,a.createElement)(a.Fragment,null,this.renderIcon(e),(0,a.createElement)("span",{contentEditable:u,onKeyUp:t=>this.handleInputKeys(t,e),ref:t=>this.inputRefs[e.id]=t,role:"textbox"},c))),(0,a.createElement)(Qr,{isSticky:e.sticky,onDeletePost:()=>this.onDelete(e),onDuplicatePost:()=>this.onDuplicate(e),onPinPost:()=>this.onPin(e),onRenamePost:()=>this.onActivateRename(e,t),onSetAsHomePost:()=>this.onSetAsHome(e),postType:e.type,shouldDiplayPinAction:"post"===e.type&&"publish"===e.status,shouldDisplayHomepageAction:"page"===n&&"page"===e.type&&"publish"===e.status&&e.id!==l}),u&&(0,a.createElement)("div",{className:"content-management__panel__rename-actions"},(0,a.createElement)(i.Button,{className:"content-management__panel__rename-action content-management__panel__rename-action--confirm",onClick:()=>this.onCompleteRename(e)},(0,a.createElement)(i.Icon,{icon:ae,size:22})),(0,a.createElement)(i.Button,{className:"content-management__panel__rename-action content-management__panel__rename-action--cancel",onClick:()=>this.onResetRename(e)},(0,a.createElement)(i.Icon,{icon:Dr,size:20}))))};render(){const{props:e}=this,t="page"===e.postType.slug?this.getOrderedPublishedPages():this.getOrderedPublishedPosts(),o=this.getOrderedDrafts();return(0,a.createElement)(i.PanelBody,{className:J()("content-management__panel",{"is-renaming":e.isInRenameMode}),initialOpen:e.postType.slug===e.currentPostType,key:e.postType.slug,title:e.postType.name},t&&t.map(this.renderRow),o&&o.length>0&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h3",{className:"content-management__panel__separator"},(0,a.createElement)("span",null,(0,c.__)("Drafts","coblocks"))),o.map(this.renderRow)),(0,a.createElement)(i.Tooltip,{text:e.postType.labels.add_new_item},(0,a.createElement)(i.Button,{className:"content-management__add-new-button",onClick:()=>this.onCreateNew(e.postType)},(0,a.createElement)(i.Icon,{icon:jr,size:28}))))}}var Jr=(0,ie.compose)([(0,$.withSelect)(((e,t)=>{const{getCurrentPostId:o,getCurrentPostType:l}=e("core/editor"),{getEntityRecords:n,getEntityRecord:r,getEntity:s}=e("core"),a={};(n("postType",t.postType.slug,{per_page:-1,status:["publish","future","pending","private","draft"]})||[]).forEach((e=>a[e.id]=e));const{page_on_front:c,page_for_posts:i,show_on_front:u}=r("root","site")||{},{isInRenameMode:m}=e("coblocks/site-content");return{currentPostId:o(),currentPostType:l(),entities:Object.values(a),homepageId:c,homepageType:u,homepostId:i,isInRenameMode:m(),settingsEntity:s("root","site")}})),(0,$.withDispatch)((e=>{const{editEntityRecord:t,receiveEntityRecords:o,saveEntityRecord:l}=e("core"),{savePost:n}=e("core/editor"),{createErrorNotice:r,createSuccessNotice:s}=e("core/notices"),{cancelRenameMode:a,setRenameMode:c}=e("coblocks/site-content"),{openTemplateSelector:i}=e("coblocks/template-selector");return{cancelRenameMode:a,createErrorNotice:r,createSuccessNotice:s,editEntityRecord:t,openTemplateSelector:i,receiveEntityRecords:o,saveEntityRecord:l,savePost:n,setRenameMode:c}}))])(Kr);const es="coblocks_site_content_controls_enabled",ts="undefined"!=typeof coblocksLabs?coblocksLabs:{},os=()=>{const{isGoThemeActive:e,isGoThemeInstalled:t,goThemeDetailsUri:o,goThemeInstallUri:l}=ts;return e&&t?(0,c.__)("This feature requires the Go Theme.","coblocks"):t?(0,a.createElement)(a.Fragment,null," ",(0,c.__)("This feature requires the Go Theme - ","coblocks"),(0,a.createElement)("a",{href:o,rel:"noopener noreferrer",target:"_blank"},(0,c.__)("Activate","coblocks"))):(0,a.createElement)(a.Fragment,null," ",(0,c.__)("This feature requires the Go Theme - ","coblocks"),(0,a.createElement)("a",{href:l,rel:"noopener noreferrer",target:"_blank"},(0,c.__)("Install now","coblocks")))},ls=()=>{const{isGoThemeActive:e,isGoThemeInstalled:t}=ts;return!e||!t};var ns=function({label:e,help:t,description:o,imageSrc:l,imageAlt:n,settingsKey:r,showGoHelp:s,conditionalDisable:c=!1}){const[u,m]=(0,ce.useEntityProp)("root","site",r);return(0,a.createElement)(Xt,null,(0,a.createElement)("section",{className:"coblocks-labs-modal__section"},(0,a.createElement)("div",{className:"coblocks-labs-modal__section__vertical-group"},(0,a.createElement)("h2",{className:"coblocks-labs-modal__section__heading"},e),o&&(0,a.createElement)("p",{className:"coblocks-labs-modal__section__description"},o),(0,a.createElement)(i.ToggleControl,{checked:!!u,disabled:!!c&&ls(),help:s?os():"",onChange:m})),(0,a.createElement)("figure",null,(0,a.createElement)("img",{alt:n,src:l}))),(0,a.createElement)("hr",null))},rs=o.p+"images/site-content.da68e2d6.png";(0,he.registerPlugin)("coblocks-site-content-control",{render:()=>(0,a.createElement)(ns,{description:(0,c.__)("Quickly and easily manage your websites pages and posts from inside the editor.","coblocks"),imageAlt:(0,c.__)("Site content example","coblocks"),imageSrc:rs,label:(0,c.__)("Site Content","coblocks"),settingsKey:es})}),(0,he.registerPlugin)("coblocks-site-content",{icon:z,render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const [e]=(0,ce.useEntityProp)("root","site",es),t=!!(0,$.select)("core/editor");return e&&t})),(0,$.withSelect)((e=>{const{getCurrentPostId:t,getEditedPostAttribute:o}=e("core/editor"),{getPostTypes:l}=e("core"),n=(l()||[]).filter((e=>!0===e.viewable&&["post","page"].includes(e.slug)));return{currentPageMeta:o("meta"),currentPostId:t(),postTypes:(0,re.sortBy)(n,["name"])}})),(0,$.withDispatch)((e=>{const{editPost:t}=e("core/editor");return{editPost:t}}))])((e=>{(0,m.useEffect)((()=>{const{currentPageMeta:t,editPost:o}=e;t&&"enabled"===t.hide_page_title&&wp.domReady((()=>{document.getElementsByClassName("edit-post-visual-editor__post-title-wrapper")[0]&&(document.getElementsByClassName("edit-post-visual-editor__post-title-wrapper")[0].style.display="none",o({meta:{hide_page_title:"enabled"}}))}))}),[]);const t=(e,t)=>{window.location.href=`/wp-admin/post.php?post=${t}&action=edit`},{postTypes:o}=e;return(0,a.createElement)("span",{"data-test":"site-content__container"},(0,a.createElement)(Ut.PluginSidebar,{className:"content-management",icon:(0,a.createElement)(Fr,{icon:z,label:(0,c.__)("Site content","coblocks"),slug:"site-content"}),title:(0,c.__)("Site contents","coblocks")},o.map((e=>(0,a.createElement)("span",{"data-test":"post-type-panel",key:e.slug},(0,a.createElement)(Jr,{loadPostIntoEditor:t,postType:e}))))))}))});var ss="coblocks/site-design";function as({slug:e,palette:t,isActive:o}){const l=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),n=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]),{updateColorPalette:r}=(0,$.useDispatch)(ss),s=J()("color-palette",{"is-selected":o}),c=(0,m.useCallback)((()=>{n!==e&&r(e)}),[e,n,l]);return(0,a.createElement)(i.Button,{className:s,onClick:c},Object.entries(t).reverse().map((([e,t])=>"background"!==e?(0,a.createElement)(i.ColorIndicator,{colorValue:t,key:`color-preview-${e}`}):null)))}function cs({previousPalette:e,onUpdateColors:t,onDismissCustom:o}){const l=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),n=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]);return l&&"custom"===n?(0,a.createElement)("div",{className:"color-palette-custom components-site-design__custom"},(0,a.createElement)("div",{className:"color-palette-custom__title"},(0,c.__)("Custom Colors","coblocks")),e&&(0,a.createElement)("button",{className:"components-site-design__custom__dismiss",onClick:o},(0,a.createElement)("span",null,(0,c.__)("Dismiss custom color","coblocks"))),Object.entries(l).map((([e,o])=>(0,a.createElement)(i.Dropdown,{key:`color-picker-${e}`,position:"bottom center",renderContent:()=>(0,a.createElement)(i.ColorPicker,{color:is(l,e,o),disableAlpha:!0,onChangeComplete:o=>{const l=document.getElementsByClassName(`has-${e}-background-color`);if(l.length)for(let e=0;e<l.length;e++)l[e].style.backgroundColor=o.hex;const n=document.getElementsByClassName(`has-${e}-color`);if(n.length)for(let e=0;e<n.length;e++)n[e].style.color=o.hex;t({[e]:o.hex})}}),renderToggle:({isOpen:t,onToggle:n})=>(0,a.createElement)(i.Button,{"aria-expanded":t,className:"color-palette-custom__color",isLink:!0,onClick:n},(0,a.createElement)(i.ColorIndicator,{colorValue:is(l,e,o),key:`color-${e}`}),us(e))})))):null}const is=(e,t,o)=>void 0!==Object.keys(e).shift()&&e[t]?e[t].includes("#")?e[t]:`#${e[t]}`:o,us=e=>{const t=e.toLowerCase().split(" ");for(let e=0;e<t.length;e++)t[e]=t[e].charAt(0).toUpperCase()+t[e].substring(1);return t.join(" ")};var ms=function(){const e=(0,$.useSelect)((e=>e("core/block-editor").getSettings),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),o=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),l=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]),n=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),r=(0,$.useSelect)((e=>e(ss).isColorsPanelOpen()),[]),s=(0,$.useDispatch)("core/block-editor").updateSettings,{updateCustomColors:u,updateColorPalette:d,toggleColorsPanel:h}=(0,$.useDispatch)(ss),[p,f]=(0,m.useState)(null);(0,m.useEffect)((()=>{n&&(g(),Object.entries(n).forEach((([e,t])=>{document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty(`--go--color--${e}`,t)})))}),[n]);const g=(t={})=>{const o={...n,...t};"custom"===l&&f(null),s({...e(),colors:Object.entries(o).map((([e,t])=>({name:e,slug:e,color:t})))}),u({...n,...t})};return(0,a.createElement)(i.PanelBody,{className:"site-design--colors__panel",onToggle:h,opened:r,title:(0,c.__)("Colors","coblocks")},(0,a.createElement)(i.BaseControl,{className:"components-site-design-color-palettes"},(0,a.createElement)(cs,{onDismissCustom:()=>d(p),onUpdateColors:g,previousPalette:p}),(0,a.createElement)("div",{className:"color-palettes"},(0,a.createElement)("div",{className:"color-palettes__title"},(0,a.createElement)("span",null,(0,c.__)("Color Palettes","coblocks")),"custom"!==l&&(0,a.createElement)("button",{className:"color-palettes__custom-button",onClick:()=>{f(l),d("custom"),g()}},(0,c.__)("Custom","coblocks"))),(0,a.createElement)("div",{className:"color-palettes__palettes"},t&&t.palettes.map((([e,t])=>(0,a.createElement)(as,{isActive:l.replace(`${o}-`,"")===e,key:`palette-${e}`,palette:t,slug:e})))))))},ds=function(){const e=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyles()),[]),o=(0,$.useSelect)((e=>e(ss).isDesignsPanelOpen()),[]),l=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),n=(0,$.useSelect)((e=>e(ss).isUpdating()),[]),r=t?.find((t=>t.slug===e)),{updateDesign:s,toggleDesignsPanel:u}=(0,$.useDispatch)(ss),m=(e,t)=>{const o=[e.tertiary,e.secondary,e.primary];return(0,a.createElement)("div",{className:"components-site-design-designs__design__colors"},o.map(((e,o)=>(0,a.createElement)("li",{className:"components-site-design-designs__design__color",key:`components-site-design-designs__design__color-${t}-${o}`,style:{backgroundColor:e}}))))};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.PanelBody,{className:"site-design--designs__panel components-site-design-designs",onToggle:u,opened:o,title:(0,c.__)("Design Styles","coblocks")},(0,a.createElement)("p",null,(0,c.__)("Easily explore curated design styles, then customize your colors and fonts to get the perfect fit.","coblocks")),(0,a.createElement)(Ir,null,t&&t.map(((t,o)=>(0,a.createElement)("button",{className:J()("components-site-design-designs__design",{"components-site-design-designs__design--selected":t.slug===e,"components-site-design-designs__design--updating":n}),"data-test":`design-button-${t.slug}`,key:`design-button-${t.slug}`,onClick:()=>(t=>{t!==e&&s({designStyle:t})})(t.slug)},(0,a.createElement)("div",{className:"components-site-design-designs__design__content"},(0,a.createElement)("div",{className:"components-site-design-designs__design__label",style:{fontFamily:Object.entries(t.fonts)[0][0]}},t.label),m(t.slug!==e||n?t.palettes[0][1]:l,o))))))),!o&&!!r&&(0,a.createElement)("div",{className:"components-site-design-design components-panel__body is-opened"},(0,a.createElement)("button",{className:"components-site-design-designs__design components-site-design-designs__design--current",onClick:u},(0,a.createElement)("div",{className:"components-site-design-designs__design__content"},(0,a.createElement)("div",{className:"components-site-design-designs__design__label",style:{fontFamily:Object.entries(r.fonts)[0][0]}},r.label),m(l,9999)))))},hs=function(){const e=(0,$.useSelect)((e=>e(ss).getFontSize()),[]),t=Number(e?.replace("rem","")),o=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),l=Number(o?.font_size?.replace("rem",""));return(0,m.useEffect)((()=>{t&&document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty("--go--font-size",`${t}rem`)}),[t]),[t,l]},ps=function(){const e=(0,$.useSelect)((e=>e(ss).getTypeRatio()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),o=t?.type_ratio;return(0,m.useEffect)((()=>{e&&document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty("--go--type-ratio",e)}),[e]),[e,o]};const fs="custom";var gs=function e(){const[t,o]=hs(),[l,n]=ps(),{updateFontSize:r,updateTypeRatio:s}=(0,$.useDispatch)(ss),u=(0,ie.useInstanceId)(e),d=(0,m.useMemo)((()=>function(e){return e?[{key:"small",name:(0,c.__)("Small","coblocks"),style:{fontSize:`${(.8*e).toFixed(2)}rem`}},{key:"normal",name:(0,c.__)("Normal","coblocks"),style:{fontSize:`${e.toFixed(2)}rem`}},{key:"large",name:(0,c.__)("Large","coblocks"),style:{fontSize:`${(1.3*e).toFixed(2)}rem`}},{key:fs,name:(0,c.__)("Custom")}]:[]}(o)),[o]),h=(0,m.useMemo)((()=>function(e,t){if(t){const o=e.find((e=>e.style?.fontSize===`${t.toFixed(2)}rem`));return o?o.key:fs}return"normal"}(d,t)),[d,t]),p=(0,m.useCallback)((({selectedItem:e})=>{const t=e?.style?.fontSize;t&&r(t)}));if(!d)return null;const f=`components-font-size-picker__number#${u}`;return(0,a.createElement)("fieldset",{className:"components-font-size-picker"},(0,a.createElement)(i.VisuallyHidden,{as:"legend"},(0,c.__)("Base size","coblocks")),(0,a.createElement)("div",{className:"components-font-size-picker__controls"},t&&(0,a.createElement)(i.CustomSelectControl,{className:"components-font-size-picker__select",label:(0,c.__)("Font size","coblocks"),onChange:p,options:d,value:d.find((e=>e.key===h))}),(0,a.createElement)("div",{className:"components-font-size-picker__number-container"},(0,a.createElement)("input",{"aria-label":(0,c.__)("Custom"),className:"components-font-size-picker__number",id:f,max:5,min:0,onChange:e=>{r(`${e.target.value}rem`)},step:.01,type:"number",value:t||""}))),(0,a.createElement)("div",{className:"components-font-size-picker__heading-container"},(0,a.createElement)(i.RangeControl,{className:"components-font-size-picker__heading-scale",initialPosition:l,label:(0,c.__)("Heading Scale","coblocks"),max:1.15*n,min:.9*n,onChange:s,showTooltip:!1,step:.01,value:l||"",withInputField:!1})))},vs=function(){const e=(0,$.useSelect)((e=>e(ss).getFonts()),[]),t=(0,$.useSelect)((e=>e(ss).getSelectedFonts()),[]);return(0,m.useEffect)((()=>{if(!t)return;const[e,o]=t[0],[l,n]=t[1],r=document.getElementsByClassName(siteDesign.editorClass)[0];r&&(r.style.setProperty("--go-heading--font-family",e),r.style.setProperty("--go-heading--font-weight",o[0]),r.style.setProperty("--go--font-family",l),r.style.setProperty("--go--font-weight",n[0]))}),[t]),[e,t]},ws=function(e){const[t,o]=hs(),[l,n]=ps(),[r,s]=vs(),{updateFontSize:u,updateTypeRatio:d,updateSelectedFonts:h}=(0,$.useDispatch)(ss),p=(0,m.useMemo)((()=>(e=>e.flat().sort().filter(((e,t,o)=>o.findIndex((t=>t[0]===e[0]))===t)).map((e=>({key:e[0],name:e[0],style:{fontFamily:e[0]},weights:e[1],weightsOptions:e[1].map((t=>({key:t,name:t,style:{fontWeight:t,fontFamily:e[0]}})))}))))(r)),[r]),[f,g]=s[0],[v,w]=s[1],y=p.find((e=>e.key===f)),b=y.weightsOptions.find((e=>e.key===g[0])),E=p.find((e=>e.key===v)),k=E.weightsOptions.find((e=>e.key===w[0])),{onClose:_}=e;return(0,a.createElement)("div",{className:"components-site-design__custom"},(0,a.createElement)("strong",null,(0,c.__)("Custom Font Options","coblocks")),(0,a.createElement)("button",{className:"components-site-design__custom__dismiss",onClick:_},(0,a.createElement)("span",null,"Dismiss custom color")),(0,a.createElement)("fieldset",{className:"components-site-design__custom__body"},(0,a.createElement)("strong",null,(0,c.__)("HEADING","coblocks")),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Font","coblocks"),onChange:({selectedItem:e})=>h([[e.key,e.weights],s[1]]),options:p,value:y}),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Weight","coblocks"),onChange:({selectedItem:e})=>h([[f,[e.key]],s[1]]),options:y.weightsOptions,value:b}),(0,a.createElement)(i.RangeControl,{initialPosition:l,label:(0,c.__)("Size","coblocks"),max:1.15*n,min:.9*n,onChange:d,showTooltip:!1,step:.01,value:l||"",withInputField:!1})),(0,a.createElement)("hr",{className:"components-site-design-fonts__advanced__separator"}),(0,a.createElement)("fieldset",{className:"components-site-design-fonts__advanced__heading"},(0,a.createElement)(i.VisuallyHidden,{as:"legend"},(0,c.__)("Heading font size","coblocks")),(0,a.createElement)("strong",null,(0,c.__)("BODY","coblocks")),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Font","coblocks"),onChange:({selectedItem:e})=>h([s[0],[e.key,e.weights]]),options:p,style:{fontFamily:E.key},value:E}),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Weight","coblocks"),onChange:({selectedItem:e})=>h([s[0],[v,[e.key]]]),options:E.weightsOptions,value:k}),(0,a.createElement)(i.RangeControl,{initialPosition:0,label:(0,c.__)("Size","coblocks"),max:(2*o).toFixed(2),min:(.8*o).toFixed(2),onChange:e=>u(`${e}rem`),showTooltip:!1,step:.01,value:t,withInputField:!1})))},ys=window.wp.dataControls;const bs="TOGGLE_COLORS_PANEL",Es="TOGGLE_DESIGNS_PANEL",ks="TOGGLE_FONTS_PANEL",_s="TOGGLE_IS_UPDATING",xs="UPDATE_COLOR_PALETTE",Cs="UPDATE_CUSTOM_COLORS",zs="UPDATE_DESIGN",Ss="UPDATE_DESIGN_STYLE",Ps="UPDATE_FONT_SIZE",Bs="UPDATE_REF_STATE",Vs="UPDATE_SELECTED_FONTS",Ms="UPDATE_TYPE_RATIO",{resolveSelect:Gs}=$.controls;function*Ts({designStyle:e="none",saveChanges:t=!1,initialLoad:o=!1}){const l=yield Gs(ss,"getColorPalette");let{colorPalette:n=("custom"===l?"custom":"one"),customColors:r=("custom"===l?yield Gs(ss,"getCurrentColors"):null),fonts:s=!1,fontSize:a=!1,typeRatio:c=!1}={};t&&(e=yield Gs(ss,"getDesignStyle"),n=yield Gs(ss,"getColorPalette"),r=yield Gs(ss,"getCurrentColors"),s=yield Gs(ss,"getSelectedFonts"),s=(0,re.cloneDeep)(s),siteDesign.isAdvancedFontsEnabled&&(s[0][0]=`${s[0][0]}_heading`,s[1][0]=`${s[1][0]}_body`),s=JSON.stringify(Object.fromEntries(s)),a=yield Gs(ss,"getFontSize"),c=yield Gs(ss,"getTypeRatio"));const i=new FormData;let u;i.append("action","site_design_update_design_style"),i.append("nonce",coblocksBlockData.labsSiteDesignNonce),i.append("design_style",e),i.append("color_palette",n),i.append("fonts",s),i.append("font_size",a),i.append("type_ratio",c),i.append("should_update",t),i.append("initial_load",o),r&&Object.keys(r).forEach((e=>i.append(`${e}_color`,r[e]))),o||(yield Hs()),yield Ns(e);try{u=yield(0,ys.apiFetch)({body:i,method:"POST",path:`${coblocksBlockData.baseApiNamespace}/${siteDesign.apiRoute}`})}catch(e){return void console.log("Error updating design",e)}if(u&&(yield{newState:{designResp:u},type:zs},!o)){if(yield Os(n),!1===s){const e=yield Gs(ss,"getDesignStyleObj");yield Is(Object.entries(e.fonts)),yield Ls(e.font_size),yield As(e.type_ratio)}yield Hs(),t&&(yield Ws())}}const Ns=e=>({newState:{designStyle:e},type:Ss});function*Os(e){const t=yield Gs(ss,"getDesignStyleObj"),o=Object.fromEntries(t.palettes)[e];if("custom"!==e&&(yield Rs(o)),null==o||!Object.entries(o).length)return{newState:{colorPalette:e},type:xs};for(const[e,t]of Object.entries(o)){const o=document.getElementsByClassName(`has-${e}-background-color`);if(o.length)for(let e=0;e<o.length;e++)o[e].style.backgroundColor=t;const l=document.getElementsByClassName(`has-${e}-color`);if(l.length)for(let e=0;e<l.length;e++)l[e].style.color=t}return{newState:{colorPalette:e},type:xs}}const Rs=e=>({newState:{currentColors:e},type:Cs}),Ls=e=>({newState:{fontSize:e},type:Ps}),As=e=>({newState:{typeRatio:e},type:Ms}),Is=e=>({newState:{selectedFonts:e},type:Vs}),Fs=()=>({stateProp:"fontsPanelOpen",type:ks}),Ds=()=>({stateProp:"colorsPanelOpen",type:bs}),js=()=>({stateProp:"designsPanelOpen",type:Es}),Hs=()=>({stateProp:"isUpdating",type:_s}),Ws=()=>({type:Bs}),{resolveSelect:$s}=$.controls;function*Us(){const e=yield $s(ss,"getDesignStyle"),t=yield $s(ss,"getColorPalette"),o=yield $s(ss,"getCurrentColors");yield Ts({designStyle:e,colorPalette:t,customColors:o,initialLoad:!0})}function qs(e,t){if(!e)return-1;const o=e.map((e=>e[0]));return t.map((e=>[e[0][0],e[1][0]])).findIndex((e=>0===(0,re.difference)(e,o).length))}function Zs({selected:e}){const[t,o]=(0,m.useState)(!1);return(0,m.useEffect)((()=>{-1===e&&o(!0)}),[e]),siteDesign.isAdvancedFontsEnabled?(0,a.createElement)(a.Fragment,null,t&&(0,a.createElement)(ws,{onClose:()=>o(!1)}),!t&&(0,a.createElement)("button",{className:J()("components-site-design-fonts__heading__custom",{"components-site-design-fonts__heading__custom--open":t}),onClick:()=>o((e=>!e))},(0,c.__)("Custom","coblocks"))):null}function Ys({font:e,isSelected:t}){const{updateSelectedFonts:o}=(0,$.useDispatch)(ss),[l,n]=(0,m.useState)(!1),r=(0,m.useCallback)((()=>{o(e),n(!1)}),[e,n]),s=t?"div":"button",u={};return"button"===s&&(u.onClick=r),(0,a.createElement)("li",{className:J()("components-site-design-fonts__option",{"is-selected":t})},(0,a.createElement)(s,{...u,className:"components-site-design-fonts__option__section"},(0,a.createElement)("p",{className:"components-site-design-fonts__option__primary",style:{fontFamily:e[0][0]}},e[0][0]),(0,a.createElement)("p",{className:"components-site-design-fonts__option__secondary",style:{fontFamily:e[1][0]}},(0,c.__)("The quick brown fox jumped over the lazy dog.","coblocks")),t&&(0,a.createElement)("button",{className:"components-site-design-fonts__option__edit",onClick:()=>n((e=>!e))},(0,a.createElement)("span",{className:"icon"},(0,a.createElement)(i.Icon,{icon:S})),l?(0,c.__)("Hide font sizes","coblocks"):(0,c.__)("Edit font sizes","coblocks"))),t&&l&&(0,a.createElement)("div",{className:"components-site-design-fonts__option__settings components-site-design-fonts__option__section"},(0,a.createElement)(gs,null)))}var Qs=function e(){const t=`font-preview-${(0,ie.useInstanceId)(e)}`,[o,l]=vs(),n=(0,$.useSelect)((e=>e(ss).isFontsPanelOpen()),[]),{toggleFontsPanel:r}=(0,$.useDispatch)(ss);if(!o)return null;const s=qs(l,o);return(0,a.createElement)(i.PanelBody,{className:"components-site-design components-site-design-fonts site-design--fonts__panel",onToggle:r,opened:n,title:(0,c.__)("Fonts","coblocks")},(0,a.createElement)("div",{className:"components-site-design-fonts__heading"},(0,a.createElement)(Zs,{selected:s}),(0,a.createElement)("p",null,(0,c.__)("Font Pairings","coblocks"))),(0,a.createElement)("ul",{className:"components-site-design-fonts__options"},o.map(((e,o)=>(0,a.createElement)(Ys,{font:e,isSelected:o===s,key:`${t}-${o}`})))))};const Xs=(e,t)=>Object.keys(t).some((o=>!(0,re.isEqual)(e[o],t[o])));const Ks=e=>e.designResp,Js=e=>e.designStyle,ea=e=>e.designStyles,ta=e=>e.designStyles?.find((t=>t.slug===e.designStyle)),oa=e=>e.colorPalette,la=e=>e.currentColors,na=e=>e.fontSize,ra=e=>e.typeRatio,sa=e=>e.fonts,aa=e=>e.showSaveBtn,ca=e=>e.selectedFonts,ia=e=>e.fontsPanelOpen,ua=e=>e.colorsPanelOpen,ma=e=>e.designsPanelOpen,da=e=>e.isUpdating;(0,$.registerStore)(ss,{reducer:(e={},t)=>{switch((0,$.use)($.plugins.persistence,e),(0,re.isEmpty)(e)&&(e=(()=>{if("undefined"==typeof siteDesign||(0,re.isEmpty)(siteDesign))return{};const e=e=>Object.entries(e).map((e=>(e[0]=e[0].replace(/_(heading|body)/,""),e))),t=siteDesign?.fonts?.map((t=>e(t))),o=Object.entries(siteDesign?.availableDesignStyles).map((([,e])=>({...e,palettes:Object.entries(e.color_schemes).map((([e,t])=>[e,Object.fromEntries(["primary","secondary","tertiary","background"].map((e=>[e,t[e]])))]))}))),l={colorPalette:siteDesign.currentColorScheme,colorsPanelOpen:!0,currentColors:Object.fromEntries(Object.entries(siteDesign.currentColors).filter((e=>e[1]))),designStyle:siteDesign.currentDesignStyle,designStyles:o,designsPanelOpen:!0,fontSize:siteDesign?.fontSize,fonts:t,fontsPanelOpen:!0,isUpdating:!1,selectedFonts:(()=>{const t=siteDesign?.currentFonts;return t?e(t):null})(),showSaveBtn:!1,typeRatio:siteDesign?.typeRatio};return l.refState={...l},l})()),t.type){case zs:return{...e,...t.newState};case Ss:case xs:case Vs:case Cs:case Ps:case Ms:return{...e,...t.newState,showSaveBtn:Xs(e.refState,{colorPalette:e.colorPalette,currentColors:e.currentColors,designStyle:e.designStyle,fontSize:e.fontSize,selectedFonts:e.selectedFonts,typeRatio:e.typeRatio,...t.newState})};case ks:case bs:case Es:case _s:return{...e,[t.stateProp]:!e[t.stateProp]};case Bs:const o={...e};return delete o.refState,{...e,refState:o,showSaveBtn:!1};default:return e}},actions:l,selectors:r,controls:ys.controls,resolvers:n,persist:["fontsPanelOpen","colorsPanelOpen","designsPanelOpen"]});const ha="coblocks_site_design_controls_enabled";var pa=o.p+"images/site-design.0ce62606.png";(0,he.registerPlugin)("coblocks-site-design-control",{render:()=>(0,a.createElement)(ns,{conditionalDisable:!0,description:(0,c.__)("Easily explore curated design styles, then customize your colors and fonts inside the editor to get the perfect fit.","coblocks"),imageAlt:(0,c.__)("Site design example","coblocks"),imageSrc:pa,label:(0,c.__)("Site Design","coblocks"),settingsKey:ha,showGoHelp:!0})});const fa=C?.outlined;let ga=!1,va=!1;const wa="_coblocks_non_existing_meta",ya=(0,c.__)("Site design","coblocks");function ba(){const e=(0,$.useSelect)((e=>e(ss).isUpdating()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignResp()),[]);return vs(),hs(),ps(),(0,m.useEffect)((()=>{if(!t||e)return;const o=document.getElementById("site-design-styles");ga=ga||t.fontStyles,o.innerHTML=[t.stylesheet,ga].join(" "),o.closest("div.is-desktop-preview")||document.querySelectorAll(".is-desktop-preview style:last-of-type")?.[0].after(o)}),[e,t]),(0,m.useEffect)((()=>{const t=document.getElementsByClassName("interface-interface-skeleton__content");t.length>0&&t[0].classList.toggle("site-design-updating",e)}),[e]),null}function Ea(){const e=(0,$.useSelect)((e=>e(ss).showSaveBtn()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),{updateDesign:o}=(0,$.useDispatch)(ss),l=()=>o({saveChanges:!0}),n=(0,$.useSelect)((e=>e("core/editor").getCurrentPostType()),[]),r=(0,$.useSelect)((e=>e("core/editor").getCurrentPostId()),[]),{editEntityRecord:s}=(0,$.useDispatch)("core"),[c]=(0,ce.useEntityProp)("postType",n,"meta");return(0,m.useEffect)((()=>{if(e){if(va=document.getElementsByClassName("editor-post-publish-button")[0]||!1,va)return s("postType",n,r,{meta:{...c,[wa]:!0}},{undoIgnore:!0}),va.addEventListener("click",l),function(){va&&va.removeEventListener("click",l)}}else va&&(delete c[wa],s("postType",n,r,{meta:{...c}},{undoIgnore:!0}),va.removeEventListener("click",l),va=!1)}),[e]),t?(0,a.createElement)(a.Fragment,null,(0,a.createElement)(ds,null),(0,a.createElement)(ms,null),(0,a.createElement)(Qs,null)):null}const ka=C?.outlined;(0,he.registerPlugin)("coblocks-site-design",{icon:ka,render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const[e]=(0,ce.useEntityProp)("root","site",ha);return e}))])((()=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(Ut.PluginSidebar,{icon:(0,a.createElement)(Fr,{icon:fa,label:(0,c.__)("Site design","coblocks"),slug:"site-design"}),title:ya},(0,a.createElement)(Ea,null)),(0,a.createElement)(ba,null))))});const _a="coblocks_layout_selector_controls_enabled",xa=({layouts:e,category:t,onInsert:o})=>{const l=(0,$.useSelect)((e=>e("core").getEntityRecord),[]),n=l("root","site")?.image_category||"",r=(0,m.useMemo)((()=>e.filter((e=>e.category===t&&!!e.parsedBlocks?.length)).map((e=>({...e,blocks:(0,Gt.applyFilters)("coblocks.layoutPreviewBlocks",e.parsedBlocks)})))),[JSON.stringify(e),t,n]),s=(0,ie.useAsyncList)(r);return t&&r.length?(0,a.createElement)("div",{className:"coblocks-layout-selector__layouts"},(0,a.createElement)(Pa,{layouts:r,onClickLayout:o,shownLayouts:s})):(0,a.createElement)("p",null,(0,a.createElement)("em",null,(0,c.__)("No layouts are available for this category.","coblocks")))},Ca=({layout:e,onClick:t})=>{const o=za(e.blocks);return(0,a.createElement)(i.Button,{className:J()("coblocks-layout-selector__layout"),"data-testid":"coblocks-layout-selector__layout-button",onClick:()=>t(e)},(0,a.createElement)(i.Spinner,null),(0,a.createElement)("div",{className:"coblocks-layout-selector__layout-preview-container"},(0,a.createElement)(U.BlockPreview,{blocks:o,viewportWidth:700})))},za=e=>e.map((e=>(e?.attributes?.animation&&(e.attributes.animation=""),e?.innerBlocks?.length>0&&(e.innerBlocks=za(e.innerBlocks)),e))),Sa=()=>(0,a.createElement)("div",{className:"coblocks-layout-selector__layout is-placeholder","data-testid":"coblocks-layout-selector__layout-placeholder"},(0,a.createElement)(i.Spinner,null)),Pa=({layouts:e,shownLayouts:t,onClickLayout:o})=>e.map(((e,l)=>t.includes(e)?(0,a.createElement)(Ca,{key:l,layout:e,onClick:o}):(0,a.createElement)(Sa,{key:l})));var Ba=o(9588),Va=o.n(Ba);const Ma={categories:coblocksLayoutSelector.categories||[],computedLayouts:[],layoutUsage:{},layouts:coblocksLayoutSelector.layouts||[],selectedCategory:"most-used",templateSelector:!1},Ga=Va()(((e,t)=>{if(!e)return t;const o=Date.now()-e;switch(!0){case o<36e5:return 4*t;case o<864e5:return 2*t;case o<6048e5:return t/2;default:return t/4}})),Ta={closeTemplateSelector:()=>({type:"CLOSE_TEMPLATE_SELECTOR"}),incrementLayoutUsage:e=>({layout:e,time:Date.now(),type:"INCREMENT_LAYOUT_USAGE"}),openTemplateSelector:()=>({type:"OPEN_TEMPLATE_SELECTOR"}),updateCategories:e=>({categories:e,type:"UPDATE_CATEGORIES"}),updateComputedLayouts:e=>({computedLayouts:e,type:"UPDATE_COMPUTED_LAYOUTS"}),updateLayouts:e=>({layouts:e,type:"UPDATE_LAYOUTS"}),updateSelectedCategory:e=>({selectedCategory:e,type:"UPDATE_CATEGORY"})};var Na=(0,$.createReduxStore)("coblocks/template-selector",{actions:Ta,controls:ys.controls,persist:["layoutUsage"],reducer(e=Ma,t){switch(t.type){case"OPEN_TEMPLATE_SELECTOR":return{...e,templateSelector:!0};case"CLOSE_TEMPLATE_SELECTOR":return{...e,templateSelector:!1};case"UPDATE_LAYOUTS":return{...e,layouts:t.layouts};case"UPDATE_COMPUTED_LAYOUTS":return{...e,computedLayouts:t.computedLayouts};case"UPDATE_CATEGORIES":return{...e,categories:t.categories};case"UPDATE_CATEGORY":return{...e,selectedCategory:t.selectedCategory};case"INCREMENT_LAYOUT_USAGE":const o=(0,re.kebabCase)(t.layout.label);return{...e,layoutUsage:{...e.layoutUsage,[o]:{count:e.layoutUsage[o]?e.layoutUsage[o].count+1:1,time:t.time}}}}return e},resolvers:{*isTemplateSelectorActive(){const e=(0,$.select)("core/editor").isCleanNewPost(),t=(0,$.select)("core/editor").isEditedPostEmpty();return(e||t)&&Ta.openTemplateSelector()}},selectors:{getCategories:e=>e.categories||[],getComputedLayouts:e=>e.computedLayouts,getLayoutUsage:e=>e.layoutUsage,getLayouts:e=>(e.layouts||[]).map((t=>{const{time:o,count:l=0}=e.layoutUsage[(0,re.kebabCase)(t.label)]||{};return{...t,frequency:Ga(o,l)}})),getSelectedCategory:e=>e.selectedCategory,hasCategories:e=>!!e.categories.length,hasLayouts:e=>!!e.layouts.length,isTemplateSelectorActive:e=>e.templateSelector}}),Oa=function(e){const t=(0,$.select)("coblocks/template-selector").getCategories();return(0,m.useMemo)((()=>t.filter((t=>(t=>!!(t=>e.filter((e=>e.category===t))||[])(t).length)(t.slug)))),[JSON.stringify(e)])};function Ra(e,t){var o;return window.requestIdleCallback?window.requestIdleCallback(e,t):setTimeout((()=>{e({didTimeout:!0,timeRemaining:()=>1})}),null!==(o=t.timeout)&&void 0!==o?o:0)}const La=(e,t,o=[])=>(0,u.createBlock)(e,t,o&&o.map((([e,t,o])=>La(e,t,o))));let Aa=null,Ia=[],Fa=[],Da=[];const{Fill:ja,Slot:Ha}=(0,i.createSlotFill)("CoBlocksLayoutSelectorFill");function Wa({children:e}){return(0,a.createElement)(ja,null,e)}(0,he.registerPlugin)("coblocks-layout-selector-control",{render:()=>(0,Gt.applyFilters)("coblocks-show-layout-selector",!0)&&(0,a.createElement)(ye,{help:(0,c.__)("Allow layout selection on new pages","coblocks"),label:(0,c.__)("Layout selector","coblocks"),settingsKey:_a,shouldDisable:(()=>{const e="undefined"!=typeof coblocksLabs?coblocksLabs:{};return!e.isGoThemeActive||!e.isGoThemeInstalled})()})});var $a=o.p+"images/layout-selector.69de142d.png";(0,he.registerPlugin)("coblocks-labs-layout-selector-control",{render:()=>(0,a.createElement)(ns,{conditionalDisable:!0,description:(0,c.__)("Get access to high-quality, professionally designed layouts when creating new pages to make page creation easier.","coblocks"),imageAlt:(0,c.__)("Layout selector example","coblocks"),imageSrc:$a,label:(0,c.__)("Layout Selector","coblocks"),settingsKey:_a,showGoHelp:!0})}),(0,$.register)(Na);const Ua=({slug:e,title:t,isSelected:o,onClick:l})=>(0,a.createElement)("li",{className:"coblocks-layout-selector__sidebar__item",key:e},(0,a.createElement)("a",{className:J()({"is-selected":o}),href:`#${e}`,onClick:e=>{e.preventDefault(),l()}},t));class qa extends m.Component{render(){const{categories:e,selectedCategory:t,updateSelectedCategory:o,isActive:l,isMobile:n,useEmptyTemplateLayout:r,useTemplateLayout:s,layouts:u}=this.props,d=(0,Gt.applyFilters)("coblocks-layout-selector-controls",[]),h=(0,a.createElement)(a.Fragment,null,(0,a.createElement)(Ha,null),Array.isArray(d)&&d.map(((e,t)=>{let o=e;return["function","object"].includes(typeof o)?((0,m.isValidElement)(o)||(o=(0,a.createElement)(o,null)),(0,a.createElement)(Wa,{key:`layout-control-${t}`},o)):null})));return l?(0,a.createElement)(i.Modal,{className:"coblocks-layout-selector-modal",onRequestClose:r,title:(0,a.createElement)(a.Fragment,null,(0,a.createElement)("div",null,(0,c.__)("Add New Page","coblocks")),(0,a.createElement)("span",null,(0,c.__)("Pick one of these layouts or start with a blank page.","coblocks")))},(0,a.createElement)("div",{className:"coblocks-layout-selector"},n&&(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar"},(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left"},(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left__settings"},h),(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left__category"},(0,a.createElement)("strong",null,(0,c.__)("Layouts","coblocks"),":")," ",e.find((e=>e.slug===t))?.title,(0,a.createElement)(i.DropdownMenu,{label:"Select a layout category"},(({onClose:t})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.MenuGroup,{onClick:t},e.map(((e,l)=>(0,a.createElement)(i.MenuItem,{key:l,onClick:()=>{o(e.slug),t()}},e.title))))))))),(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__right"},(0,a.createElement)(i.Button,{className:"coblocks-layout-selector__add-button",isLink:!0,onClick:r},(0,a.createElement)("span",null,(0,a.createElement)(i.Icon,{icon:"plus",size:16}))," ",(0,c.__)("Add blank page","coblocks")))),!n&&(0,a.createElement)("aside",{className:"coblocks-layout-selector__sidebar"},h,(0,a.createElement)("ul",{className:"coblocks-layout-selector__sidebar__items"},e.map(((e,l)=>(0,a.createElement)(Ua,{isSelected:e.slug===t,key:l,onClick:()=>o(e.slug),slug:e.slug,title:e.title})))),(0,a.createElement)(i.Button,{className:"coblocks-layout-selector__add-button",isLink:!0,onClick:r},(0,a.createElement)("span",null,(0,a.createElement)(i.SVG,{"aria-hidden":"true",focusable:"false",height:"24",role:"img",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)(i.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"}))),(0,c.__)("Add blank page","coblocks"))),(0,a.createElement)("div",{className:"coblocks-layout-selector__content"},(0,a.createElement)(xa,{category:t,layouts:u,onInsert:e=>s(e)})))):null}}"undefined"!=typeof coblocksLayoutSelector&&coblocksLayoutSelector.postTypeEnabled&&(0,he.registerPlugin)("coblocks-layout-selector",{render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const[e]=(0,ce.useEntityProp)("root","site",_a),t=!!document.getElementsByClassName("coblocks-labs-modal")?.[0],{hasLayouts:o,hasCategories:l}=(0,$.useSelect)((e=>e("coblocks/template-selector")));return e&&!t&&o()&&l()})),(0,$.withSelect)((e=>{const{getSelectedCategory:t,isTemplateSelectorActive:o}=e("coblocks/template-selector"),{isViewportMatch:l}=e("core/viewport"),n=function(){const e=(0,$.select)("coblocks/template-selector").getLayouts(),t=(0,$.select)("coblocks/template-selector").getComputedLayouts(),o=(0,$.select)("coblocks/template-selector").getSelectedCategory(),{updateComputedLayouts:l}=(0,$.useDispatch)("coblocks/template-selector"),n=e=>[o].includes(e.category)?e.blocks?e.blocks.map((e=>Array.isArray(e)?La(e[0],e[1],e[2]):e)):(0,u.rawHandler)({HTML:e.postContent})||[]:e.parsedBlocks?e.parsedBlocks:[],r=e=>({...e,parsedBlocks:n(e)}),s=e=>{for(;(e.timeRemaining()>0||e.didTimeout)&&Ia.length;)Fa.push(r(Ia.shift()));Ia.length?Ra(s,{timeout:1e3}):l(Fa)};return(0,m.useEffect)((()=>{var t;t=Aa,window.cancelIdleCallback?window.cancelIdleCallback(t):clearTimeout(t),Fa=[];const l=(0,re.orderBy)(e,["frequency"],["desc"]).slice(0,6).map((e=>({...e,category:"most-used"})));Ia=[...l,...e],Da=[o],Aa=Ra(s,{timeout:1e3})}),[JSON.stringify(e)]),(0,m.useEffect)((()=>{Da.includes(o)||(Da.push(o),l(t.map(r)))}),[o]),t}();return{categories:Oa(n),isActive:o(),isMobile:l("< medium"),layouts:n,selectedCategory:t()}})),(0,$.withDispatch)((e=>{const{closeTemplateSelector:t,incrementLayoutUsage:o,updateSelectedCategory:l}=e("coblocks/template-selector"),{editPost:n}=e("core/editor"),{createWarningNotice:r,createSuccessNotice:s}=e("core/notices");return{closeTemplateSelector:t,createSuccessNotice:s,createWarningNotice:r,editPost:n,updateSelectedCategory:l,useEmptyTemplateLayout:()=>{n({blocks:[],title:""}),t()},useTemplateLayout:e=>{n({blocks:e.blocks,title:e.label}),t(),o(e),s((0,c.sprintf)(61 (0,c.__)('"%s" set as the homepage.',"coblocks"),e.title.raw),{type:"snackbar"})}))};handleInputKeys=(e,t)=>{switch(e.key){case"Enter":e.preventDefault(),this.onCompleteRename(t);break;case"Escape":this.onResetRename(t);break;case" ":e.stopPropagation(),e.preventDefault()}};getOrderedPublishedPages=()=>{const{entities:e,homepageId:t,homepostId:o}=this.props,l=e.filter((e=>"draft"!==e.status&&e.id!==o));return l.sort(((e,o)=>e.id===t?-1:o.id===t?1:0)),l};getOrderedPublishedPosts=()=>{const{entities:e}=this.props;return[...e.filter((e=>"draft"!==e.status&&e.sticky)),...e.filter((e=>"draft"!==e.status&&!e.sticky))]};getOrderedDrafts=()=>{const{entities:e}=this.props;return e.filter((e=>"draft"===e.status)).reverse()};renderIcon=e=>{const{homepageId:t,homepageType:o}=this.props;return e.sticky?Yr:e.id===t&&"page"===o?Wr:"post"===e.type?qr:$r};renderPageTitle=e=>{const{isInRenameMode:t}=this.props;return e.id===t?this.inputRefs[e.id]?.textContent!==(0,c.__)("(no title)","coblocks")?this.inputRefs[e.id].textContent:"":e.title.raw?e.title.raw:(0,c.__)("(no title)","coblocks")};renderRow=(e,t)=>{const{currentPostId:o,homepageId:l,homepageType:n,loadPostIntoEditor:r,isInRenameMode:s}=this.props,c=this.renderPageTitle(e),u=e.id===s;return(0,a.createElement)(i.PanelRow,{className:J()("content-management__panel__row",{current:o===e.id,"is-renaming":u}),key:t},(0,a.createElement)(i.Button,{className:J()("content-management__panel__button"),isLink:!0,onClick:()=>!s&&r(e.type,e.id)},(0,a.createElement)(a.Fragment,null,this.renderIcon(e),(0,a.createElement)("span",{contentEditable:u,onKeyUp:t=>this.handleInputKeys(t,e),ref:t=>this.inputRefs[e.id]=t,role:"textbox"},c))),(0,a.createElement)(Qr,{isSticky:e.sticky,onDeletePost:()=>this.onDelete(e),onDuplicatePost:()=>this.onDuplicate(e),onPinPost:()=>this.onPin(e),onRenamePost:()=>this.onActivateRename(e,t),onSetAsHomePost:()=>this.onSetAsHome(e),postType:e.type,shouldDiplayPinAction:"post"===e.type&&"publish"===e.status,shouldDisplayHomepageAction:"page"===n&&"page"===e.type&&"publish"===e.status&&e.id!==l}),u&&(0,a.createElement)("div",{className:"content-management__panel__rename-actions"},(0,a.createElement)(i.Button,{className:"content-management__panel__rename-action content-management__panel__rename-action--confirm",onClick:()=>this.onCompleteRename(e)},(0,a.createElement)(i.Icon,{icon:ae,size:22})),(0,a.createElement)(i.Button,{className:"content-management__panel__rename-action content-management__panel__rename-action--cancel",onClick:()=>this.onResetRename(e)},(0,a.createElement)(i.Icon,{icon:Dr,size:20}))))};render(){const{props:e}=this,t="page"===e.postType.slug?this.getOrderedPublishedPages():this.getOrderedPublishedPosts(),o=this.getOrderedDrafts();return(0,a.createElement)(i.PanelBody,{className:J()("content-management__panel",{"is-renaming":e.isInRenameMode}),initialOpen:e.postType.slug===e.currentPostType,key:e.postType.slug,title:e.postType.name},t&&t.map(this.renderRow),o&&o.length>0&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h3",{className:"content-management__panel__separator"},(0,a.createElement)("span",null,(0,c.__)("Drafts","coblocks"))),o.map(this.renderRow)),(0,a.createElement)(i.Tooltip,{text:e.postType.labels.add_new_item},(0,a.createElement)(i.Button,{className:"content-management__add-new-button",onClick:()=>this.onCreateNew(e.postType)},(0,a.createElement)(i.Icon,{icon:jr,size:28}))))}}var Jr=(0,ie.compose)([(0,$.withSelect)(((e,t)=>{const{getCurrentPostId:o,getCurrentPostType:l}=e("core/editor"),{getEntityRecords:n,getEntityRecord:r,getEntity:s}=e("core"),a={};(n("postType",t.postType.slug,{per_page:-1,status:["publish","future","pending","private","draft"]})||[]).forEach((e=>a[e.id]=e));const{page_on_front:c,page_for_posts:i,show_on_front:u}=r("root","site")||{},{isInRenameMode:m}=e("coblocks/site-content");return{currentPostId:o(),currentPostType:l(),entities:Object.values(a),homepageId:c,homepageType:u,homepostId:i,isInRenameMode:m(),settingsEntity:s("root","site")}})),(0,$.withDispatch)((e=>{const{editEntityRecord:t,receiveEntityRecords:o,saveEntityRecord:l}=e("core"),{savePost:n}=e("core/editor"),{createErrorNotice:r,createSuccessNotice:s}=e("core/notices"),{cancelRenameMode:a,setRenameMode:c}=e("coblocks/site-content"),{openTemplateSelector:i}=e("coblocks/template-selector");return{cancelRenameMode:a,createErrorNotice:r,createSuccessNotice:s,editEntityRecord:t,openTemplateSelector:i,receiveEntityRecords:o,saveEntityRecord:l,savePost:n,setRenameMode:c}}))])(Kr);const es="coblocks_site_content_controls_enabled",ts="undefined"!=typeof coblocksLabs?coblocksLabs:{},os=()=>{const{isGoThemeActive:e,isGoThemeInstalled:t,goThemeDetailsUri:o,goThemeInstallUri:l}=ts;return e&&t?(0,c.__)("This feature requires the Go Theme.","coblocks"):t?(0,a.createElement)(a.Fragment,null," ",(0,c.__)("This feature requires the Go Theme - ","coblocks"),(0,a.createElement)("a",{href:o,rel:"noopener noreferrer",target:"_blank"},(0,c.__)("Activate","coblocks"))):(0,a.createElement)(a.Fragment,null," ",(0,c.__)("This feature requires the Go Theme - ","coblocks"),(0,a.createElement)("a",{href:l,rel:"noopener noreferrer",target:"_blank"},(0,c.__)("Install now","coblocks")))},ls=()=>{const{isGoThemeActive:e,isGoThemeInstalled:t}=ts;return!e||!t};var ns=function({label:e,help:t,description:o,imageSrc:l,imageAlt:n,settingsKey:r,showGoHelp:s,conditionalDisable:c=!1}){const[u,m]=(0,ce.useEntityProp)("root","site",r);return(0,a.createElement)(Xt,null,(0,a.createElement)("section",{className:"coblocks-labs-modal__section"},(0,a.createElement)("div",{className:"coblocks-labs-modal__section__vertical-group"},(0,a.createElement)("h2",{className:"coblocks-labs-modal__section__heading"},e),o&&(0,a.createElement)("p",{className:"coblocks-labs-modal__section__description"},o),(0,a.createElement)(i.ToggleControl,{checked:!!u,disabled:!!c&&ls(),help:s?os():"",onChange:m})),(0,a.createElement)("figure",null,(0,a.createElement)("img",{alt:n,src:l}))),(0,a.createElement)("hr",null))},rs=o.p+"images/site-content.da68e2d6.png";(0,he.registerPlugin)("coblocks-site-content-control",{render:()=>(0,a.createElement)(ns,{description:(0,c.__)("Quickly and easily manage your websites pages and posts from inside the editor.","coblocks"),imageAlt:(0,c.__)("Site content example","coblocks"),imageSrc:rs,label:(0,c.__)("Site Content","coblocks"),settingsKey:es})}),(0,he.registerPlugin)("coblocks-site-content",{icon:z,render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const e=window.location.pathname.includes("post-new.php"),[t]=(0,ce.useEntityProp)("root","site",es),o=!!(0,$.select)("core/editor");return e&&t&&o})),(0,$.withSelect)((e=>{const{getCurrentPostId:t,getEditedPostAttribute:o}=e("core/editor"),{getPostTypes:l}=e("core"),n=(l()||[]).filter((e=>!0===e.viewable&&["post","page"].includes(e.slug)));return{currentPageMeta:o("meta"),currentPostId:t(),postTypes:(0,re.sortBy)(n,["name"])}})),(0,$.withDispatch)((e=>{const{editPost:t}=e("core/editor");return{editPost:t}}))])((e=>{(0,m.useEffect)((()=>{const{currentPageMeta:t,editPost:o}=e;t&&"enabled"===t.hide_page_title&&wp.domReady((()=>{document.getElementsByClassName("edit-post-visual-editor__post-title-wrapper")[0]&&(document.getElementsByClassName("edit-post-visual-editor__post-title-wrapper")[0].style.display="none",o({meta:{hide_page_title:"enabled"}}))}))}),[]);const t=(e,t)=>{window.location.href=`/wp-admin/post.php?post=${t}&action=edit`},{postTypes:o}=e;return(0,a.createElement)("span",{"data-test":"site-content__container"},(0,a.createElement)(Ut.PluginSidebar,{className:"content-management",icon:(0,a.createElement)(Fr,{icon:z,label:(0,c.__)("Site content","coblocks"),slug:"site-content"}),title:(0,c.__)("Site contents","coblocks")},o.map((e=>(0,a.createElement)("span",{"data-test":"post-type-panel",key:e.slug},(0,a.createElement)(Jr,{loadPostIntoEditor:t,postType:e}))))))}))});var ss="coblocks/site-design";function as({slug:e,palette:t,isActive:o}){const l=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),n=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]),{updateColorPalette:r}=(0,$.useDispatch)(ss),s=J()("color-palette",{"is-selected":o}),c=(0,m.useCallback)((()=>{n!==e&&r(e)}),[e,n,l]);return(0,a.createElement)(i.Button,{className:s,onClick:c},Object.entries(t).reverse().map((([e,t])=>"background"!==e?(0,a.createElement)(i.ColorIndicator,{colorValue:t,key:`color-preview-${e}`}):null)))}function cs({previousPalette:e,onUpdateColors:t,onDismissCustom:o}){const l=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),n=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]);return l&&"custom"===n?(0,a.createElement)("div",{className:"color-palette-custom components-site-design__custom"},(0,a.createElement)("div",{className:"color-palette-custom__title"},(0,c.__)("Custom Colors","coblocks")),e&&(0,a.createElement)("button",{className:"components-site-design__custom__dismiss",onClick:o},(0,a.createElement)("span",null,(0,c.__)("Dismiss custom color","coblocks"))),Object.entries(l).map((([e,o])=>(0,a.createElement)(i.Dropdown,{key:`color-picker-${e}`,position:"bottom center",renderContent:()=>(0,a.createElement)(i.ColorPicker,{color:is(l,e,o),disableAlpha:!0,onChangeComplete:o=>{const l=document.getElementsByClassName(`has-${e}-background-color`);if(l.length)for(let e=0;e<l.length;e++)l[e].style.backgroundColor=o.hex;const n=document.getElementsByClassName(`has-${e}-color`);if(n.length)for(let e=0;e<n.length;e++)n[e].style.color=o.hex;t({[e]:o.hex})}}),renderToggle:({isOpen:t,onToggle:n})=>(0,a.createElement)(i.Button,{"aria-expanded":t,className:"color-palette-custom__color",isLink:!0,onClick:n},(0,a.createElement)(i.ColorIndicator,{colorValue:is(l,e,o),key:`color-${e}`}),us(e))})))):null}const is=(e,t,o)=>void 0!==Object.keys(e).shift()&&e[t]?e[t].includes("#")?e[t]:`#${e[t]}`:o,us=e=>{const t=e.toLowerCase().split(" ");for(let e=0;e<t.length;e++)t[e]=t[e].charAt(0).toUpperCase()+t[e].substring(1);return t.join(" ")};var ms=function(){const e=(0,$.useSelect)((e=>e("core/block-editor").getSettings),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),o=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),l=(0,$.useSelect)((e=>e(ss).getColorPalette()),[]),n=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),r=(0,$.useSelect)((e=>e(ss).isColorsPanelOpen()),[]),s=(0,$.useDispatch)("core/block-editor").updateSettings,{updateCustomColors:u,updateColorPalette:d,toggleColorsPanel:h}=(0,$.useDispatch)(ss),[p,f]=(0,m.useState)(null);(0,m.useEffect)((()=>{n&&(g(),Object.entries(n).forEach((([e,t])=>{document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty(`--go--color--${e}`,t)})))}),[n]);const g=(t={})=>{const o={...n,...t};"custom"===l&&f(null),s({...e(),colors:Object.entries(o).map((([e,t])=>({name:e,slug:e,color:t})))}),u({...n,...t})};return(0,a.createElement)(i.PanelBody,{className:"site-design--colors__panel",onToggle:h,opened:r,title:(0,c.__)("Colors","coblocks")},(0,a.createElement)(i.BaseControl,{className:"components-site-design-color-palettes"},(0,a.createElement)(cs,{onDismissCustom:()=>d(p),onUpdateColors:g,previousPalette:p}),(0,a.createElement)("div",{className:"color-palettes"},(0,a.createElement)("div",{className:"color-palettes__title"},(0,a.createElement)("span",null,(0,c.__)("Color Palettes","coblocks")),"custom"!==l&&(0,a.createElement)("button",{className:"color-palettes__custom-button",onClick:()=>{f(l),d("custom"),g()}},(0,c.__)("Custom","coblocks"))),(0,a.createElement)("div",{className:"color-palettes__palettes"},t&&t.palettes.map((([e,t])=>(0,a.createElement)(as,{isActive:l.replace(`${o}-`,"")===e,key:`palette-${e}`,palette:t,slug:e})))))))},ds=function(){const e=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyles()),[]),o=(0,$.useSelect)((e=>e(ss).isDesignsPanelOpen()),[]),l=(0,$.useSelect)((e=>e(ss).getCurrentColors()),[]),n=(0,$.useSelect)((e=>e(ss).isUpdating()),[]),r=t?.find((t=>t.slug===e)),{updateDesign:s,toggleDesignsPanel:u}=(0,$.useDispatch)(ss),m=(e,t)=>{const o=[e.tertiary,e.secondary,e.primary];return(0,a.createElement)("div",{className:"components-site-design-designs__design__colors"},o.map(((e,o)=>(0,a.createElement)("li",{className:"components-site-design-designs__design__color",key:`components-site-design-designs__design__color-${t}-${o}`,style:{backgroundColor:e}}))))};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.PanelBody,{className:"site-design--designs__panel components-site-design-designs",onToggle:u,opened:o,title:(0,c.__)("Design Styles","coblocks")},(0,a.createElement)("p",null,(0,c.__)("Easily explore curated design styles, then customize your colors and fonts to get the perfect fit.","coblocks")),(0,a.createElement)(Ir,null,t&&t.map(((t,o)=>(0,a.createElement)("button",{className:J()("components-site-design-designs__design",{"components-site-design-designs__design--selected":t.slug===e,"components-site-design-designs__design--updating":n}),"data-test":`design-button-${t.slug}`,key:`design-button-${t.slug}`,onClick:()=>(t=>{t!==e&&s({designStyle:t})})(t.slug)},(0,a.createElement)("div",{className:"components-site-design-designs__design__content"},(0,a.createElement)("div",{className:"components-site-design-designs__design__label",style:{fontFamily:Object.entries(t.fonts)[0][0]}},t.label),m(t.slug!==e||n?t.palettes[0][1]:l,o))))))),!o&&!!r&&(0,a.createElement)("div",{className:"components-site-design-design components-panel__body is-opened"},(0,a.createElement)("button",{className:"components-site-design-designs__design components-site-design-designs__design--current",onClick:u},(0,a.createElement)("div",{className:"components-site-design-designs__design__content"},(0,a.createElement)("div",{className:"components-site-design-designs__design__label",style:{fontFamily:Object.entries(r.fonts)[0][0]}},r.label),m(l,9999)))))},hs=function(){const e=(0,$.useSelect)((e=>e(ss).getFontSize()),[]),t=Number(e?.replace("rem","")),o=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),l=Number(o?.font_size?.replace("rem",""));return(0,m.useEffect)((()=>{t&&document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty("--go--font-size",`${t}rem`)}),[t]),[t,l]},ps=function(){const e=(0,$.useSelect)((e=>e(ss).getTypeRatio()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyleObj()),[]),o=t?.type_ratio;return(0,m.useEffect)((()=>{e&&document.getElementsByClassName(siteDesign.editorClass)[0].style.setProperty("--go--type-ratio",e)}),[e]),[e,o]};const fs="custom";var gs=function e(){const[t,o]=hs(),[l,n]=ps(),{updateFontSize:r,updateTypeRatio:s}=(0,$.useDispatch)(ss),u=(0,ie.useInstanceId)(e),d=(0,m.useMemo)((()=>function(e){return e?[{key:"small",name:(0,c.__)("Small","coblocks"),style:{fontSize:`${(.8*e).toFixed(2)}rem`}},{key:"normal",name:(0,c.__)("Normal","coblocks"),style:{fontSize:`${e.toFixed(2)}rem`}},{key:"large",name:(0,c.__)("Large","coblocks"),style:{fontSize:`${(1.3*e).toFixed(2)}rem`}},{key:fs,name:(0,c.__)("Custom")}]:[]}(o)),[o]),h=(0,m.useMemo)((()=>function(e,t){if(t){const o=e.find((e=>e.style?.fontSize===`${t.toFixed(2)}rem`));return o?o.key:fs}return"normal"}(d,t)),[d,t]),p=(0,m.useCallback)((({selectedItem:e})=>{const t=e?.style?.fontSize;t&&r(t)}));if(!d)return null;const f=`components-font-size-picker__number#${u}`;return(0,a.createElement)("fieldset",{className:"components-font-size-picker"},(0,a.createElement)(i.VisuallyHidden,{as:"legend"},(0,c.__)("Base size","coblocks")),(0,a.createElement)("div",{className:"components-font-size-picker__controls"},t&&(0,a.createElement)(i.CustomSelectControl,{className:"components-font-size-picker__select",label:(0,c.__)("Font size","coblocks"),onChange:p,options:d,value:d.find((e=>e.key===h))}),(0,a.createElement)("div",{className:"components-font-size-picker__number-container"},(0,a.createElement)("input",{"aria-label":(0,c.__)("Custom"),className:"components-font-size-picker__number",id:f,max:5,min:0,onChange:e=>{r(`${e.target.value}rem`)},step:.01,type:"number",value:t||""}))),(0,a.createElement)("div",{className:"components-font-size-picker__heading-container"},(0,a.createElement)(i.RangeControl,{className:"components-font-size-picker__heading-scale",initialPosition:l,label:(0,c.__)("Heading Scale","coblocks"),max:1.15*n,min:.9*n,onChange:s,showTooltip:!1,step:.01,value:l||"",withInputField:!1})))},vs=function(){const e=(0,$.useSelect)((e=>e(ss).getFonts()),[]),t=(0,$.useSelect)((e=>e(ss).getSelectedFonts()),[]);return(0,m.useEffect)((()=>{if(!t)return;const[e,o]=t[0],[l,n]=t[1],r=document.getElementsByClassName(siteDesign.editorClass)[0];r&&(r.style.setProperty("--go-heading--font-family",e),r.style.setProperty("--go-heading--font-weight",o[0]),r.style.setProperty("--go--font-family",l),r.style.setProperty("--go--font-weight",n[0]))}),[t]),[e,t]},ws=function(e){const[t,o]=hs(),[l,n]=ps(),[r,s]=vs(),{updateFontSize:u,updateTypeRatio:d,updateSelectedFonts:h}=(0,$.useDispatch)(ss),p=(0,m.useMemo)((()=>(e=>e.flat().sort().filter(((e,t,o)=>o.findIndex((t=>t[0]===e[0]))===t)).map((e=>({key:e[0],name:e[0],style:{fontFamily:e[0]},weights:e[1],weightsOptions:e[1].map((t=>({key:t,name:t,style:{fontWeight:t,fontFamily:e[0]}})))}))))(r)),[r]),[f,g]=s[0],[v,w]=s[1],y=p.find((e=>e.key===f)),b=y.weightsOptions.find((e=>e.key===g[0])),E=p.find((e=>e.key===v)),k=E.weightsOptions.find((e=>e.key===w[0])),{onClose:_}=e;return(0,a.createElement)("div",{className:"components-site-design__custom"},(0,a.createElement)("strong",null,(0,c.__)("Custom Font Options","coblocks")),(0,a.createElement)("button",{className:"components-site-design__custom__dismiss",onClick:_},(0,a.createElement)("span",null,"Dismiss custom color")),(0,a.createElement)("fieldset",{className:"components-site-design__custom__body"},(0,a.createElement)("strong",null,(0,c.__)("HEADING","coblocks")),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Font","coblocks"),onChange:({selectedItem:e})=>h([[e.key,e.weights],s[1]]),options:p,value:y}),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Weight","coblocks"),onChange:({selectedItem:e})=>h([[f,[e.key]],s[1]]),options:y.weightsOptions,value:b}),(0,a.createElement)(i.RangeControl,{initialPosition:l,label:(0,c.__)("Size","coblocks"),max:1.15*n,min:.9*n,onChange:d,showTooltip:!1,step:.01,value:l||"",withInputField:!1})),(0,a.createElement)("hr",{className:"components-site-design-fonts__advanced__separator"}),(0,a.createElement)("fieldset",{className:"components-site-design-fonts__advanced__heading"},(0,a.createElement)(i.VisuallyHidden,{as:"legend"},(0,c.__)("Heading font size","coblocks")),(0,a.createElement)("strong",null,(0,c.__)("BODY","coblocks")),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Font","coblocks"),onChange:({selectedItem:e})=>h([s[0],[e.key,e.weights]]),options:p,style:{fontFamily:E.key},value:E}),(0,a.createElement)(i.CustomSelectControl,{label:(0,c.__)("Weight","coblocks"),onChange:({selectedItem:e})=>h([s[0],[v,[e.key]]]),options:E.weightsOptions,value:k}),(0,a.createElement)(i.RangeControl,{initialPosition:0,label:(0,c.__)("Size","coblocks"),max:(2*o).toFixed(2),min:(.8*o).toFixed(2),onChange:e=>u(`${e}rem`),showTooltip:!1,step:.01,value:t,withInputField:!1})))},ys=window.wp.dataControls;const bs="TOGGLE_COLORS_PANEL",Es="TOGGLE_DESIGNS_PANEL",ks="TOGGLE_FONTS_PANEL",_s="TOGGLE_IS_UPDATING",xs="UPDATE_COLOR_PALETTE",Cs="UPDATE_CUSTOM_COLORS",zs="UPDATE_DESIGN",Ss="UPDATE_DESIGN_STYLE",Ps="UPDATE_FONT_SIZE",Bs="UPDATE_REF_STATE",Vs="UPDATE_SELECTED_FONTS",Ms="UPDATE_TYPE_RATIO",{resolveSelect:Gs}=$.controls;function*Ts({designStyle:e="none",saveChanges:t=!1,initialLoad:o=!1}){const l=yield Gs(ss,"getColorPalette");let{colorPalette:n=("custom"===l?"custom":"one"),customColors:r=("custom"===l?yield Gs(ss,"getCurrentColors"):null),fonts:s=!1,fontSize:a=!1,typeRatio:c=!1}={};t&&(e=yield Gs(ss,"getDesignStyle"),n=yield Gs(ss,"getColorPalette"),r=yield Gs(ss,"getCurrentColors"),s=yield Gs(ss,"getSelectedFonts"),s=(0,re.cloneDeep)(s),siteDesign.isAdvancedFontsEnabled&&(s[0][0]=`${s[0][0]}_heading`,s[1][0]=`${s[1][0]}_body`),s=JSON.stringify(Object.fromEntries(s)),a=yield Gs(ss,"getFontSize"),c=yield Gs(ss,"getTypeRatio"));const i=new FormData;let u;i.append("action","site_design_update_design_style"),i.append("nonce",coblocksBlockData.labsSiteDesignNonce),i.append("design_style",e),i.append("color_palette",n),i.append("fonts",s),i.append("font_size",a),i.append("type_ratio",c),i.append("should_update",t),i.append("initial_load",o),r&&Object.keys(r).forEach((e=>i.append(`${e}_color`,r[e]))),o||(yield Hs()),yield Ns(e);try{u=yield(0,ys.apiFetch)({body:i,method:"POST",path:`${coblocksBlockData.baseApiNamespace}/${siteDesign.apiRoute}`})}catch(e){return void console.log("Error updating design",e)}if(u&&(yield{newState:{designResp:u},type:zs},!o)){if(yield Os(n),!1===s){const e=yield Gs(ss,"getDesignStyleObj");yield Is(Object.entries(e.fonts)),yield Ls(e.font_size),yield As(e.type_ratio)}yield Hs(),t&&(yield Ws())}}const Ns=e=>({newState:{designStyle:e},type:Ss});function*Os(e){const t=yield Gs(ss,"getDesignStyleObj"),o=Object.fromEntries(t.palettes)[e];if("custom"!==e&&(yield Rs(o)),null==o||!Object.entries(o).length)return{newState:{colorPalette:e},type:xs};for(const[e,t]of Object.entries(o)){const o=document.getElementsByClassName(`has-${e}-background-color`);if(o.length)for(let e=0;e<o.length;e++)o[e].style.backgroundColor=t;const l=document.getElementsByClassName(`has-${e}-color`);if(l.length)for(let e=0;e<l.length;e++)l[e].style.color=t}return{newState:{colorPalette:e},type:xs}}const Rs=e=>({newState:{currentColors:e},type:Cs}),Ls=e=>({newState:{fontSize:e},type:Ps}),As=e=>({newState:{typeRatio:e},type:Ms}),Is=e=>({newState:{selectedFonts:e},type:Vs}),Fs=()=>({stateProp:"fontsPanelOpen",type:ks}),Ds=()=>({stateProp:"colorsPanelOpen",type:bs}),js=()=>({stateProp:"designsPanelOpen",type:Es}),Hs=()=>({stateProp:"isUpdating",type:_s}),Ws=()=>({type:Bs}),{resolveSelect:$s}=$.controls;function*Us(){const e=yield $s(ss,"getDesignStyle"),t=yield $s(ss,"getColorPalette"),o=yield $s(ss,"getCurrentColors");yield Ts({designStyle:e,colorPalette:t,customColors:o,initialLoad:!0})}function qs(e,t){if(!e)return-1;const o=e.map((e=>e[0]));return t.map((e=>[e[0][0],e[1][0]])).findIndex((e=>0===(0,re.difference)(e,o).length))}function Zs({selected:e}){const[t,o]=(0,m.useState)(!1);return(0,m.useEffect)((()=>{-1===e&&o(!0)}),[e]),siteDesign.isAdvancedFontsEnabled?(0,a.createElement)(a.Fragment,null,t&&(0,a.createElement)(ws,{onClose:()=>o(!1)}),!t&&(0,a.createElement)("button",{className:J()("components-site-design-fonts__heading__custom",{"components-site-design-fonts__heading__custom--open":t}),onClick:()=>o((e=>!e))},(0,c.__)("Custom","coblocks"))):null}function Ys({font:e,isSelected:t}){const{updateSelectedFonts:o}=(0,$.useDispatch)(ss),[l,n]=(0,m.useState)(!1),r=(0,m.useCallback)((()=>{o(e),n(!1)}),[e,n]),s=t?"div":"button",u={};return"button"===s&&(u.onClick=r),(0,a.createElement)("li",{className:J()("components-site-design-fonts__option",{"is-selected":t})},(0,a.createElement)(s,{...u,className:"components-site-design-fonts__option__section"},(0,a.createElement)("p",{className:"components-site-design-fonts__option__primary",style:{fontFamily:e[0][0]}},e[0][0]),(0,a.createElement)("p",{className:"components-site-design-fonts__option__secondary",style:{fontFamily:e[1][0]}},(0,c.__)("The quick brown fox jumped over the lazy dog.","coblocks")),t&&(0,a.createElement)("button",{className:"components-site-design-fonts__option__edit",onClick:()=>n((e=>!e))},(0,a.createElement)("span",{className:"icon"},(0,a.createElement)(i.Icon,{icon:S})),l?(0,c.__)("Hide font sizes","coblocks"):(0,c.__)("Edit font sizes","coblocks"))),t&&l&&(0,a.createElement)("div",{className:"components-site-design-fonts__option__settings components-site-design-fonts__option__section"},(0,a.createElement)(gs,null)))}var Qs=function e(){const t=`font-preview-${(0,ie.useInstanceId)(e)}`,[o,l]=vs(),n=(0,$.useSelect)((e=>e(ss).isFontsPanelOpen()),[]),{toggleFontsPanel:r}=(0,$.useDispatch)(ss);if(!o)return null;const s=qs(l,o);return(0,a.createElement)(i.PanelBody,{className:"components-site-design components-site-design-fonts site-design--fonts__panel",onToggle:r,opened:n,title:(0,c.__)("Fonts","coblocks")},(0,a.createElement)("div",{className:"components-site-design-fonts__heading"},(0,a.createElement)(Zs,{selected:s}),(0,a.createElement)("p",null,(0,c.__)("Font Pairings","coblocks"))),(0,a.createElement)("ul",{className:"components-site-design-fonts__options"},o.map(((e,o)=>(0,a.createElement)(Ys,{font:e,isSelected:o===s,key:`${t}-${o}`})))))};const Xs=(e,t)=>Object.keys(t).some((o=>!(0,re.isEqual)(e[o],t[o])));const Ks=e=>e.designResp,Js=e=>e.designStyle,ea=e=>e.designStyles,ta=e=>e.designStyles?.find((t=>t.slug===e.designStyle)),oa=e=>e.colorPalette,la=e=>e.currentColors,na=e=>e.fontSize,ra=e=>e.typeRatio,sa=e=>e.fonts,aa=e=>e.showSaveBtn,ca=e=>e.selectedFonts,ia=e=>e.fontsPanelOpen,ua=e=>e.colorsPanelOpen,ma=e=>e.designsPanelOpen,da=e=>e.isUpdating;(0,$.registerStore)(ss,{reducer:(e={},t)=>{switch((0,$.use)($.plugins.persistence,e),(0,re.isEmpty)(e)&&(e=(()=>{if("undefined"==typeof siteDesign||(0,re.isEmpty)(siteDesign))return{};const e=e=>Object.entries(e).map((e=>(e[0]=e[0].replace(/_(heading|body)/,""),e))),t=siteDesign?.fonts?.map((t=>e(t))),o=Object.entries(siteDesign?.availableDesignStyles).map((([,e])=>({...e,palettes:Object.entries(e.color_schemes).map((([e,t])=>[e,Object.fromEntries(["primary","secondary","tertiary","background"].map((e=>[e,t[e]])))]))}))),l={colorPalette:siteDesign.currentColorScheme,colorsPanelOpen:!0,currentColors:Object.fromEntries(Object.entries(siteDesign.currentColors).filter((e=>e[1]))),designStyle:siteDesign.currentDesignStyle,designStyles:o,designsPanelOpen:!0,fontSize:siteDesign?.fontSize,fonts:t,fontsPanelOpen:!0,isUpdating:!1,selectedFonts:(()=>{const t=siteDesign?.currentFonts;return t?e(t):null})(),showSaveBtn:!1,typeRatio:siteDesign?.typeRatio};return l.refState={...l},l})()),t.type){case zs:return{...e,...t.newState};case Ss:case xs:case Vs:case Cs:case Ps:case Ms:return{...e,...t.newState,showSaveBtn:Xs(e.refState,{colorPalette:e.colorPalette,currentColors:e.currentColors,designStyle:e.designStyle,fontSize:e.fontSize,selectedFonts:e.selectedFonts,typeRatio:e.typeRatio,...t.newState})};case ks:case bs:case Es:case _s:return{...e,[t.stateProp]:!e[t.stateProp]};case Bs:const o={...e};return delete o.refState,{...e,refState:o,showSaveBtn:!1};default:return e}},actions:l,selectors:r,controls:ys.controls,resolvers:n,persist:["fontsPanelOpen","colorsPanelOpen","designsPanelOpen"]});const ha="coblocks_site_design_controls_enabled";var pa=o.p+"images/site-design.0ce62606.png";(0,he.registerPlugin)("coblocks-site-design-control",{render:()=>(0,a.createElement)(ns,{conditionalDisable:!0,description:(0,c.__)("Easily explore curated design styles, then customize your colors and fonts inside the editor to get the perfect fit.","coblocks"),imageAlt:(0,c.__)("Site design example","coblocks"),imageSrc:pa,label:(0,c.__)("Site Design","coblocks"),settingsKey:ha,showGoHelp:!0})});const fa=C?.outlined;let ga=!1,va=!1;const wa="_coblocks_non_existing_meta",ya=(0,c.__)("Site design","coblocks");function ba(){const e=(0,$.useSelect)((e=>e(ss).isUpdating()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignResp()),[]);return vs(),hs(),ps(),(0,m.useEffect)((()=>{if(!t||e)return;const o=document.getElementById("site-design-styles");if(ga=ga||t.fontStyles,o.innerHTML=[t.stylesheet,ga].join(" "),!o.closest("div.is-desktop-preview")){var l;const e=null!==(l=document.querySelectorAll(".is-desktop-preview style:last-of-type")?.[0])&&void 0!==l?l:document.querySelectorAll(".is-desktop-preview div")?.[0];e&&e?.after?.(o)}}),[e,t]),(0,m.useEffect)((()=>{const t=document.getElementsByClassName("interface-interface-skeleton__content");t.length>0&&t[0].classList.toggle("site-design-updating",e)}),[e]),null}function Ea(){const e=(0,$.useSelect)((e=>e(ss).showSaveBtn()),[]),t=(0,$.useSelect)((e=>e(ss).getDesignStyle()),[]),{updateDesign:o}=(0,$.useDispatch)(ss),l=()=>o({saveChanges:!0}),n=(0,$.useSelect)((e=>e("core/editor").getCurrentPostType()),[]),r=(0,$.useSelect)((e=>e("core/editor").getCurrentPostId()),[]),{editEntityRecord:s}=(0,$.useDispatch)("core"),[c]=(0,ce.useEntityProp)("postType",n,"meta");return(0,m.useEffect)((()=>{if(e){if(va=document.getElementsByClassName("editor-post-publish-button")[0]||!1,va)return s("postType",n,r,{meta:{...c,[wa]:!0}},{undoIgnore:!0}),va.addEventListener("click",l),function(){va&&va.removeEventListener("click",l)}}else va&&(delete c[wa],s("postType",n,r,{meta:{...c}},{undoIgnore:!0}),va.removeEventListener("click",l),va=!1)}),[e]),t?(0,a.createElement)(a.Fragment,null,(0,a.createElement)(ds,null),(0,a.createElement)(ms,null),(0,a.createElement)(Qs,null)):null}const ka=C?.outlined;(0,he.registerPlugin)("coblocks-site-design",{icon:ka,render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const[e]=(0,ce.useEntityProp)("root","site",ha);return e}))])((()=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(Ut.PluginSidebar,{icon:(0,a.createElement)(Fr,{icon:fa,label:(0,c.__)("Site design","coblocks"),slug:"site-design"}),title:ya},(0,a.createElement)(Ea,null)),(0,a.createElement)(ba,null))))});const _a="coblocks_layout_selector_controls_enabled",xa=({layouts:e,category:t,onInsert:o})=>{const l=(0,$.useSelect)((e=>e("core").getEntityRecord),[]),n=l("root","site")?.image_category||"",r=(0,m.useMemo)((()=>e.filter((e=>e.category===t&&!!e.parsedBlocks?.length)).map((e=>({...e,blocks:(0,Gt.applyFilters)("coblocks.layoutPreviewBlocks",e.parsedBlocks)})))),[JSON.stringify(e),t,n]),s=(0,ie.useAsyncList)(r);return t&&r.length?(0,a.createElement)("div",{className:"coblocks-layout-selector__layouts"},(0,a.createElement)(Pa,{layouts:r,onClickLayout:o,shownLayouts:s})):(0,a.createElement)("p",null,(0,a.createElement)("em",null,(0,c.__)("No layouts are available for this category.","coblocks")))},Ca=({layout:e,onClick:t})=>{const o=za(e.blocks);return(0,a.createElement)(i.Button,{className:J()("coblocks-layout-selector__layout"),"data-testid":"coblocks-layout-selector__layout-button",onClick:()=>t(e)},(0,a.createElement)(i.Spinner,null),(0,a.createElement)("div",{className:"coblocks-layout-selector__layout-preview-container"},(0,a.createElement)(U.BlockPreview,{blocks:o,viewportWidth:700})))},za=e=>e.map((e=>(e?.attributes?.animation&&(e.attributes.animation=""),e?.innerBlocks?.length>0&&(e.innerBlocks=za(e.innerBlocks)),e))),Sa=()=>(0,a.createElement)("div",{className:"coblocks-layout-selector__layout is-placeholder","data-testid":"coblocks-layout-selector__layout-placeholder"},(0,a.createElement)(i.Spinner,null)),Pa=({layouts:e,shownLayouts:t,onClickLayout:o})=>e.map(((e,l)=>t.includes(e)?(0,a.createElement)(Ca,{key:l,layout:e,onClick:o}):(0,a.createElement)(Sa,{key:l})));var Ba=o(9588),Va=o.n(Ba);const Ma={categories:coblocksLayoutSelector.categories||[],computedLayouts:[],layoutUsage:{},layouts:coblocksLayoutSelector.layouts||[],selectedCategory:"most-used",templateSelector:!1},Ga=Va()(((e,t)=>{if(!e)return t;const o=Date.now()-e;switch(!0){case o<36e5:return 4*t;case o<864e5:return 2*t;case o<6048e5:return t/2;default:return t/4}})),Ta={closeTemplateSelector:()=>({type:"CLOSE_TEMPLATE_SELECTOR"}),incrementLayoutUsage:e=>({layout:e,time:Date.now(),type:"INCREMENT_LAYOUT_USAGE"}),openTemplateSelector:()=>({type:"OPEN_TEMPLATE_SELECTOR"}),updateCategories:e=>({categories:e,type:"UPDATE_CATEGORIES"}),updateComputedLayouts:e=>({computedLayouts:e,type:"UPDATE_COMPUTED_LAYOUTS"}),updateLayouts:e=>({layouts:e,type:"UPDATE_LAYOUTS"}),updateSelectedCategory:e=>({selectedCategory:e,type:"UPDATE_CATEGORY"})};var Na=(0,$.createReduxStore)("coblocks/template-selector",{actions:Ta,controls:ys.controls,persist:["layoutUsage"],reducer(e=Ma,t){switch(t.type){case"OPEN_TEMPLATE_SELECTOR":return{...e,templateSelector:!0};case"CLOSE_TEMPLATE_SELECTOR":return{...e,templateSelector:!1};case"UPDATE_LAYOUTS":return{...e,layouts:t.layouts};case"UPDATE_COMPUTED_LAYOUTS":return{...e,computedLayouts:t.computedLayouts};case"UPDATE_CATEGORIES":return{...e,categories:t.categories};case"UPDATE_CATEGORY":return{...e,selectedCategory:t.selectedCategory};case"INCREMENT_LAYOUT_USAGE":const o=(0,re.kebabCase)(t.layout.label);return{...e,layoutUsage:{...e.layoutUsage,[o]:{count:e.layoutUsage[o]?e.layoutUsage[o].count+1:1,time:t.time}}}}return e},resolvers:{*isTemplateSelectorActive(){const e=(0,$.select)("core/editor").isCleanNewPost(),t=(0,$.select)("core/editor").isEditedPostEmpty();return(e||t)&&Ta.openTemplateSelector()}},selectors:{getCategories:e=>e.categories||[],getComputedLayouts:e=>e.computedLayouts,getLayoutUsage:e=>e.layoutUsage,getLayouts:e=>(e.layouts||[]).map((t=>{const{time:o,count:l=0}=e.layoutUsage[(0,re.kebabCase)(t.label)]||{};return{...t,frequency:Ga(o,l)}})),getSelectedCategory:e=>e.selectedCategory,hasCategories:e=>!!e.categories.length,hasLayouts:e=>!!e.layouts.length,isTemplateSelectorActive:e=>e.templateSelector}}),Oa=function(e){const t=(0,$.select)("coblocks/template-selector").getCategories();return(0,m.useMemo)((()=>t.filter((t=>(t=>!!(t=>e.filter((e=>e.category===t))||[])(t).length)(t.slug)))),[JSON.stringify(e)])};function Ra(e,t){var o;return window.requestIdleCallback?window.requestIdleCallback(e,t):setTimeout((()=>{e({didTimeout:!0,timeRemaining:()=>1})}),null!==(o=t.timeout)&&void 0!==o?o:0)}const La=(e,t,o=[])=>(0,u.createBlock)(e,t,o&&o.map((([e,t,o])=>La(e,t,o))));let Aa=null,Ia=[],Fa=[],Da=[];const{Fill:ja,Slot:Ha}=(0,i.createSlotFill)("CoBlocksLayoutSelectorFill");function Wa({children:e}){return(0,a.createElement)(ja,null,e)}(0,he.registerPlugin)("coblocks-layout-selector-control",{render:()=>(0,Gt.applyFilters)("coblocks-show-layout-selector",!0)&&(0,a.createElement)(ye,{help:(0,c.__)("Allow layout selection on new pages","coblocks"),label:(0,c.__)("Layout selector","coblocks"),settingsKey:_a,shouldDisable:(()=>{const e="undefined"!=typeof coblocksLabs?coblocksLabs:{};return!e.isGoThemeActive||!e.isGoThemeInstalled})()})});var $a=o.p+"images/layout-selector.69de142d.png";(0,he.registerPlugin)("coblocks-labs-layout-selector-control",{render:()=>(0,a.createElement)(ns,{conditionalDisable:!0,description:(0,c.__)("Get access to high-quality, professionally designed layouts when creating new pages to make page creation easier.","coblocks"),imageAlt:(0,c.__)("Layout selector example","coblocks"),imageSrc:$a,label:(0,c.__)("Layout Selector","coblocks"),settingsKey:_a,showGoHelp:!0})}),(0,$.register)(Na);const Ua=({slug:e,title:t,isSelected:o,onClick:l})=>(0,a.createElement)("li",{className:"coblocks-layout-selector__sidebar__item",key:e},(0,a.createElement)("a",{className:J()({"is-selected":o}),href:`#${e}`,onClick:e=>{e.preventDefault(),l()}},t));class qa extends m.Component{render(){const{categories:e,selectedCategory:t,updateSelectedCategory:o,isActive:l,isMobile:n,useEmptyTemplateLayout:r,useTemplateLayout:s,layouts:u}=this.props,d=(0,Gt.applyFilters)("coblocks-layout-selector-controls",[]),h=(0,a.createElement)(a.Fragment,null,(0,a.createElement)(Ha,null),Array.isArray(d)&&d.map(((e,t)=>{let o=e;return["function","object"].includes(typeof o)?((0,m.isValidElement)(o)||(o=(0,a.createElement)(o,null)),(0,a.createElement)(Wa,{key:`layout-control-${t}`},o)):null})));return l?(0,a.createElement)(i.Modal,{className:"coblocks-layout-selector-modal",onRequestClose:r,title:(0,a.createElement)(a.Fragment,null,(0,a.createElement)("div",null,(0,c.__)("Add New Page","coblocks")),(0,a.createElement)("span",null,(0,c.__)("Pick one of these layouts or start with a blank page.","coblocks")))},(0,a.createElement)("div",{className:"coblocks-layout-selector"},n&&(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar"},(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left"},(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left__settings"},h),(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__left__category"},(0,a.createElement)("strong",null,(0,c.__)("Layouts","coblocks"),":")," ",e.find((e=>e.slug===t))?.title,(0,a.createElement)(i.DropdownMenu,{label:"Select a layout category"},(({onClose:t})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.MenuGroup,{onClick:t},e.map(((e,l)=>(0,a.createElement)(i.MenuItem,{key:l,onClick:()=>{o(e.slug),t()}},e.title))))))))),(0,a.createElement)("div",{className:"coblocks-layout-selector__topbar__right"},(0,a.createElement)(i.Button,{className:"coblocks-layout-selector__add-button",isLink:!0,onClick:r},(0,a.createElement)("span",null,(0,a.createElement)(i.Icon,{icon:"plus",size:16}))," ",(0,c.__)("Add blank page","coblocks")))),!n&&(0,a.createElement)("aside",{className:"coblocks-layout-selector__sidebar"},h,(0,a.createElement)("ul",{className:"coblocks-layout-selector__sidebar__items"},e.map(((e,l)=>(0,a.createElement)(Ua,{isSelected:e.slug===t,key:l,onClick:()=>o(e.slug),slug:e.slug,title:e.title})))),(0,a.createElement)(i.Button,{className:"coblocks-layout-selector__add-button",isLink:!0,onClick:r},(0,a.createElement)("span",null,(0,a.createElement)(i.SVG,{"aria-hidden":"true",focusable:"false",height:"24",role:"img",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)(i.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"}))),(0,c.__)("Add blank page","coblocks"))),(0,a.createElement)("div",{className:"coblocks-layout-selector__content"},(0,a.createElement)(xa,{category:t,layouts:u,onInsert:e=>s(e)})))):null}}"undefined"!=typeof coblocksLayoutSelector&&coblocksLayoutSelector.postTypeEnabled&&(0,he.registerPlugin)("coblocks-layout-selector",{render:(0,ie.compose)([(0,ie.ifCondition)((()=>{const[e]=(0,ce.useEntityProp)("root","site",_a),t=!!document.getElementsByClassName("coblocks-labs-modal")?.[0],{hasLayouts:o,hasCategories:l}=(0,$.useSelect)((e=>e("coblocks/template-selector")));return e&&!t&&o()&&l()})),(0,$.withSelect)((e=>{const{getSelectedCategory:t,isTemplateSelectorActive:o}=e("coblocks/template-selector"),{isViewportMatch:l}=e("core/viewport"),n=function(){const e=(0,$.select)("coblocks/template-selector").getLayouts(),t=(0,$.select)("coblocks/template-selector").getComputedLayouts(),o=(0,$.select)("coblocks/template-selector").getSelectedCategory(),{updateComputedLayouts:l}=(0,$.useDispatch)("coblocks/template-selector"),n=e=>[o].includes(e.category)?e.blocks?e.blocks.map((e=>Array.isArray(e)?La(e[0],e[1],e[2]):e)):(0,u.rawHandler)({HTML:e.postContent})||[]:e.parsedBlocks?e.parsedBlocks:[],r=e=>({...e,parsedBlocks:n(e)}),s=e=>{for(;(e.timeRemaining()>0||e.didTimeout)&&Ia.length;)Fa.push(r(Ia.shift()));Ia.length?Ra(s,{timeout:1e3}):l(Fa)};return(0,m.useEffect)((()=>{var t;t=Aa,window.cancelIdleCallback?window.cancelIdleCallback(t):clearTimeout(t),Fa=[];const l=(0,re.orderBy)(e,["frequency"],["desc"]).slice(0,6).map((e=>({...e,category:"most-used"})));Ia=[...l,...e],Da=[o],Aa=Ra(s,{timeout:1e3})}),[JSON.stringify(e)]),(0,m.useEffect)((()=>{Da.includes(o)||(Da.push(o),l(t.map(r)))}),[o]),t}();return{categories:Oa(n),isActive:o(),isMobile:l("< medium"),layouts:n,selectedCategory:t()}})),(0,$.withDispatch)((e=>{const{closeTemplateSelector:t,incrementLayoutUsage:o,updateSelectedCategory:l}=e("coblocks/template-selector"),{editPost:n}=e("core/editor"),{createWarningNotice:r,createSuccessNotice:s}=e("core/notices");return{closeTemplateSelector:t,createSuccessNotice:s,createWarningNotice:r,editPost:n,updateSelectedCategory:l,useEmptyTemplateLayout:()=>{n({blocks:[],title:""}),t()},useTemplateLayout:e=>{n({blocks:e.blocks,title:e.label}),t(),o(e),s((0,c.sprintf)( 62 62 // translators: %s is the post title. 63 63 (0,c.__)('"%s" layout has been added to the page.',"coblocks"),e.label),{type:"snackbar"})}}}))])(qa)});const Za={};Za.uppercase=(0,a.createElement)(i.SVG,{height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)(i.Path,{d:"m0 0v2.5h4.16666667v10.5h2.5v-10.5h4.16666663v-2.5zm16 4.5h-7.5v2.5h2.5v6h2.5v-6h2.5z",transform:"translate(2 3)"}));var Ya=Za,Qa=window.wp.richText;const Xa="coblocks/uppercase",Ka={title:(0,c.__)("Uppercase","coblocks"),tagName:"span",className:"uppercase",edit:({isActive:e,value:t,onChange:o})=>{const l=()=>o((0,Qa.toggleFormat)(t,{type:Xa}));return(0,a.createElement)(m.Fragment,null,(0,a.createElement)(U.RichTextShortcut,{type:"access",character:"u",onUse:l}),(0,a.createElement)(U.RichTextToolbarButton,{icon:Ya.uppercase,title:(0,c.__)("Uppercase","coblocks"),onClick:l,isActive:e,shortcutType:"access",shortcutCharacter:"u"}))}};[s].forEach((({name:e,settings:t})=>{(0,Qa.registerFormatType)(e,t)})),[{label:(0,c.__)("Info","coblocks"),name:"info"},{label:(0,c.__)("Success","coblocks"),name:"success"},{label:(0,c.__)("Warning","coblocks"),name:"warning"},{label:(0,c.__)("error","coblocks"),name:"error"}].forEach((e=>(0,u.registerBlockStyle)("core/paragraph",e))),(0,u.registerBlockStyle)("core/image",{name:"default", -
coblocks/trunk/readme.txt
r3062838 r3079624 6 6 Tested up to: 6.5 7 7 Requires PHP: 7.4 8 Stable tag: 3.1. 88 Stable tag: 3.1.9 9 9 License: GPL-2.0 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 126 126 == Changelog == 127 127 128 = 3.1.9 / 2024-04-30 = 129 # Bug fix 130 * Prevent local URLs from loading with events block [#2607](https://github.com/godaddy-wordpress/coblocks/pull/2607) 131 * Fix Site Content extension loading outside of editor [#2609](https://github.com/godaddy-wordpress/coblocks/pull/2609) 132 * Fix Site Design extension failing dom operations [#2610](https://github.com/godaddy-wordpress/coblocks/pull/2610) 133 128 134 = 3.1.8 / 2024-04-02 = 129 135 # Enhancements -
coblocks/trunk/src/blocks/events/index.php
r2949408 r3079624 18 18 if ( empty( $attributes['externalCalendarUrl'] ) ) { 19 19 return $content; 20 } 21 22 // If externalCalendarUrl contains a localhost URL, return an error message. 23 if ( strpos( $attributes['externalCalendarUrl'], 'localhost' ) !== false || strpos( $attributes['externalCalendarUrl'], '127.0' ) !== false ) { 24 return '<div class="components-placeholder"><div class="notice notice-error">' . __( 'An error has occurred. localhost URLs are not permitted.', 'coblocks' ) . '</div></div>'; 20 25 } 21 26 … … 35 40 ) 36 41 ); 37 $ical->init_url( $attributes['externalCalendarUrl']);42 $ical->init_url( esc_url_raw( $attributes['externalCalendarUrl'] ) ); 38 43 39 44 if ( 'all' === $attributes['eventsRange'] ) { -
coblocks/trunk/src/blocks/post-carousel/index.php
r2949408 r3079624 23 23 'orderby' => $attributes['orderBy'], 24 24 'suppress_filters' => false, 25 'post__not_in' => array( $post->ID),25 'post__not_in' => ! is_null( $post ) ? array( $post->ID ) : array(), 26 26 ); 27 27 -
coblocks/trunk/src/blocks/posts/index.php
r2949408 r3079624 23 23 'orderby' => $attributes['orderBy'], 24 24 'suppress_filters' => false, 25 'post__not_in' => array( $post->ID),25 'post__not_in' => ! is_null( $post ) ? array( $post->ID ) : array(), 26 26 ); 27 27
Note: See TracChangeset
for help on using the changeset viewer.