(()=>{var e={d:(o,n)=>{for(var r in n)e.o(n,r)&&!e.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:n[r]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};(()=>{"use strict";e.r(o),e.d(o,{conversionActions:()=>t});var n={};e.r(n),e.d(n,{getConversionActionType:()=>a,getConversionActionTypes:()=>c});var r={};e.r(r),e.d(r,{addConversionActionTypes:()=>u,removeConversionActionTypes:()=>d});var t={};e.r(t),e.d(t,{createConversionAction:()=>T,registerConversionActionType:()=>m,store:()=>p});const i=window.wp.data,s=window.lodash,c=(0,i.createSelector)(e=>(0,s.values)(e.conversionActionTypes),e=>[e.conversionActionTypes]),a=function(e,o){return e.conversionActionTypes[o]};function u(e){return{type:"ADD_CONVERSION_ACTION_TYPES",conversionActionTypes:(0,s.castArray)(e)}}function d(e){return{type:"REMOVE_CONVERSION_ACTION_TYPES",names:(0,s.castArray)(e)}}const l={conversionActionTypes:{}},p=(0,i.createReduxStore)("nab/conversion-actions",{reducer:function(e=l,o){return function(e,o){switch(o.type){case"ADD_CONVERSION_ACTION_TYPES":{const n={...e.conversionActionTypes,...(0,s.keyBy)(o.conversionActionTypes,"name")};return(0,s.isEqual)(e.conversionActionTypes,n)?e:{...e,conversionActionTypes:n}}case"REMOVE_CONVERSION_ACTION_TYPES":{const n=(0,s.omit)(e.conversionActionTypes,o.names);return(0,s.isEqual)(e.conversionActionTypes,n)?e:{...e,conversionActionTypes:n}}}}(e,o)??e},selectors:n,actions:r});!function(e){(0,i.register)(e)}(p);const v=new Uint8Array(16),y=[];for(let e=0;e<256;++e)y.push((e+256).toString(16).slice(1));const f=function(e,o,n){return o||e||!crypto.randomUUID?function(e,o,n){const r=(e=e||{}).random??e.rng?.()??crypto.getRandomValues(v);if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,o){if((n=n||0)<0||n+16>o.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)o[n+e]=r[e];return o}return function(e,o=0){return(y[e[o+0]]+y[e[o+1]]+y[e[o+2]]+y[e[o+3]]+"-"+y[e[o+4]]+y[e[o+5]]+"-"+y[e[o+6]]+y[e[o+7]]+"-"+y[e[o+8]]+y[e[o+9]]+"-"+y[e[o+10]]+y[e[o+11]]+y[e[o+12]]+y[e[o+13]]+y[e[o+14]]+y[e[o+15]]).toLowerCase()}(r)}(e,o,n):crypto.randomUUID()};function T(e,o){const{getConversionActionType:n}=(0,i.select)(p),r=n(e);if(r)return{id:f(),type:e,attributes:{...r.attributes,...o||{}},scope:r.scope}}const A=window.nab.utils;function m(e,o){if("string"!=typeof e)return void console.error("Conversion action names must be strings.");if(!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(e))return void console.error("Conversion action names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-conversion-action");if((0,i.select)(p).getConversionActionType(e))return void console.error(`Conversion action “${e}” is already registered.`);if(!g(o))return void console.error(`Conversion action “${e}” should specify a title.`);if(!b(o))return void console.error(`Conversion action “${e}” should specify a category.`);if(!h(o))return void console.error(`Conversion action “${e}” should specify a description.`);if(!C(o))return void console.error(`Conversion action “${e}” should specify its default attributes.`);if(!O(o))return void console.error(`Conversion action “${e}” should specify its default scope.`);if(!w(o))return void console.error(`The conversion action “${e}” must have an icon.`);if(!(0,A.isValidIcon)(o.icon))return void console.error("The icon passed is invalid. The icon should be an element or a function.");if(!_(o))return void console.error("The “view” property must be a valid function.");if(!E(o))return void console.error("The “edit” property must be a valid function.");const n={name:e,...o};return(0,i.dispatch)(p).addConversionActionTypes(n),n}const g=e=>"string"==typeof e.title&&!!e.title,b=e=>"string"==typeof e.category&&!!e.category,h=e=>"string"==typeof e.description&&!!e.description,C=e=>!!e.attributes,O=e=>!!e.scope,w=e=>"icon"in e,_=e=>(0,s.isFunction)(e.view),E=e=>(0,s.isFunction)(e.edit)})();var n=nab="undefined"==typeof nab?{}:nab;for(var r in o)n[r]=o[r];o.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();