!function(){"use strict";var e=window.wp.blocks,t=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"atomic-wind/link","title":"Link","category":"atomic-wind","description":"An anchor element with link picker and rich text.","keywords":["link","anchor","url"],"textdomain":"atomic-wind","attributes":{"url":{"type":"string","source":"attribute","selector":"a","attribute":"href"},"text":{"type":"rich-text","source":"rich-text","selector":"a","role":"content"},"opensInNewTab":{"type":"boolean","default":false},"rel":{"type":"string","source":"attribute","selector":"a","attribute":"rel"},"mode":{"type":"string","default":"text"}},"supports":{"anchor":true,"html":false,"color":false,"typography":false,"spacing":false},"editorScript":"file:./index.js"}'),o=window.wp.primitives,n=window.ReactJSXRuntime,r=(0,n.jsxs)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,n.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,n.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,n.jsx)(o.Path,{d:"M12.009 12H12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),s=window.wp.blockEditor,i=window.wp.components,l=(0,n.jsx)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsx)(o.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})}),c=(0,n.jsx)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsx)(o.Path,{d:"M8 12.5h8V11H8v1.5Z M19 6.5H5a2 2 0 0 0-2 2V15a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a2 2 0 0 0-2-2ZM5 8h14a.5.5 0 0 1 .5.5V15a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V8.5A.5.5 0 0 1 5 8Z"})}),a=window.wp.i18n,d=window.wp.element,u=window.wp.data;const{name:p,...k}=t;(0,e.registerBlockType)(p,{...k,icon:r,edit:function({attributes:e,setAttributes:t,clientId:o}){const{url:r,text:p,opensInNewTab:k,rel:w,mode:h}=e,[x,b]=(0,d.useState)(!1),m=(0,s.useBlockProps)(),v=(0,u.useSelect)((e=>e("core/block-editor").getBlock(o)?.innerBlocks?.length||0),[o]);(0,d.useEffect)((()=>{v>0&&"inner-blocks"!==h&&t({mode:"inner-blocks"})}),[v]);const j=(0,s.useInnerBlocksProps)(m);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(s.BlockControls,{children:[(0,n.jsx)(i.ToolbarButton,{icon:l,label:(0,a.__)("Edit Link","otter-blocks"),onClick:()=>b(!x),isActive:!!r}),(0,n.jsx)(i.ToolbarGroup,{children:(0,n.jsx)(i.ToolbarButton,{icon:c,label:(0,a.__)("Switch to inner blocks mode","otter-blocks"),onClick:()=>t({mode:"inner-blocks"===h?"text":"inner-blocks"}),isActive:"inner-blocks"===h})})]}),(0,n.jsx)(s.InspectorControls,{children:(0,n.jsx)(i.PanelBody,{title:(0,a.__)("Link Settings","otter-blocks"),children:(0,n.jsxs)("p",{children:[(0,a.__)("URL:","otter-blocks"),r||(0,a.__)("Not set","otter-blocks")]})})}),"inner-blocks"===h?(0,n.jsx)("a",{...j}):(0,n.jsx)(s.RichText,{...m,tagName:"a",value:p,onChange:e=>t({text:e}),placeholder:(0,a.__)("Link text…","otter-blocks")}),x&&(0,n.jsx)(i.Popover,{position:"bottom center",onClose:()=>b(!1),children:(0,n.jsx)(s.__experimentalLinkControl,{value:{url:r,opensInNewTab:k},onChange:e=>{t({url:e.url,opensInNewTab:e.opensInNewTab})}})})]})},save:function({attributes:e}){const{url:t,text:o,opensInNewTab:r,rel:i,mode:l}=e,c=s.useBlockProps.save(),a=r?"_blank":void 0,d=i||(r?"noopener noreferrer":void 0);if("inner-blocks"===l){const e=s.useInnerBlocksProps.save({...c,href:t,target:a,rel:d});return(0,n.jsx)("a",{...e})}return(0,n.jsx)(s.RichText.Content,{...c,tagName:"a",href:t,value:o,target:a,rel:d})}})}();