!function(){"use strict";var e=window.wp.blocks,t=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"atomic-wind/image","title":"Image","category":"atomic-wind","description":"A simple image element. Set via media library or direct URL.","keywords":["image","img","photo"],"textdomain":"atomic-wind","attributes":{"id":{"type":"number"},"url":{"type":"string","source":"attribute","selector":"img","attribute":"src"},"alt":{"type":"string","source":"attribute","selector":"img","attribute":"alt","default":""},"className":{"type":"string","default":"w-full"}},"supports":{"anchor":true,"html":false,"color":false,"typography":false,"spacing":false},"editorScript":"file:./index.js"}'),o=window.wp.primitives,r=window.ReactJSXRuntime,i=(0,r.jsxs)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,r.jsx)(o.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M20.3541 3.64593C18.5085 1.8004 13.2722 4.04455 8.65837 8.65837C4.04455 13.2722 1.8004 18.5085 3.64593 20.3541C5.49146 22.1996 10.7278 19.9555 15.3416 15.3416C19.9555 10.7278 22.1996 5.49146 20.3541 3.64593Z",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)(o.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M3.64593 3.64593C1.8004 5.49146 4.04455 10.7278 8.65837 15.3416C13.2722 19.9555 18.5085 22.1996 20.3541 20.3541C22.1996 18.5085 19.9555 13.2722 15.3416 8.65837C10.7278 4.04455 5.49146 1.8004 3.64593 3.64593Z",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)(o.Path,{d:"M12.009 12H12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),n=window.wp.blockEditor,s=window.wp.components,l=window.wp.i18n,a=window.wp.data;const{name:c,...d}=t;(0,e.registerBlockType)(c,{...d,icon:i,edit:function({attributes:e,setAttributes:t,clientId:o}){const{id:i,url:c,alt:d,postField:u}=e,p=(0,n.useBlockProps)(),{isActive:m,post:g}=function(e,t){return(0,a.useSelect)((o=>{const r={isActive:!1,post:null,queryPostType:""};if(!t)return r;const{getBlockParents:i,getBlock:n}=o("core/block-editor"),s=i(e);let l="";for(const e of s){const t=n(e);if("atomic-wind/box"===t?.name&&t?.attributes?.queryPostType){l=t.attributes.queryPostType;break}}if(!l)return r;const a=o("core").getEntityRecords("postType",l,{per_page:1,_embed:!0});return{isActive:!0,post:a&&a.length>0?a[0]:null,queryPostType:l}}),[e,t])}(o,u);if(m){const e="author_avatar"===u?function(e){if(!e)return"";const t=e._embedded?.author;if(t&&t.length>0){const e=t[0]?.avatar_urls;return e?.[256]||e?.[96]||e?.[48]||e?.[24]||""}return""}(g):function(e){if(!e)return"";const t=e._embedded?.["wp:featuredmedia"];return t&&t.length>0&&(t[0]?.media_details?.sizes?.large?.source_url||t[0]?.source_url)||""}(g),t="author_avatar"===u?(0,l.__)("Author Avatar","otter-blocks"):(0,l.__)("Featured Image","otter-blocks");return e?(0,r.jsx)("img",{...p,src:e,alt:""}):(0,r.jsx)("div",{...p,style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"200px",background:"#f0f0f0",color:"#757575",fontSize:"13px"},children:t})}return c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.BlockControls,{children:(0,r.jsx)(n.MediaReplaceFlow,{mediaId:i,mediaURL:c,allowedTypes:["image"],onSelect:e=>t({id:e.id,url:e.url,alt:e.alt||""})})}),(0,r.jsx)(n.InspectorControls,{children:(0,r.jsxs)(s.PanelBody,{title:(0,l.__)("Settings","otter-blocks"),children:[(0,r.jsx)(s.TextControl,{label:(0,l.__)("Image URL","otter-blocks"),value:c,onChange:e=>t({url:e,id:void 0})}),(0,r.jsx)(s.TextControl,{label:(0,l.__)("Alt Text","otter-blocks"),value:d,onChange:e=>t({alt:e})})]})}),(0,r.jsx)("img",{...p,src:c,alt:d})]}):(0,r.jsxs)("div",{...p,children:[(0,r.jsx)(n.MediaPlaceholder,{onSelect:e=>t({id:e.id,url:e.url,alt:e.alt||""}),allowedTypes:["image"],labels:{title:(0,l.__)("Image","otter-blocks"),instructions:(0,l.__)("Upload or select an image, or enter a URL.","otter-blocks")}}),(0,r.jsx)(n.InspectorControls,{children:(0,r.jsx)(s.PanelBody,{title:(0,l.__)("Settings","otter-blocks"),children:(0,r.jsx)(s.TextControl,{label:(0,l.__)("Image URL","otter-blocks"),value:c||"",onChange:e=>t({url:e,id:void 0})})})})]})},save:function({attributes:e}){const{url:t,alt:o}=e,i=n.useBlockProps.save();return(0,r.jsx)("img",{...i,src:t||"",alt:o||""})}})}();