(()=>{"use strict";const e=window.ReactJSXRuntime;!function(t){const{addFilter:i}=t.hooks,{createHigherOrderComponent:n}=t.compose,{Fragment:r,cloneElement:l}=t.element,{InspectorControls:o}=t.blockEditor,{PanelBody:s,TextControl:a}=t.components,{__}=t.i18n;i("blocks.registerBlockType","betheme/add-link-title-attr",(e,t)=>"core/image"!==t?e:{...e,attributes:{...e.attributes,linkTitle:{type:"string",default:""}}}),i("editor.BlockEdit","betheme/add-link-title-control",n(t=>i=>{if("core/image"!==i.name)return(0,e.jsx)(t,{...i});const{attributes:n,setAttributes:l}=i,{href:c,linkTitle:m}=n,p=!!c;return(0,e.jsxs)(r,{children:[(0,e.jsx)(t,{...i}),p&&(0,e.jsx)(o,{children:(0,e.jsx)(s,{title:__("Link","betheme"),initialOpen:!0,children:(0,e.jsx)(a,{label:__("Title attribute","betheme"),value:m||"",onChange:e=>l({linkTitle:e}),help:__('Adds title="..." to the link wrapping the image.',"betheme")})})})]})},"withLinkTitleControl")),i("blocks.getSaveElement","betheme/apply-link-title",(e,t,i)=>{if(!e||"core/image"!==t.name)return e;const{href:n,linkTitle:r}=i;if(!n||!r)return e;const o=e=>{if(!e||!e.props)return e;if("a"===e.type)return e.props.title?e:l(e,{title:r});const t=e.props.children;if(!t)return e;const i=Array.isArray(t)?t.map(o):o(t);return i===t?e:l(e,{},i)};return o(e)})}(window.wp)})();