function t(t){return"string"!=typeof t||""===t?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(t)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)}function n(t){return"string"!=typeof t||""===t?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(t)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(t)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)}function s(s,i){return function(e,o,r){let c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10;const u=s[i];if(!n(e))return;if(!t(o))return;if("function"!=typeof r)return void console.error("The hook callback must be a function.");if("number"!=typeof c)return void console.error("If specified, the hook priority must be a number.");const h={callback:r,priority:c,namespace:o};if(u[e]){const t=u[e].handlers;let n;for(n=t.length;n>0&&!(c>=t[n-1].priority);n--);n===t.length?t[n]=h:t.splice(n,0,h),u.__current.forEach((t=>{t.name===e&&t.currentIndex>=n&&t.currentIndex++}))}else u[e]={handlers:[h],runs:0};"hookAdded"!==e&&s.doAction("hookAdded",e,o,r,c)}}function i(s,i){let e=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(o,r){const c=s[i];if(!n(o))return;if(!e&&!t(r))return;if(!c[o])return 0;let u=0;if(e)u=c[o].handlers.length,c[o]={runs:c[o].runs,handlers:[]};else{const t=c[o].handlers;for(let n=t.length-1;n>=0;n--)t[n].namespace===r&&(t.splice(n,1),u++,c.__current.forEach((t=>{t.name===o&&t.currentIndex>=n&&t.currentIndex--})))}return"hookRemoved"!==o&&s.doAction("hookRemoved",o,r),u}}function e(t,n){return function(s,i){const e=t[n];return void 0!==i?s in e&&e[s].handlers.some((t=>t.namespace===i)):s in e}}function o(t,n){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(i){const e=t[n];e[i]||(e[i]={handlers:[],runs:0}),e[i].runs++;const o=e[i].handlers;for(var r=arguments.length,c=new Array(r>1?r-1:0),u=1;u<r;u++)c[u-1]=arguments[u];if(!o||!o.length)return s?c[0]:void 0;const h={name:i,currentIndex:0};for(e.__current.push(h);h.currentIndex<o.length;){const t=o[h.currentIndex].callback.apply(null,c);s&&(c[0]=t),h.currentIndex++}return e.__current.pop(),s?c[0]:void 0}}function r(t,n){return function(){var s,i;const e=t[n];return null!==(s=null===(i=e.__current[e.__current.length-1])||void 0===i?void 0:i.name)&&void 0!==s?s:null}}function c(t,n){return function(s){const i=t[n];return void 0===s?void 0!==i.__current[0]:!!i.__current[0]&&s===i.__current[0].name}}function u(t,s){return function(i){const e=t[s];if(n(i))return e[i]&&e[i].runs?e[i].runs:0}}const h=new class{constructor(){this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=s(this,"actions"),this.addFilter=s(this,"filters"),this.removeAction=i(this,"actions"),this.removeFilter=i(this,"filters"),this.hasAction=e(this,"actions"),this.hasFilter=e(this,"filters"),this.removeAllActions=i(this,"actions",!0),this.removeAllFilters=i(this,"filters",!0),this.doAction=o(this,"actions"),this.applyFilters=o(this,"filters",!0),this.currentAction=r(this,"actions"),this.currentFilter=r(this,"filters"),this.doingAction=c(this,"actions"),this.doingFilter=c(this,"filters"),this.didAction=u(this,"actions"),this.didFilter=u(this,"filters")}},{applyFilters:a}=h;export{a,h as d}