import{ensureArrayQueryFilter as e}from"../ensureArrayQueryFilter.mjs";import{getFiltersAndPaginationFromBody as t}from"./getFiltersAndPaginationFromBody.mjs";const n=(n,r)=>{let{filters:i,...a}=t(n),{roles:o,project:s}=r?.locals||n.locals||{},c={},l={updatedAt:-1},{key:u,search:d,keys:f,tags:p,location:m,priority:h,ids:g,projectId:_,projectIds:v,userId:y,userIds:b,creatorId:x,creatorIds:S,title:C,description:w,version:T,sortBy:E,sortOrder:D,fetchAll:O}=i??{};if(g&&(c={...c,_id:{$in:e(g)}}),_&&(c={...c,projectIds:_}),v&&(c={...c,projectIds:{$in:e(v)}}),o.includes(`admin`)&&O===`true`||(c={...c,projectIds:{$in:s?.id}}),y&&(c={...c,creatorId:y}),b&&(c={...c,creatorId:{$in:e(b)}}),x&&(c={...c,creatorId:x}),S&&(c={...c,creatorId:{$in:e(S)}}),C&&(c={...c,title:new RegExp(C,`i`)}),w&&(c={...c,description:new RegExp(w,`i`)}),u&&(c={...c,key:new RegExp(u,`i`)}),d){let e=new RegExp(d,`i`);c={...c,$or:[{key:e},{title:e},{description:e},{tags:e}]}}return f&&(c={...c,key:{$in:e(f)}}),p&&(c={...c,tags:{$in:e(p)}}),m===`local`&&(c={...c,_id:null}),h&&(c={...c,priority:Number(h)}),T&&(c={...c,[`content.${T}`]:{$exists:!0}}),E&&D&&(D===`asc`||D===`desc`)&&(l={[E]:D===`asc`?1:-1}),{filters:c,sortOptions:l,...a}};export{n as getDictionaryFiltersAndPagination};
//# sourceMappingURL=getDictionaryFiltersAndPagination.mjs.map