(()=>{"use strict";const o=window.wp.hooks,e=((0,o.addFilter)("blocks.registerBlockType","zolo/extension/backgroundVideo",o=>(!o.category||"zoloblocks"!=o.category&&"zoloblocks-single"!=o.category||"zolo/container"!==o.name&&"zolo/slide"!==o.name||(o.attributes={...o.attributes,backgroundVideo:{type:"object"}}),o)),window.wp.blockEditor),l=window.wp.i18n,a=window.ReactJSXRuntime,{ImageAvatar:d,ZoloButton:i,ZoloBaseControl:t}=window.zoloModule,n=({panelProps:o})=>{const{attributes:n,setAttributes:r}=o,{backgroundVideo:s={}}=n,{id:c="",url:u="",falbackImageID:g="",falbackImageURL:b=""}=s;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t,{label:(0,l.__)("Select Video","zoloblocks"),className:"zolo-flex-col-control",children:c?(0,a.jsx)(d,{imageUrl:s&&s.url,onDeleteImage:()=>r({backgroundVideo:{...s,id:"",url:""}}),allowedTypes:["video"],imageId:s&&s.id,onEditImage:o=>{r({backgroundVideo:{...s,id:o.id,url:o.url}})}}):(0,a.jsx)(e.MediaUpload,{onSelect:o=>{o&&o.url&&o.id&&r({backgroundVideo:{...s,id:o.id,url:o.url}})},allowedTypes:["video"],value:c,render:({open:o})=>(0,a.jsxs)(i,{className:"zolo-image-upload-btn",onClick:o,children:[(0,a.jsx)("svg",{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",children:(0,a.jsx)("path",{d:"M11.492 10.172l-2.5 3.064-.737-.677 3.737-4.559 3.753 4.585-.753.665-2.5-3.076v7.826h-1v-7.828zm7.008 9.828h-13c-2.481 0-4.5-2.018-4.5-4.5 0-2.178 1.555-4.038 3.698-4.424l.779-.14.043-.789c.185-3.448 3.031-6.147 6.48-6.147 3.449 0 6.295 2.699 6.478 6.147l.044.789.78.14c2.142.386 3.698 2.246 3.698 4.424 0 2.482-2.019 4.5-4.5 4.5m.978-9.908c-.212-3.951-3.472-7.092-7.478-7.092s-7.267 3.141-7.479 7.092c-2.57.463-4.521 2.706-4.521 5.408 0 3.037 2.463 5.5 5.5 5.5h13c3.037 0 5.5-2.463 5.5-5.5 0-2.702-1.951-4.945-4.522-5.408"})}),(0,l.__)(" Upload Video","zoloblocks")]})})}),(0,a.jsx)(t,{label:(0,l.__)("Poster (optional)","zoloblocks"),className:"zolo-flex-col-control",children:b?(0,a.jsx)(d,{imageUrl:b,imageId:g,onDeleteImage:()=>r({backgroundVideo:{...s,falbackImageURL:"",falbackImageID:""}}),onEditImage:({id:o,url:e})=>{r({backgroundVideo:{...s,falbackImageURL:e,falbackImageID:o}})}}):(0,a.jsx)(e.MediaUpload,{onSelect:o=>{o&&o.url&&o.id&&r({backgroundVideo:{...s,falbackImageURL:o.url,falbackImageID:o.id}})},allowedTypes:["image"],value:g,render:({open:o})=>(0,a.jsxs)(i,{className:"zolo-image-upload-btn",onClick:o,children:[(0,a.jsx)("svg",{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",children:(0,a.jsx)("path",{d:"M11.492 10.172l-2.5 3.064-.737-.677 3.737-4.559 3.753 4.585-.753.665-2.5-3.076v7.826h-1v-7.828zm7.008 9.828h-13c-2.481 0-4.5-2.018-4.5-4.5 0-2.178 1.555-4.038 3.698-4.424l.779-.14.043-.789c.185-3.448 3.031-6.147 6.48-6.147 3.449 0 6.295 2.699 6.478 6.147l.044.789.78.14c2.142.386 3.698 2.246 3.698 4.424 0 2.482-2.019 4.5-4.5 4.5m.978-9.908c-.212-3.951-3.472-7.092-7.478-7.092s-7.267 3.141-7.479 7.092c-2.57.463-4.521 2.706-4.521 5.408 0 3.037 2.463 5.5 5.5 5.5h13c3.037 0 5.5-2.463 5.5-5.5 0-2.702-1.951-4.945-4.522-5.408"})}),(0,l.__)(" Upload Image","zoloblocks")]})})})]})};function r({panelProps:o}){const{attributes:e}=o,{backgroundVideo:l,uniqueId:d}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:`zolo-bgv-container zolo-bgv-${d}`,style:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"},children:(0,a.jsx)("video",{className:"zolo-bgv-hosted zolo-html5-video",loop:!0,muted:!0,playsInline:!0,preload:"none",autoPlay:!0,poster:l?.falbackImageURL||"",src:l?.url||""})})})}(0,o.addFilter)("zolo.extensions.controls.backgroundVideo","zolo/background-video",(o,e)=>(!e.attributes||"video"!==e.attributes?.advBtnBgbackgroundType&&"video"!==e.attributes?.mainBgbackgroundType||o.push((0,a.jsx)(n,{panelProps:e},`controls-background-video-${e.attributes.uniqueId}`)),o)),(0,o.addFilter)("zolo.blocks.render.hook.before","zolo/background-video",(o,e)=>(!e.attributes.backgroundVideo||"video"!==e.attributes?.advBtnBgbackgroundType&&"video"!==e.attributes?.mainBgbackgroundType||o.push((0,a.jsx)(r,{panelProps:e},`render-background-video-${e.attributes.uniqueId}`)),o))})();