(()=>{"use strict";const e=window.wp.hooks,o=window.wp.compose,a=window.wp.element,l=window.wp.blockEditor,t=window.wp.components,n=window.wp.i18n,r=window.ReactJSXRuntime,s=[{label:"— Kein Icon —",value:""},{label:"👍 Thumbs Up",value:"fa-solid fa-thumbs-up"},{label:"❤️  Heart",value:"fa-solid fa-heart"},{label:"✔️  Check",value:"fa-solid fa-check"},{label:"💬 Comment",value:"fa-solid fa-comment"},{label:"👤 User",value:"fa-solid fa-user"},{label:"✉️  Envelope",value:"fa-solid fa-envelope"},{label:"⭐ Star",value:"fa-solid fa-star"},{label:"Download",value:"fa-solid fa-download"},{label:"Upload",value:"fa-solid fa-upload"},{label:"➡️  Right",value:"fa-solid fa-arrow-right"},{label:"⬅️  Left",value:"fa-solid fa-arrow-left"},{label:"⬇️  Down",value:"fa-solid fa-arrow-down"},{label:"⬆️  Up",value:"fa-solid fa-arrow-up"}];(0,e.addFilter)("blocks.registerBlockType","sunflower/button-icon-attribute",(e,o)=>("core/button"!==o||(e.attributes={...e.attributes,myIcon:{type:"string",default:""}}),e));const i=(0,o.createHigherOrderComponent)(e=>o=>{const{name:i,attributes:c,setAttributes:u}=o;return"core/button"!==i?(0,r.jsx)(e,{...o}):(0,r.jsxs)(a.Fragment,{children:[(0,r.jsx)(e,{...o}),(0,r.jsx)(l.InspectorControls,{children:(0,r.jsx)(t.PanelBody,{title:(0,n.__)("Icon auswählen","sunflower"),initialOpen:!1,children:(0,r.jsx)(t.SelectControl,{label:(0,n.__)("Font Awesome Icon","sunflower"),value:c.myIcon,options:s,onChange:e=>u({myIcon:e})})})})]})},"withIconControl");(0,e.addFilter)("editor.BlockEdit","sunflower/button-icon-control",i),(0,e.addFilter)("blocks.getSaveElement","sunflower/button-icon-save",(e,o,l)=>{if("core/button"!==o.name)return e;const{myIcon:t}=l;if(!t)return e;const n=e.props?.children;if(!n?.props||"string"!=typeof n.props.className)return e;const r=(0,a.cloneElement)(n,{className:n.props.className+" "+t}),s=(e.props.className||"").split(" ").filter(e=>!e.startsWith("fa-")&&"fas"!==e&&"far"!==e&&"fab"!==e).join(" ");return(0,a.cloneElement)(e,{className:s},r)}),(0,e.addFilter)("editor.BlockListBlock","sunflower/button-icon-editor-preview",e=>o=>{if("core/button"!==o.name)return(0,r.jsx)(e,{...o});const{myIcon:a}=o.attributes;if(!a)return(0,r.jsx)(e,{...o});const l={...o.wrapperProps,"data-icon":a,className:[o.wrapperProps?.className,"has-fa-icon",a].filter(Boolean).join(" ")};return(0,r.jsx)(e,{...o,wrapperProps:l})})})();