File "api.js"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/better-wp-security/dist/user-groups/api.js
File size: 13.13 KB
MIME-type: text/plain
Charset: utf-8

(globalThis.itsecWebpackJsonP=globalThis.itsecWebpackJsonP||[]).push([[4862],{62352:(e,t,r)=>{"use strict";r.r(t),r.d(t,{store:()=>Ze});var i={};r.r(i),r.d(i,{APPEND_TO_QUERY:()=>X,FAILED_CREATE_GROUP:()=>ie,FAILED_DELETE_GROUP:()=>le,FAILED_FETCH_GROUPS_SETTINGS:()=>_e,FAILED_PATCH_BULK_GROUP_SETTINGS:()=>Ie,FAILED_UPDATE_GROUP:()=>de,FAILED_UPDATE_GROUP_SETTINGS:()=>he,FINISH_CREATE_GROUP:()=>re,FINISH_DELETE_GROUP:()=>ae,FINISH_FETCH_GROUPS_SETTINGS:()=>fe,FINISH_PATCH_BULK_GROUP_SETTINGS:()=>Se,FINISH_UPDATE_GROUP:()=>oe,FINISH_UPDATE_GROUP_SETTINGS:()=>ge,GROUP_NOT_FOUND:()=>ne,RECEIVE_GROUP:()=>se,RECEIVE_GROUP_SETTINGS:()=>pe,RECEIVE_MATCHABLES:()=>ee,RECEIVE_QUERY:()=>z,START_CREATE_GROUP:()=>te,START_DELETE_GROUP:()=>ce,START_FETCH_GROUPS_SETTINGS:()=>Ee,START_PATCH_BULK_GROUP_SETTINGS:()=>Te,START_UPDATE_GROUP:()=>ue,START_UPDATE_GROUP_SETTINGS:()=>ye,appendToQuery:()=>T,createGroup:()=>w,deleteGroup:()=>k,failedCreateGroup:()=>U,failedDeleteGroup:()=>D,failedFetchGroupsSettings:()=>K,failedPatchBulkGroupSettings:()=>Z,failedUpdateGroup:()=>A,failedUpdateGroupSettings:()=>v,fetchGroupsSettings:()=>x,finishCreateGroup:()=>R,finishDeleteGroup:()=>B,finishFetchGroupsSettings:()=>V,finishPatchBulkGroupSettings:()=>W,finishUpdateGroup:()=>F,finishUpdateGroupSettings:()=>H,groupNotFound:()=>b,patchBulkGroupSettings:()=>Y,path:()=>f,processItem:()=>I,query:()=>_,receiveGroup:()=>m,receiveGroupSettings:()=>C,receiveMatchables:()=>G,receiveQuery:()=>S,saveGroupSettingsAsBatch:()=>Q,saveGroups:()=>M,startCreateGroup:()=>P,startDeleteGroup:()=>N,startFetchGroupsSettings:()=>j,startPatchBulkGroupSettings:()=>J,startUpdateGroup:()=>O,startUpdateGroupSettings:()=>L,updateGroup:()=>q,updateGroupSettings:()=>$});var s={};r.r(s),r.d(s,{getGroup:()=>Be,getGroupAttribute:()=>Ce,getGroupSetting:()=>we,getGroupSettings:()=>He,getGroups:()=>Ae,getGroupsBySetting:()=>Me,getMatchableLabel:()=>Oe,getMatchableType:()=>Re,getMatchables:()=>Ue,getQueriedObjectIds:()=>Ne,getSettingDefinitions:()=>xe,isBulkPatchingSettings:()=>ke,isDeleting:()=>ve,isGroupNotFound:()=>De,isUpdating:()=>Le,isUpdatingSettings:()=>qe});var n={};r.r(n),r.d(n,{getGroup:()=>Ve,getGroupSettings:()=>Ye,getGroupsBySetting:()=>Je,getMatchables:()=>Ke});var u=r(48015),o=r(31600),d=r(87514),c=r.n(d),a=r(31511);function l(e){return{type:"API_FETCH",request:e}}const p={API_FETCH:({request:e})=>c()(e).catch(a.xJ)};var y=r(92819),g=r(19631),h=r.n(g),E=r(73470);const f="/ithemes-security/v1/user-groups";function*_(e,t){const r=yield l({path:(0,E.addQueryArgs)(f,t)});yield S(e,r);for(const e of r)yield*I(e);return r}function*T(e,t){yield{type:X,queryId:e,item:t},yield*I(t)}function S(e,t){return{type:z,queryId:e,items:t}}function*I(e){const t=(0,y.get)(e,["_embedded","ithemes-security:user-group-member"],[]),r=(0,y.get)(e,["_embedded","ithemes-security:user-matchable-settings",0]);for(const e of t)yield u.controls.dispatch("ithemes-security/core","receiveUser",e);r&&(yield C(e.id,r))}function m(e){return{type:se,group:e}}function b(e){return{type:ne,id:e}}function G(e){return{type:ee,matchables:e}}function P(e){return{type:te,group:e}}function U(e,t){return{type:ie,group:e,error:t}}function R(e,t){return{type:re,group:e,response:t}}function O(e,t){return{type:ue,id:e,group:t}}function A(e,t){return{type:de,id:e,error:t}}function F(e,t){return{type:oe,id:e,response:t}}function N(e){return{type:ce,id:e}}function D(e,t){return{type:le,id:e,error:t}}function B(e){return{type:ae,id:e}}function C(e,t){return{type:pe,id:e,settings:t}}function L(e,t){return{type:ye,id:e,settings:t}}function v(e,t){return{type:he,id:e,error:t}}function H(e,t){return{type:ge,id:e,response:t}}function*w(e){let t;yield P(e);try{t=yield l({path:(0,E.addQueryArgs)(f,{_embed:1}),method:"POST",data:e})}catch(t){return yield U(e,t),t}return yield R(e,t),yield m(t),yield*I(t),t}function*q(e,t){let r;yield O(e,t);try{r=yield l({path:f+"/"+e,method:"PUT",data:t})}catch(t){return yield A(e,t),t}return yield F(e,r),yield m(r),r}function*k(e){yield N(e);try{yield l({path:`${f}/${e}`,method:"DELETE"})}catch(t){return yield D(e,t),t}return yield B(e),null}function*M({create:e=[],update:t=[],delete:r=[]}){const i=[];for(const e of t)i.push({method:"PUT",path:`${f}/${e.id}`,body:e}),yield O(e.id);for(const t of e)i.push({method:"POST",path:f,body:t}),yield P(t);for(const e of r)i.push({method:"DELETE",path:`${f}/${e}`}),yield N(e);let s;const n={};try{s=yield(0,o.apiFetchBatch)(i)}catch(i){for(const e of t)yield A(e.id,i);for(const t of e)yield U(t,i);for(const e of r)yield D(e,i);return i}for(let e=0;e<i.length;e++){const t=i[e],r=t.body,u=s[e],o=r?.id||u.body?.id||t.path.replace(`${f}/`,"");o&&(n[o]=u),u.status>=400?"PUT"===t.method?yield A(o,u.body):"DELETE"===t.method?yield D(o,u.body):yield U(r,u.body):("PUT"===t.method?yield F(o,u.body):"DELETE"===t.method?yield B(o):yield R(r,u.body),yield m(r))}return{responses:s,byId:n}}function*$(e,t){let r;yield L(e,t);try{r=yield l({path:`ithemes-security/v1/user-matchable-settings/${e}`,method:"PUT",data:t})}catch(t){return yield v(e,t),t}return yield H(e,r),yield C(e,r),r}function*Q(e){const t=[],r=Object.keys(e);for(const i of r)t.push({method:"PUT",path:`/ithemes-security/v1/user-matchable-settings/${i}`,body:e[i]}),yield L(i,e[i]);let i;try{i=yield(0,o.apiFetchBatch)(t)}catch(e){for(const t of r)yield v(t,e);return e}const s={};for(let e=0;e<t.length;e++){const t=r[e],n=i[e];s[t]=n.body,n.status>=400?yield v(t,n.body):(yield H(t,n.body),yield C(t,n.body))}return{responses:i,byId:s}}function*x(e=[]){let t;yield j(e);try{let r="ithemes-security/v1/user-matchable-settings";e.length>0&&(r=(0,E.addQueryArgs)(r,{include:e})),t=yield l({path:r})}catch(t){return yield K(e,t),t}yield V(e,t);for(const e in t)t.hasOwnProperty(e)&&(yield C(e,t[e]));return t}function j(e){return{type:Ee,groupIds:e}}function V(e,t){return{type:fe,groupIds:e,response:t}}function K(e,t){return{type:_e,groupIds:e,error:t}}function*Y(e,t){let r;yield J(e,t);try{r=yield l({path:(0,E.addQueryArgs)("ithemes-security/v1/user-matchable-settings",{include:e}),method:"PATCH",data:t})}catch(r){return yield Z(e,t,r),r}yield W(e,t,r);const i=yield u.controls.resolveSelect("ithemes-security/core","getSchema","ithemes-security-user-group-settings"),s=(0,a.CO)(i,"self");if(!s)return r;const n=new(h())(s.href);for(const e of r){if(200!==e.status)continue;const t=n.fromUri(e.href);t.id&&(yield C(t.id,e.response))}return r}function J(e,t){return{type:Te,groupIds:e,patch:t}}function W(e,t,r){return{type:Se,groupIds:e,patch:t,response:r}}function Z(e,t,r){return{type:Ie,groupIds:e,patch:t,error:r}}const z="RECEIVE_QUERY",X="APPEND_TO_QUERY",ee="RECEIVE_MATCHABLES",te="START_CREATE_GROUP",re="FINISH_CREATE_GROUP",ie="FAILED_CREATE_GROUP",se="RECEIVE_GROUP",ne="GROUP_NOT_FOUND",ue="START_UPDATE_GROUP",oe="FINISH_UPDATE_GROUP",de="FAILED_UPDATE_GROUP",ce="START_DELETE_GROUP",ae="FINISH_DELETE_GROUP",le="FAILED_DELETE_GROUP",pe="RECEIVE_GROUP_SETTINGS",ye="START_UPDATE_GROUP_SETTINGS",ge="FINISH_UPDATE_GROUP_SETTINGS",he="FAILED_UPDATE_GROUP_SETTINGS",Ee="START_FETCH_GROUPS_SETTINGS",fe="FINISH_FETCH_GROUPS_SETTINGS",_e="FAILED_FETCH_GROUPS_SETTINGS",Te="START_PATCH_BULK_GROUP_SETTINGS",Se="FINISH_PATCH_BULK_GROUP_SETTINGS",Ie="FAILED_PATCH_BULK_GROUP_SETTINGS";var me=r(28306),be=r(59588),Ge=r.n(be);const Pe="ithemes-security/user-groups",Ue=(0,me.Z)((e=>(0,y.filter)((0,y.map)(e.matchableIds,(t=>e.matchablesById[t])),y.isObject)),(e=>[e.matchablesById,e.matchableIds]));function Re(e,t){return(e.matchablesById[t]||{}).type}function Oe(e,t){return(e.matchablesById[t]||{}).label}const Ae=(0,me.Z)(((e,t)=>(0,y.filter)((0,y.map)(e.queries[t],(t=>e.byId[t])),y.isObject)),((e,t)=>[e.queries[t],e.byId])),Fe=[];function Ne(e,t){return e.queries[t]||Fe}function De(e,t){return e.groupsNotFound.includes(t)}function Be(e,t){return e.byId[t]}const Ce=(0,u.createRegistrySelector)((e=>(t,r,i)=>{const s=e(Pe).getGroup(r);return s?s[i]:void 0}));function Le(e,t){return e.updating.includes(t)}function ve(e,t){return e.deleting.includes(t)}function He(e,t){return e.settings[t]}const we=(0,u.createRegistrySelector)((e=>(t,r,i,s)=>{const n=e(Pe).getGroupSettings(r);return(0,y.get)(n,[i,s])}));function qe(e,t){return e.updatingSettings.includes(t)}function ke(e,t,r){const i=t.join("_");return e.bulkPatchingSettings[i]===r}function Me(e){const t={};for(const r in e.settings)if(e.settings.hasOwnProperty(r))for(const i in e.settings[r])if(e.settings[r].hasOwnProperty(i))for(const s in e.settings[r][i])e.settings[r][i].hasOwnProperty(s)&&(t[i]||(t[i]={}),t[i][s]||(t[i][s]=[]),e.settings[r][i][s]&&t[i][s].push(r));return t}const $e=Ge()(((e,t,{skipConditions:r=!1},i,s,n)=>i.reduce(((u,o)=>{if("active"!==o.status.selected)return u;if(!(e=>!t.module||t.module===e.id)(o))return u;if("password-requirements"!==o.id&&(0,y.isEmpty)(o.user_groups))return u;const d=(0,y.pickBy)("password-requirements"===o.id?function(e){return Object.fromEntries(e.filter((e=>!(0,y.isEmpty)(e.password_requirements))).flatMap((e=>Object.entries(e.password_requirements).filter((([,e])=>e.hasOwnProperty("user-group"))).map((([t,r])=>[`requirement_settings.${t}.group`,{title:r.title||e.title,description:r.description||e.description}])))))}(i):o.user_groups,(t=>{if(!t.conditional||r)return!0;if(t.conditional["active-modules"])for(const e of t.conditional["active-modules"])if(!s.includes(e))return!1;return!(t.conditional.settings&&!e.compile(t.conditional.settings)(n[o.id]))}));return(0,y.isEmpty)(d)||u.push({id:o.id,title:o.title,description:o.description,settings:d}),u}),[])),{maxSize:1}),Qe={},xe=(0,u.createRegistrySelector)((e=>(t,r,i=Qe,s=Qe)=>$e(r,i,s,e(o.MODULES_STORE_NAME).getEditedModules(),e(o.MODULES_STORE_NAME).getActiveModules(),e(o.MODULES_STORE_NAME).__unstableGetAllEditedSettings()))),je={matchablesById:{},matchableIds:[],byId:{},groupsNotFound:[],queries:{},creating:[],updating:[],deleting:[],settings:{},updatingSettings:[],bulkPatchingSettings:{}},Ve={*fulfill(e){try{const t=yield l({path:`${f}/${e}?_embed=1`});yield m(t),yield*I(t)}catch(t){yield b(e)}},isFulfilled:(e,t)=>!!e.byId[t]},Ke={*fulfill(){const e=yield l({path:"/ithemes-security/v1/user-matchables?_embed=1"});for(const t of e){const e=(0,y.get)(t,["_embedded","self",0]),r=(0,y.get)(t,["_embedded","ithemes-security:user-matchable-settings",0]);e&&(yield m(e)),r&&(yield C(t.id,r))}yield G(e)},isFulfilled:e=>!(0,y.isEmpty)(e.matchablesById)},Ye={*fulfill(e){try{const t=yield l({path:`ithemes-security/v1/user-matchable-settings/${e}`});yield C(e,t)}catch(t){yield b(e)}},isFulfilled:(e,t)=>!!e.settings[t]},Je={*fulfill(){yield u.controls.resolveSelect(Pe,"getMatchables")},isFulfilled:e=>!(0,y.isEmpty)(e.matchablesById)},We=(0,u.createReduxStore)(Pe,{controls:{...o.controls,...p},actions:i,selectors:s,resolvers:n,reducer:function(e=je,t){switch(t.type){case ee:return{...e,matchableIds:(0,y.map)(t.matchables,"id"),matchablesById:(0,y.keyBy)(t.matchables,"id")};case z:return{...e,byId:{...e.byId,...(0,y.keyBy)(t.items,"id")},queries:{...e.queries,[t.queryId]:(0,y.map)(t.items,"id")}};case X:return{...e,byId:{...e.byId,[t.item.id]:t.item},queries:{...e.queries,[t.queryId]:[...e.queries[t.queryId]||[],t.item.id]}};case se:return{...e,byId:{...e.byId,[t.group.id]:t.group},matchablesById:e.matchablesById[t.group.id]?{...e.matchablesById,[t.group.id]:{...e.matchablesById[t.group.id],label:t.group.label}}:e.matchablesById};case ne:return{...e,groupsNotFound:e.groupsNotFound.includes(t.id)?e.groupsNotFound:[...e.groupsNotFound,t.id]};case te:return{...e,creating:[...e.creating,t.group]};case re:return{...e,creating:e.creating.filter((e=>e!==t.group)),matchablesById:{...e.matchablesById,[t.response.id]:{id:t.response.id,label:t.response.label,type:"user-group"}},matchableIds:[...e.matchableIds,[t.response.id]]};case ie:return{...e,creating:e.creating.filter((e=>e!==t.group))};case ue:return{...e,updating:[...e.updating,t.id]};case oe:case de:return{...e,updating:e.updating.filter((e=>e!==t.id))};case ce:return{...e,deleting:[...e.deleting,t.id]};case ae:return{...e,deleting:e.deleting.filter((e=>e!==t.id)),byId:(0,y.omit)(e.byId,[t.id]),matchablesById:(0,y.omit)(e.matchablesById,[t.id]),matchableIds:e.matchableIds.filter((e=>e!==t.id)),settings:(0,y.omit)(e.settings,[t.id])};case le:return{...e,deleting:e.deleting.filter((e=>e!==t.id))};case pe:return{...e,settings:{...e.settings,[t.id]:t.settings}};case ye:return{...e,updatingSettings:[...e.updatingSettings,t.id]};case ge:case he:return{...e,updatingSettings:e.updatingSettings.filter((e=>e!==t.id))};case Te:return{...e,bulkPatchingSettings:{...e.bulkPatchingSettings,[t.groupIds.join("_")]:t.patch}};case Se:case Ie:return{...e,bulkPatchingSettings:(0,y.omit)(e.bulkPatchingSettings,[t.groupIds.join("_")])};default:return e}}});(0,u.register)(We);const Ze=We;r.p=window.itsecWebpackPublicPath},31600:e=>{e.exports=function(){return this.itsec.packages.data}()},87514:e=>{e.exports=function(){return this.wp.apiFetch}()},48015:e=>{e.exports=function(){return this.wp.data}()},6293:e=>{e.exports=function(){return this.wp.element}()},95122:e=>{e.exports=function(){return this.wp.i18n}()},73470:e=>{e.exports=function(){return this.wp.url}()},92819:e=>{"use strict";e.exports=window.lodash}},e=>{e.O(0,[5307,2388,1511],(()=>(62352,e(e.s=62352))));var t=e.O();((window.itsec=window.itsec||{})["user-groups"]=window.itsec["user-groups"]||{}).api=t}]);