(()=>{"use strict";var e={n:l=>{var n=l&&l.__esModule?()=>l.default:()=>l;return e.d(n,{a:n}),n},d:(l,n)=>{for(var t in n)e.o(n,t)&&!e.o(l,t)&&Object.defineProperty(l,t,{enumerable:!0,get:n[t]})},o:(e,l)=>Object.prototype.hasOwnProperty.call(e,l)};const l=window.wp.blocks,n=window.wp.element,t=window.wp.components,i=window.wp.blockEditor,r=window.wp.apiFetch;var a=e.n(r);const o=window.wp.i18n,s=window.prli.shared,p=window.ReactJSXRuntime;(0,l.registerBlockType)("pretty-links/pixel-block",{edit:function({attributes:e,setAttributes:l}){const{linkId:r}=e,[c,d]=(0,n.useState)(""),k=(0,i.useBlockProps)();(0,n.useEffect)(()=>{r&&a()({path:`/pretty-links/v1/links/${r}`}).then(e=>d(e.name||e.slug||`#${r}`)).catch(()=>d(`#${r}`))},[r]);const u=(0,n.useCallback)(async e=>{const l=await a()({path:`/pretty-links/v1/links?redirect_type=pixel&per_page=50&status=any&search=${encodeURIComponent(e||"")}`});return(Array.isArray(l)?l:[]).map(e=>({value:e.id,label:e.name||e.slug||`#${e.id}`}))},[]),w=r?{value:r,label:c||`#${r}`}:null;return(0,p.jsx)("div",{...k,children:(0,p.jsxs)(t.Placeholder,{label:(0,o.__)("Pretty Link Tracking Pixel","pretty-link-pro"),icon:"hidden",children:[(0,p.jsx)(s.ChipPicker,{label:(0,o.__)("Pixel link","pretty-link-pro"),isMulti:!1,value:w,loadOptions:u,onChange:e=>{e?(l({linkId:e.value}),d(e.label)):(l({linkId:0}),d(""))},placeholder:(0,o.__)("Search pixel links…","pretty-link-pro"),ariaLabel:(0,o.__)("Pixel link","pretty-link-pro"),isClearable:!0}),r>0&&(0,p.jsx)("p",{className:"prli-pixel-block-note",children:(0,o.__)("Renders a 1×1 invisible tracking pixel on the frontend.","pretty-link-pro")})]})})},save:()=>null})})();