!function(){"use strict";var e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AvatarLoader:function(){return E},clearCache:function(){return A},default:function(){return _}});var r={};e.r(r),e.d(r,{receiveAvatar:function(){return f}});var n={};e.r(n),e.d(n,{getAvatar:function(){return w}});var a={};e.r(a),e.d(a,{getAvatar:function(){return g}});var i=window.wp.dataControls,c=window.wp.data;function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var u=(0,window.nisje.data.onSubKey)("context")((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_AVATAR":return l(l({},e),{},o({},t.id,t.sources));default:return e}})),d="members";function f(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d;return{type:"RECEIVE_AVATAR",id:e,context:r,sources:t}}var v=window.regeneratorRuntime,p=e.n(v),h=p().mark(w);function w(e){var t,r,n=arguments;return p().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:d,a.next=3,(0,i.apiFetch)({path:"/buddypress/v1/".concat(t,"/").concat(e,"/avatar?_fields=full")});case 3:if(r=a.sent,!Array.isArray(r)||0===r.length){a.next=9;break}return a.next=7,f(e,r[0].full,t);case 7:a.next=11;break;case 9:return a.next=11,f(e,"fallback",t);case 11:case"end":return a.stop()}}),h)}var m=window.lodash;function g(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d;return(0,m.get)(e[r],t,!1)}(0,c.registerStore)("nisje/avatar",{reducer:u,controls:i.controls,actions:r,selectors:a,resolvers:n});var b=window.wp.element,y=window.wp.i18n,j=window.nisje.format,x=function(e){var t=e.size,r=e.name;return(0,b.createElement)("svg",{"aria-hidden":!0,focusable:!1,height:t,role:"img",viewBox:"0 0 150 150",width:t},(0,b.createElement)("rect",{className:"nisje-avatar__fill",height:"100%",width:"100%"}),(0,b.createElement)("text",{className:"nisje-avatar__text",dominantBaseline:"middle",fontSize:"50px",fontWeight:"600",textAnchor:"middle",x:"50%",y:"79"},r.replace(/[^a-zA-Z]+/g,"").substring(0,2).toUpperCase()))},O=function(e){var t=e.size;return(0,b.createElement)("svg",{"aria-hidden":!0,focusable:!1,height:t,role:"img",viewBox:"0 0 150 150",width:t,xmlns:"http://www.w3.org/2000/svg"},(0,b.createElement)("path",{d:"M0 0h150v150H0z",fill:"#d9edfb"}),(0,b.createElement)("circle",{cx:"75",cy:"58",fill:"#006db5",r:"33"}),(0,b.createElement)("path",{d:"M145.8 150c-2.6-35.6-33.3-50-70.8-50S6.8 114.4 4.2 150h141.6z",fill:"#006db5"}))},E=function(e){var t=e.className,r=e.size,n=void 0===r?150:r,a=(0,j.classnames)("nisje-avatar",t),i={height:"".concat(n,"px"),width:"".concat(n,"px")};return(0,b.createElement)("div",{className:"".concat(a," nisje-avatar__loader"),style:i})};function A(){caches.delete("nisje-avatars")}var _=function(e){var t=e.className,r=e.context,n=e.id,a=e.name,i=void 0===a?"":a,o=e.size,s=void 0===o?150:o,l=(0,j.classnames)("nisje-avatar",t),u={height:"".concat(s,"px"),width:"".concat(s,"px")},d=(0,c.useSelect)((function(e){return(0,e("nisje/avatar").getAvatar)(n,r)}),[n]);if(!d)return(0,b.createElement)(E,{className:t,size:s});if("fallback"!==d)return(0,b.createElement)("img",{alt:(0,y.__)("Avatar"),className:l,height:"".concat(s,"px"),loading:"lazy",src:d,style:u,width:"".concat(s,"px")});var f=String(n),v=f.charAt(f.length-1),p="groups"===r?x:O;return(0,b.createElement)("div",{className:"".concat(l," nisje-avatar__color--").concat(v),style:u},(0,b.createElement)(p,{name:i,size:s}))};(window.nisje=window.nisje||{}).avatar=t}();