(()=>{"use strict";const e=window.wp.blocks,t=window.wp.element,l=window.wp.primitives,n=(0,t.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,t.createElement)(l.Path,{d:"M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z"})),o=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":2,"name":"small-plugins/post-term","title":"Post Term","category":"text","description":"Display a post taxonomy term link.","keywords":["category","labels"],"attributes":{"term":{"type":"object","default":{}},"opensInNewTab":{"type":"boolean","default":false}},"usesContext":["category-labels-block/scope-to-current-post","category-labels-block/display-primary","category-labels-block/fallback-primary","category-labels-block/limit"],"providesContext":{"term":"term"},"version":"1.0.0","textdomain":"category-labels-block","editorScript":"category-link-block-script","parent":["small-plugins/category-labels"],"supports":{"typography":{"fontSize":true,"lineHeight":true,"__experimentalFontStyle":true,"__experimentalFontWeight":true,"__experimentalTextTransform":true,"__experimentalFontFamily":true,"__experimentalLetterSpacing":true,"__experimentalTextDecoration":true,"__experimentalSkipSerialization":["textDecoration"],"__experimentalDefaultControls":{"fontSize":true}},"__experimentalBorder":true,"spacing":{"padding":true,"blockGap":true},"color":{"background":true,"link":false,"text":true},"layout":{"allowSwitching":false,"allowInheriting":false,"allowVerticalAlignment":false,"allowSizingOnChildren":true,"default":{"type":"flex"}}}}');function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e},r.apply(this,arguments)}const a=window.wp.blockEditor,i=window.lodash,s=window.wp.i18n,c=window.wp.components,p=(0,t.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,t.createElement)(l.Path,{d:"M20.1 5.1L16.9 2 6.2 12.7l-1.3 4.4 4.5-1.3L20.1 5.1zM4 20.8h8v-1.5H4v1.5z"})),m=function(e){return(0,t.createElement)(a.InspectorControls,null)};(0,e.registerBlockType)(o,{icon:n,edit:function(e){var l;const{term:n,opensInNewTab:o}=e.attributes,u=(0,i.get)(e,"__unstableLayoutClassNames",""),g=(0,a.useBlockProps)({className:["category-label-link_root",u].join(" ")}),[b,w]=(0,t.useState)(!1),[y,d]=(0,t.useState)(!1),k=t=>{"taxonomy"===t?.kind&&(e.setAttributes({term:t}),w(!1),d(!1))},_=!(0,i.isEmpty)(n),h="true"===(0,i.get)(smallPluginsCategoryLabelsBlockData,"isPremium"),E=h?{type:"term"}:{type:"term",subtype:["post_tag","category"]},v=(0,s.__)("Search Terms","category-labels-block"),x=()=>(0,t.createElement)(c.Popover,{onFocusOutside:()=>w(!1)},(0,t.createElement)(a.__experimentalLinkControl,{noDirectEntry:!0,settings:[],searchInputPlaceholder:v,onChange:k,showInitialSuggestions:!0,suggestionsQuery:E,renderControlBottom:()=>(0,t.createElement)("div",{onClick:e=>e.stopPropagation()},(0,t.createElement)(c.PanelBody,null,(0,t.createElement)(c.ToggleControl,{label:(0,s.__)("Open in new Tab","category-labels-block"),checked:o,onChange:()=>e.setAttributes({opensInNewTab:!o}),__experimentalNoMarginBottom:!0})))}));return(0,t.createElement)(t.Fragment,null,(0,t.createElement)("a",r({},g,{onClick:e=>{_||(e.preventDefault(),w(!b))}}),(0,t.createElement)(a.InnerBlocks,{template:[["small-plugins/term-name",{},[]]],renderAppender:!1,allowedBlocks:["small-plugins/term-name","small-plugins/term-abbreviation"],orientation:null!==(l=e?.attributes?.layout?.orientation)&&void 0!==l?l:"horizontal"}),b&&!_&&(0,t.createElement)("div",{onClick:e=>e.stopPropagation()},(0,t.createElement)(x,null))),(0,t.createElement)(a.BlockControls,null,h&&(0,t.createElement)(c.ToolbarGroup,null,(0,t.createElement)(a.Inserter,{clientId:e.clientId,rootClientId:e.clientId})),_&&(0,t.createElement)(c.ToolbarGroup,null,(0,t.createElement)(c.ToolbarButton,{showTooltip:!0,icon:p,onClick:()=>d(!y),label:(0,s.__)("Edit Category","category-labels-block")}),y&&(0,t.createElement)(x,null))),(0,t.createElement)(m,e))},save:function(e){const{opensInNewTab:l}=e.attributes,n=a.useBlockProps.save({className:"category-label-link_root"});return(0,t.createElement)("a",r({},n,{href:"{{link}}",rel:"noopener",target:l?"_blank":"_self"}),(0,t.createElement)(a.InnerBlocks.Content,null))}})})();