[Back]
(()=>{"use strict";var t,e={1886:(t,e,o)=>{var r={};o.r(r),o.d(r,{apiFetch:()=>l,setBlockData:()=>n,updateBlockData:()=>c});var s={};o.r(s),o.d(s,{API_FETCH:()=>u});var i={};o.r(i),o.d(i,{getBlockData:()=>h});const a=window.wp.data;function l(t){return{type:"API_FETCH",request:t}}function n(t){return{type:"SET_BLOCK_DATA",data:t}}function c(t){return{type:"UPDATE_BLOCK_DATA",data:t}}const{apiFetch:d}=wp;function u({request:t}){return d(t).then((t=>!!(t&&t.success&&t.response)&&t.response))}const{VPSavedLayoutVariables:p}=window,{VPSavedLayoutVariables:f}=window;function h(t){return t.data||f.data}const v=(0,a.createReduxStore)("visual-portfolio/saved-layout-data",{reducer:function(t={data:p.data},e={}){switch(e.type){case"SET_BLOCK_DATA":if(e.data)return t?{...t,data:e.data}:e;break;case"UPDATE_BLOCK_DATA":if(e.data&&t)return{...t,data:{...t.data,...e.data}}}return t},selectors:i,actions:r,controls:s});(0,a.register)(v);const g=window.wp.blockEditor,w=window.wp.blocks,k=window.wp.components,y=window.wp.element,b=window.wp.hooks,_=window.wp.i18n,x=window.ReactJSXRuntime,{navigator:m}=window;let j;function S(t){const[e,o]=(0,y.useState)(!1);return(0,x.jsxs)("div",{className:"vpf-layout-shortcode-copy",children:[(0,x.jsxs)("strong",{children:[t.label,":"]}),(0,x.jsxs)("div",{children:[(0,x.jsx)("pre",{children:t.content}),(0,x.jsxs)(k.Button,{onClick:()=>{m.clipboard.writeText(t.content).then((()=>{o(!0),clearTimeout(j),j=setTimeout((()=>{o(!1)}),450)}))},children:[(0,x.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16",children:[(0,x.jsx)("path",{d:"M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"}),(0,x.jsx)("path",{d:"M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"})]}),e?(0,x.jsx)("div",{className:"vpf-layout-shortcode-copied",children:(0,_.__)("Copied!","visual-portfolio")}):null]})]})]})}(0,w.registerBlockType)("visual-portfolio/saved-editor",{icon:{foreground:"#2540CC",src:(0,x.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,x.jsx)("mask",{id:"mask0","mask-type":"alpha",maskUnits:"userSpaceOnUse",x:"9",y:"8",width:"5",height:"6",children:(0,x.jsx)("path",{d:"M11.1409 14L13.0565 8.49994H11.2789L9.55397 14H11.1409Z",fill:"url(#paint0_linear)"})}),(0,x.jsx)("g",{mask:"url(#mask0)",children:(0,x.jsx)("path",{d:"M11.1409 14L13.0565 8.49994H11.2789L9.55397 14H11.1409Z",fill:"currentColor"})}),(0,x.jsx)("path",{d:"M8.90795 14L6.9923 8.49994H8.76989L10.4948 14H8.90795Z",fill:"currentColor"}),(0,x.jsx)("path",{d:"M19 16.2222C19 16.6937 18.8104 17.1459 18.4728 17.4793C18.1352 17.8127 17.6774 18 17.2 18H2.8C2.32261 18 1.86477 17.8127 1.52721 17.4793C1.18964 17.1459 1 16.6937 1 16.2222V3.77778C1 3.30628 1.18964 2.8541 1.52721 2.5207C1.86477 2.1873 2.32261 2 2.8 2H7.3L9.1 4.66667H17.2C17.6774 4.66667 18.1352 4.85397 18.4728 5.18737C18.8104 5.52076 19 5.97295 19 6.44444V16.2222Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"transparent"}),(0,x.jsx)("defs",{children:(0,x.jsxs)("linearGradient",{id:"paint0_linear",x1:"12.191",y1:"8.49994",x2:"7.44436",y2:"15.1301",gradientUnits:"userSpaceOnUse",children:[(0,x.jsx)("stop",{}),(0,x.jsx)("stop",{offset:"1",stopOpacity:"0"})]})})]})},edit:function(t){const{clientId:e}=t,[o,r]=(0,y.useState)(!1),{postId:s,blockData:i,VisualPortfolioBlockEdit:l}=(0,a.useSelect)((t=>{const{getBlockData:e}=t("visual-portfolio/saved-layout-data"),{getCurrentPostId:o}=t("core/editor"),{getBlockType:r}=t("core/blocks");return{postId:o(),blockData:e(),VisualPortfolioBlockEdit:r("visual-portfolio/block")?.edit||(()=>null)}})),{updateBlockData:n}=(0,a.useDispatch)("visual-portfolio/saved-layout-data");let c=[{label:(0,_.__)("This Saved Layout","visual-portfolio"),content:`[visual_portfolio id="${s}"]`},{label:(0,_.__)("Filter","visual-portfolio"),content:`[visual_portfolio_filter id="${s}" type="minimal" align="center" show_count="false" text_all="All"]`,isOptional:!0},{label:(0,_.__)("Sort","visual-portfolio"),content:`[visual_portfolio_sort id="${s}" type="minimal" align="center"]`,isOptional:!0}];return c=(0,b.applyFilters)("vpf.layouts-editor.shortcodes-list",c,{props:t,postId:s,blockData:i,updateBlockData:n,VisualPortfolioBlockEdit:l}),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(g.InspectorControls,{children:(0,x.jsxs)(k.PanelBody,{title:(0,_.__)("Shortcodes","visual-portfolio"),scrollAfterOpen:!0,children:[(0,x.jsx)("p",{children:(0,_.__)("To output this saved layout and its components you can use the following shortcodes:")}),c.map((t=>t.isOptional?null:(0,x.jsx)(S,{...t},`shortcode-${t.label}`))),o?(0,x.jsxs)(x.Fragment,{children:[c.map((t=>t.isOptional?(0,x.jsx)(S,{...t},`shortcode-${t.label}`):null)),(0,b.applyFilters)("vpf.layouts-editor.shortcodes","",this)]}):(0,x.jsx)(k.Button,{isLink:!0,onClick:()=>{r(!o)},children:(0,_.__)("Show Additional Shortcodes","visual-portfolio")})]})}),(0,x.jsx)(l,{attributes:{...i,block_id:i.id||e},setAttributes:t=>{n(t)},clientId:e})]})},save:()=>null});const O=window.wp.apiFetch;var B=o.n(O);(0,window.wp.plugins.registerPlugin)("vpf-saved-layouts-editor",{render:function(){const{isSavingPost:t,isAutosavingPost:e,selectedBlock:o,editorSettings:r,editorMode:s,blocks:i,postId:l,blockData:n}=(0,a.useSelect)((t=>{const{isSavingPost:e,isAutosavingPost:o,getCurrentPostId:r,getEditorSettings:s}=t("core/editor"),{getSelectedBlock:i,getBlocks:a}=t("core/block-editor"),{getEditorMode:l}=t("core/edit-post"),{getBlockData:n}=t("visual-portfolio/saved-layout-data");return{isSavingPost:e(),isAutosavingPost:o(),selectedBlock:i(),editorSettings:s(),editorMode:l(),blocks:a(),postId:r(),blockData:n()}}),[]),{selectBlock:c,insertBlocks:d,resetBlocks:u}=(0,a.useDispatch)("core/block-editor"),{editPost:p}=(0,a.useDispatch)("core/editor"),{switchEditorMode:f}=(0,a.useDispatch)("core/edit-post");(0,y.useEffect)((()=>{r.richEditingEnabled&&"text"===s&&f()}),[r,s,f]);const h=(0,y.useRef)(!1);(0,y.useEffect)((()=>{h.current||1===i.length&&i[0]&&"visual-portfolio/saved-editor"===i[0].name||(h.current=!0,u([]),d((0,w.createBlock)("visual-portfolio/saved-editor")),h.current=!1)}),[i,h,u,d]);const v=(0,y.useRef)(!1);(0,y.useEffect)((()=>{if(v.current)return;if(o&&"visual-portfolio/saved-editor"===o.name)return void(v.current=!0);if(document.querySelector(".editor-post-title__block.is-selected, .editor-post-title.is-selected"))return;let t="";i.forEach((e=>{"visual-portfolio/saved-editor"===e.name&&(t=e.clientId)})),t&&c(t)}),[o,i,c]);const g=(0,y.useRef)(!1),k=(0,y.useRef)(!1);(0,y.useEffect)((()=>{n&&Object.keys(n).length&&(t||e||!g.current?g.current=JSON.stringify(n):(clearTimeout(k.current),k.current=setTimeout((()=>{g.current!==JSON.stringify(n)&&p({edited:new Date})}),150)))}),[t,e,n,p]);const b=(0,y.useRef)(!1),_=(0,y.useRef)(!1);return(0,y.useEffect)((()=>{const o=b.current&&!t&&!_.current;if(b.current=t,_.current=e,o){const t={};Object.keys(n).forEach((e=>{t[`vp_${e}`]=n[e]})),B()({path:"/visual-portfolio/v1/update_layout/",method:"POST",data:{data:t,post_id:l}}).catch((t=>{console.log(t)}))}}),[t,e,l,n]),null}})}},o={};function r(t){var s=o[t];if(void 0!==s)return s.exports;var i=o[t]={exports:{}};return e[t](i,i.exports,r),i.exports}r.m=e,t=[],r.O=(e,o,s,i)=>{if(!o){var a=1/0;for(d=0;d<t.length;d++){for(var[o,s,i]=t[d],l=!0,n=0;n<o.length;n++)(!1&i||a>=i)&&Object.keys(r.O).every((t=>r.O[t](o[n])))?o.splice(n--,1):(l=!1,i<a&&(a=i));if(l){t.splice(d--,1);var c=s();void 0!==c&&(e=c)}}return e}i=i||0;for(var d=t.length;d>0&&t[d-1][2]>i;d--)t[d]=t[d-1];t[d]=[o,s,i]},r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t={7696:0,616:0};r.O.j=e=>0===t[e];var e=(e,o)=>{var s,i,[a,l,n]=o,c=0;if(a.some((e=>0!==t[e]))){for(s in l)r.o(l,s)&&(r.m[s]=l[s]);if(n)var d=n(r)}for(e&&e(o);c<a.length;c++)i=a[c],r.o(t,i)&&t[i]&&t[i][0](),t[i]=0;return r.O(d)},o=globalThis.webpackChunkvisual_portfolio=globalThis.webpackChunkvisual_portfolio||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})();var s=r.O(void 0,[616],(()=>r(1886)));s=r.O(s)})();