| 1 |
(()=>{"use strict";var e={9781:(e,t,n)=>{t._j=t.Ay=void 0;var a=n(5676);Object.defineProperty(t,"Ay",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(t,"_j",{enumerable:!0,get:function(){return a.useMediaLayout}})},5676:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useMediaLayout=t.useMedia=t.mockMediaQueryList=void 0;var a=n(1594),i=n(1606);t.mockMediaQueryList={media:"",matches:!1,onchange:i.noop,addListener:i.noop,removeListener:i.noop,addEventListener:i.noop,removeEventListener:i.noop,dispatchEvent:function(e){return!0}};var s=function(e){return function(n,s){void 0===s&&(s=!1);var r=a.useState(s),o=r[0],l=r[1],d=i.queryObjectToString(n);return e((function(){var e=!0,n="undefined"==typeof window?t.mockMediaQueryList:window.matchMedia(d),a=function(){e&&l(Boolean(n.matches))};return n.addListener(a),l(n.matches),function(){e=!1,n.removeListener(a)}}),[d]),o}};t.useMedia=s(a.useEffect),t.useMediaLayout=s(a.useLayoutEffect),t.default=t.useMedia},7813:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return e.replace(/[A-Z]/g,(function(e){return"-"+e.toLowerCase()})).toLowerCase()}},1606:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.noop=t.queryObjectToString=t.camelToHyphen=void 0;var a=n(7813);Object.defineProperty(t,"camelToHyphen",{enumerable:!0,get:function(){return a.default}});var i=n(194);Object.defineProperty(t,"queryObjectToString",{enumerable:!0,get:function(){return i.default}});var s=n(1648);Object.defineProperty(t,"noop",{enumerable:!0,get:function(){return s.default}})},1648:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){}},194:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var a=n(7813),i=" and ";t.default=function(e){return"string"==typeof e?e:Object.entries(e).map((function(e){var t=e[0],n=e[1],i=a.default(t),s=n;return"boolean"==typeof s?s?i:"not "+i:("number"==typeof s&&/[height|width]$/.test(i)&&(s+="px"),"("+i+": "+s+")")})).join(i)}},1594:e=>{e.exports=React}},t={};function n(a){var i=t[a];if(void 0!==i)return i.exports;var s=t[a]={exports:{}};return e[a](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e=n(1594),t=n.n(e);const a=ReactDOM,i=wp.i18n,s=FL.Assistant.ui,r=ReactRouterDOM,o=classnames;var l=n.n(o);const d=FL.vendors.BBFluid,c=FL.vendors.BBAppCore,u=FL.Assistant.data,m=({children:e})=>{const{history:n}=(0,u.useSystemState)(!1),a={initialIndex:n.index};return n.entries&&n.entries.length&&(a.initialEntries=n.entries),t().createElement(r.MemoryRouter,a,e)},p=wp.keycodes,f=FramerMotion;var g=n(9781);const h=(0,e.memo)((()=>{const{isAppHidden:e}=(0,u.useSystemState)(),{selectApp:n,selectHomeApp:a}=(0,u.getSystemSelectors)(),{isMobile:o,isCompactHeight:d,application:c}=s.Env.use(),{toggleIsShowingUI:m,setIsAppHidden:h}=(0,u.getSystemActions)(),y=(0,g.Ay)({maxHeight:400}),E=(0,r.useHistory)(),{pathname:v}=E.location,w="beaver-builder"===c,x=0===E.index,L=v.startsWith("/fl-manage"),S=()=>{E.go(-E.length),E.replace("/",{})},M=(t=!1,n=(()=>{}))=>{t?h(!e):(h(!1),n())},A=l()("fl-asst-sidebar","frame-drag-handle",{"fl-asst-sidebar-compact":d}),C=()=>{const n=a();return n?t().createElement(f.motion.li,{layout:!0,transition:{layoutX:{duration:0}}},t().createElement(s.Button,{appearance:x&&!e?"normal":"transparent",shape:"round",size:"lg",isSelected:x&&!e,onClick:()=>M(x,S),className:"disable-while-sorting",title:n.label},t().createElement(s.Icon.Safely,{icon:n.icon,isSelected:x&&!e}))):null},I=()=>{const a=n("fl-manage");return t().createElement(f.motion.li,{layout:!0,transition:{layoutX:{duration:0}}},t().createElement(s.Button,{appearance:L&&!e?"normal":"transparent",shape:"round",size:"lg",isSelected:L&&!e,onClick:()=>M(L,(()=>E.push({pathname:`/${a.handle}`,state:a}))),className:"disable-while-sorting",title:a.label},t().createElement(s.Icon.Safely,{icon:a.icon,isSelected:L&&!e})))},P=()=>{let e=()=>m(!1);if(w){if(void 0===FL.Builder||"function"!=typeof FL.Builder.togglePanel)return null;e=FL.Builder.togglePanel}return t().createElement(s.Button,{appearance:"transparent",onClick:e,className:"fl-asst-sidebar-close-button",title:(0,i.__)("Hide Panel"),shape:"round",size:"lg",style:{margin:"0 auto"}},t().createElement(s.Icon.Close,null))};return t().createElement("div",{className:A,style:{cursor:"move"}},t().createElement("div",{className:"fl-asst-sidebar-cell fl-asst-sidebar-cell-top"},t().createElement(P,null)),t().createElement("div",{className:"fl-asst-sidebar-cell fl-asst-sidebar-cell-middle"},t().createElement(s.App.List,{before:t().createElement(C,null),after:t().createElement(I,null),limit:y?3:d?4:o?3:5},(({label:n,handle:a,icon:i,moveDown:r,moveUp:o})=>{const l={pathname:`/${a}`},d=a===v.split("/")[1],c={icon:i,context:"sidebar",isSelected:d};return t().createElement(s.Button,{appearance:d&&!e?"normal":"transparent",shape:"round",size:"lg",isSelected:d&&!e,onClick:()=>{M(d,(()=>E.push(l)))},title:n,onKeyDown:e=>{e.keyCode===p.DOWN&&(r(),e.preventDefault()),e.keyCode===p.UP&&(o(),e.preventDefault())}},t().createElement(b,c))}))),!o&&t().createElement("div",{className:"fl-asst-sidebar-cell disable-while-sorting",style:{minHeight:60}}))})),b=(0,e.memo)((e=>t().createElement(s.Icon.Safely,e))),y=h,E=()=>{const{apps:e,window:n,isAppHidden:a,homeKey:i}=(0,u.useSystemState)(["apps","window","isAppHidden","homeKey"]),{origin:o}=n,d=o[0]?"right":"left",{isMobile:m,application:p}=s.Env.use(),f="right"===d?"row-reverse":"row",g="beaver-builder"===p,h=(0,r.useLocation)().pathname.split("/")[1],b=l()({"fl-asst-main":!0,"fl-asst-main-sidebar-only":a,"fl-asst-is-mobile":m,[`fl-asst-app-${h}`]:h}),E=!a||g;return t().createElement("div",{className:b,style:{flexDirection:f}},t().createElement(y,null),E&&t().createElement("div",{className:"fl-asst-main-content"},t().createElement(c.App.Content,{apps:e,defaultApp:i,loading:s.Page.Loading})),t().createElement(s.Modal.Root,null))};function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},v.apply(this,arguments)}const w={top:0,left:0,bottom:0,right:0},x=(e=w)=>{const t=(()=>{const{isShowingAdminBar:e}=(0,u.getSystemConfig)(),t=(0,g._j)({maxWidth:782}),n=(0,g._j)({maxWidth:600}),{application:a}=s.Env.use();return"beaver-builder"===a?44:document.body.classList.contains("block-editor-page")?61:!e||n?0:t?46:32})();let n=e;return Number.isInteger(e)&&(n={top:e,right:e,bottom:e,left:e}),{...n,top:n.top+t}},L=(e=0,t,n)=>e?`calc( 100% - ${t+n.right}px )`:n.left,S=e=>e>=window.innerWidth/2,M=e=>e>=window.innerHeight/2,A=({x:e,y:t})=>[S(e)?1:0,M(t)?1:0],C=(e,t)=>typeof e!=typeof t||e[0]!==t[0]||e[1]!==t[1],I=({x:n,top:a,pinnedRight:i,maxWidth:s,minWidth:r,setWidth:o,size:l,getSizeName:d})=>{const c=(0,e.useRef)(n.get()),u=(0,e.useRef)(l);return t().createElement(f.motion.div,{className:"fl-asst-frame-resize-handle",drag:"x",dragMomentum:!1,onDrag:()=>{let e=parseInt(Math.abs(n.get()));if(e>c.current+10||e<c.current-10){const t=d(e);t!==u.current&&(o(e),u.current=t),c.current=e}},onDragEnd:()=>{let e=parseInt(Math.abs(n.get()));s<e?e=s:r>e&&(e=r),o(e)},dragElastic:0,dragConstraints:{left:i?-Math.abs(s):r,right:i?-Math.abs(r):s},style:{x:n,width:6,position:"fixed",top:a,bottom:0,left:i?"auto":0,right:i?0:"auto"}})},P=()=>t().createElement("div",{className:"frame-drag-handle",style:{display:"flex",justifyContent:"center",paddingTop:4,paddingBottom:10,position:"absolute",top:0,left:0,right:0,zIndex:5,cursor:"move",color:"var(--fluid-opaque-7)"}},t().createElement("svg",{width:"40",height:"4",viewBox:"0 0 40 4",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},t().createElement("path",{d:"M2,2 L38,2",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round"}))),k=({left:e,...n})=>t().createElement("div",v({style:{position:"fixed",top:0,bottom:0,left:e,width:60,background:"var(--fluid-blue)",zIndex:9998}},n)),_=({children:n,isHidden:a=!1,className:i,...r})=>{const{window:o,isAppHidden:c}=(0,u.useSystemState)(["window","isAppHidden"]),{width:m=w,origin:p}=o,[h]=p,{setWindow:b}=(0,u.getSystemActions)(),{minWidth:y,maxWidth:E,defaultWidth:w,breakpoint:M}=(0,u.getSystemConfig)().frameDefaults,A="beaver-builder"===s.Env.use().application,C=(0,f.useAnimation)(),_=(0,f.useDragControls)(),[B,j]=(0,e.useState)(!1),O=x(),H=JSON.stringify(O),{top:D,left:F,width:N,height:W}=((e,t,n=!1,a=420)=>{const i=n?60:a;return{top:t.top,left:L(e,i,t),width:i,height:`calc( 100vh - ${t.top+t.bottom}px )`}})(h,O,c,m),z=((e,t)=>e||t?"0 0 0px hsla( 210, 0%, 0%, 0 )":"0 0 20px hsla( 210, 20%, 30%, .15 )")(a,c),R=y,T=E>window.innerWidth?window.innerWidth:E,$=(0,f.useMotionValue)(h?-Math.abs(m):m),q=(0,f.useTransform)($,(e=>c?60:Math.abs(e))),U=(0,f.useTransform)(q,(e=>h?`calc( 100% - ${e+O.right}px )`:0)),K=h?N:-Math.abs(N),Q=(0,g.Ay)({maxWidth:600});(0,e.useEffect)((()=>{const e=document.documentElement;return e.classList.add(h?"fl-asst-pinned-right":"fl-asst-pinned-left"),()=>{e.classList.remove("fl-asst-pinned-right","fl-asst-pinned-left")}}),[]),(0,e.useEffect)((()=>{const e=document.documentElement;a?C.set({x:K,left:F}):(C.start({x:0,y:0,left:F}),h?($.set(-Math.abs(m)),e.classList.replace("fl-asst-pinned-left","fl-asst-pinned-right")):($.set(m),e.classList.replace("fl-asst-pinned-right","fl-asst-pinned-left")))}),[h]),(0,e.useEffect)((()=>{C.set({top:D,height:W})}),[H]),(0,e.useEffect)((()=>{C.start({width:N,left:F,boxShadow:z})}),[c]),(0,e.useEffect)((()=>{const e=h?N:-Math.abs(N);C.start({x:a?e:0,boxShadow:z}).then((()=>{C.set({pointerEvents:a?"none":"auto"})}));const t=document.documentElement;a?t.classList.remove("fl-asst-pinned-right","fl-asst-pinned-left"):t.classList.add(h?"fl-asst-pinned-right":"fl-asst-pinned-left")}),[a]),(0,e.useEffect)((()=>{const e=Math.floor(q.get());m!==e&&$.set(h?-Math.abs(m):m)}),[m]);const X=e=>e>=M?"medium":"compact",J=X(m),V={size:J,isMedium:"medium"===J,isCompact:"compact"===J,isDragging:!1===B},Z=l()("fl-asst-frame",{[`fluid-frame-size-${J}`]:J},i),G=!1===B&&!a&&!c;return t().createElement(d.Frame.Context.Provider,{value:V},!1!==B&&t().createElement(k,{left:L(B,60,O)}),t().createElement(f.motion.div,v({className:Z,animate:C,transition:{duration:.2},initial:{x:a?K:0,top:D,left:F,width:N,height:W,boxShadow:z},style:{width:q,left:U,position:"fixed",overflow:"auto",boxSizing:"border-box",background:"var(--fluid-background)",zIndex:Q||A?999999:9999,display:"flex",flexDirection:"column",pointerEvents:a?"none":null,contain:"strict",willChange:"transform"},drag:!0,dragControls:_,onDragStart:(e,t)=>{e.target.classList.contains("frame-drag-handle")||_.componentControls.forEach((n=>n.stop(e,t)))},onDrag:(e,t)=>{S(t.point.x)?1!==B&&j(1):0!==B&&j(0)},onDragEnd:(e,t)=>{if(j(!1),!e.target.classList.contains("frame-drag-handle"))return;const n=S(t.point.x)?1:0;h!==n?((e="left")=>{let t=[...o.origin];t[0]="right"===e?1:0,b({...o,origin:t})})(n?"right":"left"):C.start({x:0,y:0})}},r),t().createElement(P,null),n),G&&t().createElement(I,{x:$,top:D,pinnedRight:h,maxWidth:T,minWidth:R,setWidth:e=>b({...o,width:e}),size:J,getSizeName:X}))},B=({...n})=>{const a=(0,f.useAnimation)(),{window:i}=(0,u.useSystemState)(["window"]),{origin:r}=i,{toggleIsShowingUI:o,setWindow:l}=(0,u.getSystemActions)(),[d,c]=(0,e.useState)(!1),m=50,p=x(15),g=(e,t,n)=>e?`calc( 100vh - ${t+n.bottom}px )`:n.top;return(0,e.useEffect)((()=>{a.start({x:0,y:0,top:g(r[1],m,p),left:L(r[0],m,p)})}),[r]),t().createElement(t().Fragment,null,t().createElement(f.motion.button,v({onClick:()=>{d||o(),c(!1)},initial:{position:"fixed",top:g(r[1],m,p),left:L(r[0],m,p),display:"flex",alignItems:"center",justifyContent:"center",background:"var(--fluid-opaque-13)",width:m,height:m,borderRadius:25,scale:1,zIndex:99999},animate:a,transition:{type:"tween"},drag:!0,whileDrag:{scale:1.1},onDrag:(e,t)=>{const n=A(t.point);C(d,n)&&c(r)},onDragEnd:(e,t)=>{const n=A(t.point);C(r,n)?l({...i,origin:n}):a.start({x:0,y:0})},"aria-label":"Assistant","aria-expanded":!1,"aria-disabled":!1},n),t().createElement(s.Icon.Pencil,{size:36})))},j=()=>{const t=(0,r.useLocation)(),n=(0,r.useHistory)(),{setHistory:a}=(0,u.getSystemActions)();return(0,e.useEffect)((()=>{a(n.index,n.entries)}),[t]),null},O=({displayingIn:e,children:n})=>t().createElement(c.Root,{router:m},t().createElement(j,null),t().createElement(s.Env.Provider,{application:e},n)),H=()=>{const{isShowingAdminBar:e,isAdmin:n}=(0,u.getSystemConfig)(),{appearance:a,window:i}=(0,u.useSystemState)(["window","appearance"]),{isHidden:s,hiddenAppearance:r}=i,o=!n&&s&&("admin_bar"!==r||!e);return t().createElement(O,null,t().createElement(d.Color.SchemeProvider,{value:a.brightness},t().createElement(_,{isHidden:s},t().createElement(E,null)),o&&t().createElement(B,null)))},D=()=>t().createElement("div",{id:"fl-asst-mount"}),F=()=>t().createElement(O,{displayingIn:"beaver-builder"},t().createElement(_,null,t().createElement(E,null))),N=()=>{const{setWindow:e}=(0,u.getSystemActions)(),t=document.createElement("button");t.classList.add("skip-link","fl-asst-screen-reader-text"),t.innerText=(0,i.__)("Skip to Assistant"),t.tabIndex=1,t.addEventListener("click",(()=>{e({isHidden:!1});const t=document.getElementById("fl-asst-close-panel");t&&t.focus()})),document.body.prepend(t)},W=FL.Assistant;document.addEventListener("DOMContentLoaded",(()=>{const e=document.querySelector("#wp-admin-bar-fl_assistant_toggle_ui");e&&e.addEventListener("click",W.toggleUI)}));const z=parseInt(t().version.split(".")[0])>=18;let R,T;const $=()=>{void 0!==T&&z?T.unmount():(0,a.unmountComponentAtNode)(R)},q=()=>{R=document.getElementById("fl-asst-mount"),R?$():(R=document.createElement("div"),R.classList.add("fl-asst-mount","fl-asst","fl-asst-plugin","fluid","fl","uid"),R.id="fl-asst-mount",document.body.appendChild(R)),z?(T=(0,a.createRoot)(R),T.render(t().createElement(H,null))):(0,a.render)(t().createElement(H,null),R)},U=()=>{const{registerPanel:e,togglePanel:n}=FL.Builder;e("assistant",{wrapClassName:"fl-asst",label:(0,i.__)("Assistant"),root:D,frame:!1,onMount:()=>{R=document.getElementById("fl-asst-mount"),z?(T=(0,a.createRoot)(R),T.render(t().createElement(F,null))):(0,a.render)(t().createElement(F,null),R)},onUnMount:$});const s=document.querySelector(".fl-builder-fl-assistant-button");s&&s.addEventListener("click",(()=>n("assistant")))},K=()=>{if(FLBuilder.addHook("endEditingSession",q),FLBuilder.addHook("restartEditingSession",$),"Builder"in FL&&"registerPanel"in FL.Builder){const{registerPanel:e,togglePanel:t}=FL.Builder;e("assistant",{wrapClassName:"fl-asst",label:(0,i.__)("Assistant"),root:F,render:F,frame:!1});const n=document.querySelector(".fl-builder-fl-assistant-button");n&&n.addEventListener("click",(()=>t("assistant")))}},Q=document.getElementById("fl-builder-ui-iframe");Q?Q.addEventListener("load",U):"FLBuilder"in window?FLBuilder.addHook("didInitUI",K):q(),wp&&"plugins"in wp&&"editPost"in wp&&wp.plugins.registerPlugin("fl-asst-more-menu-item",{render:()=>{const{PluginMoreMenuItem:e}=wp.editPost;return t().createElement(e,{icon:t().createElement(s.Icon.Pencil,null),onClick:FL.Assistant.toggleUI},(0,i.__)("Assistant"))}}),N()})()})(); |