!function(){"use strict";var e=window.wp.blocks,t=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"atomic-wind/text","title":"Text","category":"atomic-wind","description":"A rich text element with tag selection.","keywords":["text","paragraph","heading"],"textdomain":"atomic-wind","attributes":{"tagName":{"type":"string","default":"p"},"content":{"type":"rich-text","source":"rich-text","selector":"[data-rich-text]","role":"content"}},"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"})]}),a=window.wp.blockEditor,i=window.wp.components,s=window.wp.i18n,l=window.wp.data;const c=[{label:"p",value:"p"},{label:"span",value:"span"},{label:"h1",value:"h1"},{label:"h2",value:"h2"},{label:"h3",value:"h3"},{label:"h4",value:"h4"},{label:"h5",value:"h5"},{label:"h6",value:"h6"}],{name:d,...u}=t;(0,e.registerBlockType)(d,{...u,icon:r,edit:function({attributes:e,setAttributes:t,clientId:o}){const{tagName:r,content:d,postField:u}=e,p=(0,a.useBlockProps)(),{isActive:h,post:m}=function(e,t){return(0,l.useSelect)((o=>{const n={isActive:!1,post:null,queryPostType:""};if(!t)return n;const{getBlockParents:r,getBlock:a}=o("core/block-editor"),i=r(e);let s="";for(const e of i){const t=a(e);if("atomic-wind/box"===t?.name&&t?.attributes?.queryPostType){s=t.attributes.queryPostType;break}}if(!s)return n;const l=o("core").getEntityRecords("postType",s,{per_page:1,_embed:!0});return{isActive:!0,post:l&&l.length>0?l[0]:null,queryPostType:s}}),[e,t])}(o,u);if(h){const e=function(e,t){var o;if(!e)return"";switch(t){case"title":return e.title?.rendered||"";case"excerpt":return(e.excerpt?.rendered||"").replace(/<[^>]+>/g,"").trim();case"date":return e.date?new Date(e.date).toLocaleDateString():"";case"author":return e._embedded?.author?.[0]?.name||"";case"categories":{const t=e._embedded?.["wp:term"]?.[0];return t?t.map((e=>e.name)).join(", "):""}case"tags":{const t=e._embedded?.["wp:term"]?.[1];return t?t.map((e=>e.name)).join(", "):""}case"modified_date":return e.modified?new Date(e.modified).toLocaleDateString():"";case"comment_count":return String(null!==(o=e.comment_count)&&void 0!==o?o:0);default:return""}}(m,u),o=r||"p";return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.InspectorControls,{children:(0,n.jsx)(i.PanelBody,{title:(0,s.__)("Settings","otter-blocks"),children:(0,n.jsx)(i.SelectControl,{label:(0,s.__)("HTML Tag","otter-blocks"),value:r,options:c,onChange:e=>t({tagName:e})})})}),(0,n.jsx)(o,{...p,children:e||(0,s.__)("No data","otter-blocks")})]})}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.InspectorControls,{children:(0,n.jsx)(i.PanelBody,{title:(0,s.__)("Settings","otter-blocks"),children:(0,n.jsx)(i.SelectControl,{label:(0,s.__)("HTML Tag","otter-blocks"),value:r,options:c,onChange:e=>t({tagName:e})})})}),(0,n.jsx)(a.RichText,{...p,tagName:r,value:d,onChange:e=>t({content:e}),placeholder:(0,s.__)("Write text…","otter-blocks"),"data-rich-text":""})]})},save:function({attributes:e}){const{tagName:t,content:o}=e,r=a.useBlockProps.save();return(0,n.jsx)(a.RichText.Content,{...r,tagName:t,value:o,"data-rich-text":""})}})}();