@communecter/cocolight-api-client 1.0.27 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import e from"bson-objectid";import t from"file-type";import{EventEmitter as n}from"events";import{AggregateAjvError as r}from"@segment/ajv-human-errors";import o from"ajv";import i from"ajv-formats";import a from"axios";import s from"axios-retry";import c from"ejson";import{jwtDecode as u}from"jwt-decode";import p from"pino";import l from"fs";import d from"os";import f from"path";function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function y(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){h(i,r,o,a,s,"next",e)}function s(e){h(i,r,o,a,s,"throw",e)}a(void 0)}))}}function v(e,t,n){return t=T(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,A()?Reflect.construct(t,n||[],T(e).constructor):t.apply(e,n))}function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,L(r.key),r)}}function k(e,t,n){return t&&g(e.prototype,t),n&&g(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=M(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function x(e,t,n){return(t=L(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(){return _="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=T(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},_.apply(null,arguments)}function T(e){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},T(e)}function E(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&I(e,t)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(A=function(){return!!e})()}function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function S(){S=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function p(e,t,n,r){var i=t&&t.prototype instanceof v?t:v,a=Object.create(i.prototype),s=new j(r||[]);return o(a,"_invoke",{value:A(e,n,s)}),a}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=p;var d="suspendedStart",f="suspendedYield",m="executing",h="completed",y={};function v(){}function w(){}function g(){}var k={};u(k,a,(function(){return this}));var b=Object.getPrototypeOf,x=b&&b(b(C([])));x&&x!==n&&r.call(x,a)&&(k=x);var _=g.prototype=v.prototype=Object.create(k);function T(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(o,i,a,s){var c=l(e[o],e,i);if("throw"!==c.type){var u=c.arg,p=u.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(p).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=d;return function(i,a){if(o===m)throw Error("Generator is already running");if(o===h){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var c=P(s,r);if(c){if(c===y)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===d)throw o=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=m;var u=l(t,n,r);if("normal"===u.type){if(o=r.done?h:f,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=h,r.method="throw",r.arg=u.arg)}}}function P(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=l(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function C(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return w.prototype=g,o(_,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:w,configurable:!0}),w.displayName=u(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,u(e,c,"GeneratorFunction")),e.prototype=Object.create(_),e},t.awrap=function(e){return{__await:e}},T(E.prototype),u(E.prototype,s,(function(){return this})),t.AsyncIterator=E,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new E(p(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(_),u(_,c,"Generator"),u(_,a,(function(){return this})),u(_,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=C,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return s.type="throw",s.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),I(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;I(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:C(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function I(e,t){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},I(e,t)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}(e,t)||M(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(e,t,n,r){var o=_(T(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof o?function(e){return o.apply(n,e)}:o}function D(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||M(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function N(e){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N(e)}function M(e,t){if(e){if("string"==typeof e)return m(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(e,t):void 0}}function q(e){var t="function"==typeof Map?new Map:void 0;return q=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(A())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&I(o,n.prototype),o}(e,arguments,T(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),I(n,e)},q(e)}var R=function(){function e(t,n,r){var o;return w(this,e),(o=v(this,e,[t])).name="ApiError",o.status=n,o.details=r,o}return E(e,q(Error)),k(e)}(),B=function(){function e(t,n,r){var o;return w(this,e),(o=v(this,e,[t,n,r])).name="ApiClientError",o}return E(e,R),k(e)}(),z=function(){function e(t,n,r){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return w(this,e),(o=v(this,e,[t])).name="ApiValidationError",o.status=n,o.messages=r,o.details=i,o}return E(e,q(Error)),k(e)}(),F=function(){function e(t){var n;return w(this,e),(n=v(this,e,[t,503])).name="CircuitBreakerError",n}return E(e,R),k(e)}(),U=function(){function e(t,n,r){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return w(this,e),(o=v(this,e,[t])).name="ApiResponseError",o.status=n,o.responseData=r,o.details=i,o}return E(e,q(Error)),k(e)}(),$=function(){function e(t,n,r){var o;return w(this,e),(o=v(this,e,[t,n,r])).name="ApiAuthenticationError",o}return E(e,R),k(e)}(),G=Object.freeze({__proto__:null,ApiAuthenticationError:$,ApiClientError:B,ApiError:R,ApiResponseError:U,ApiValidationError:z,CircuitBreakerError:F}),V=[],K=new WeakMap,Z=new WeakMap;function J(e){var t=function(){try{V.push(t),e()}finally{V.pop()}};return t(),t}function W(e){var t=e,n=new Set;return{get value(){var e=V[V.length-1];return e&&n.add(e),t},set value(e){t!==e&&(t=e,n.forEach((function(e){return e()})))},subscribe:function(e){return n.add(e),function(){return n.delete(e)}},__isSignal:!0}}function H(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if("object"!==N(e)||null===e)return e;if(Array.isArray(e))return function(e,t){return new Proxy(e,{get:function(e,n){if("string"==typeof n&&!isNaN(n)){var r=e[n];return Y(r)?r:Q(r,t.concat(n))}return Reflect.get(e,n)},set:function(e,n,r){var o=Q(r,t.concat(n));return e[n]=o,!0}})}(e,t);if(e.__isReactive)return e;var n=new Map,r=new Proxy(e,{get:function(e,r,o){if("__raw"===r)return e;if("__isReactive"===r)return!0;if(!n.has(r)){var i=W(H(e[r],t.concat(r)));n.set(r,i)}return n.get(r).value},set:function(e,r,o){var i=H(o,t.concat(r));if(!n.has(r)){var a=W(i);n.set(r,a)}return n.get(r).value=i,e[r]=function(e){return function(e){return e&&!0===e.__isSignal}(e)?e.value:e}(i),!0},deleteProperty:function(e,t){return n.delete(t),Reflect.deleteProperty(e,t)}});return Z.set(r,n),r}function Q(e){return"object"!==N(e)||null===e||e.__isReactive?e:H(e)}function Y(e){return!(null==e||!e.__isReactive)}function X(e,t){return t.split(".").reduce((function(e,t){return e?e[t]:void 0}),e)}function ee(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).cleanIfEqual,o=void 0===r||r,i=b(n);try{var a=function(){var n=t.value;J((function(){var t=X(e.serverData,n),r=function(e,t,n){var r,o=e.split(".")[0],i=null===(r=n.transforms)||void 0===r?void 0:r[o];return"function"==typeof i?i(t,n.serverData):t}(n,t,e),i=X(e.draftData,n),a=X(e.initialDraftData,n);JSON.stringify(i)!==JSON.stringify(a)||(o&&JSON.stringify(i)===JSON.stringify(r)?function(e,t){var n=t.split("."),r=n.pop(),o=n.reduce((function(e,t){return null==e?void 0:e[t]}),e);o&&r in o&&delete o[r]}(e.draftData,n):function(e,t,n){var r=t.split("."),o=r.pop();r.reduce((function(e,t){return null==e[t]&&(e[t]={}),e[t]}),e)[o]=n}(e.draftData,n,r))}))};for(i.s();!(t=i.n()).done;)a()}catch(e){i.e(e)}finally{i.f()}}function te(e){var t,n,r={allOf:[],$defs:{}},o=b(Array.isArray(e.constructor.SCHEMA_CONSTANTS)?e.constructor.SCHEMA_CONSTANTS:[e.constructor.SCHEMA_CONSTANTS]);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=e.apiClient.getRequestSchema(i);if(!a)throw new R("Unable to find schema for ".concat(i,"."));if(a.$defs)for(var s=0,c=Object.entries(a.$defs);s<c.length;s++){var u=j(c[s],2),p=u[0],l=u[1];r.$defs[p]||(r.$defs[p]=l)}r.allOf.push(a)}}catch(e){o.e(e)}finally{o.f()}var d=O(O({},e.serverData),e.defaultFields),f=(null===(t=e._extractWritableFields)||void 0===t?void 0:t.call(e,r,d))||[];f=(f=f.filter((function(t){return!e.removeFields.includes(t)}))).filter((function(e){return!["id"].includes(e)})),ee(e,f)}var ne=Object.freeze({__proto__:null,autoSyncDraftFromSchema:te,computed:function(e){if(K.has(e))return K.get(e);var t=W();return J((function(){return t.value=e()})),K.set(e,t),t},effect:J,getSignals:function(e){return Y(e)?Z.get(e):null},isReactive:Y,reactive:Q,syncDraftOnServerChange:ee,watch:function(e,t){var n;J((function(){var r=e();r!==n&&(t(r,n),n=r)}))}}),re=t.fromBuffer,oe=function(){return k((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(w(this,e),x(this,"_draftData",{}),x(this,"_initialDraftData",{}),x(this,"_serverData",null),x(this,"_calledFromSave",!1),x(this,"_syncReactiveDraft",!1),x(this,"defaultFields",{}),x(this,"removeFields",[]),x(this,"transforms",{}),this.__entityTag=o.entityTag||this.constructor.name||"BaseEntity",this.deps=r,"ApiClient"===(null==t?void 0:t.__entityTag))this.apiClient=t,this.parent=null,this.userContext=null;else{if(null==t||!t.apiClient)throw new R("Parent invalide ou ApiClient manquant.");this.apiClient=t.apiClient,this.parent=t,"User"===(null==t?void 0:t.__entityTag)?this.userContext=t:null!=t&&t.userContext&&(this.userContext=t.userContext)}if("function"==typeof r.EndpointApi)this.endpointApi=new r.EndpointApi(this.apiClient);else{if("object"!==N(r.EndpointApi))throw new R("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=r.EndpointApi}this._serverData=null;var i=this._buildDraftAndProxy({data:O(O({},n),this.defaultFields),serverData:this._serverData,constant:this.constructor.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields}),a=i.draft,s=i.proxy;this._initialDraftData=JSON.parse(JSON.stringify(a)),this._draftData=a,this.data=s}),[{key:"id",get:function(){return this._draftData.id||null}},{key:"slug",get:function(){return this._draftData.slug||null}},{key:"_id",value:function(e){this._draftData.id=e}},{key:"isConnected",get:function(){return this.apiClient.isConnected}},{key:"userId",get:function(){return this.apiClient.userId}},{key:"draftData",get:function(){return this._draftData}},{key:"initialDraftData",get:function(){return this._initialDraftData}},{key:"serverData",get:function(){return this._serverData}},{key:"isMe",get:function(){var e;return this.isConnected&&this.userId===(null===(e=this.userContext)||void 0===e?void 0:e.id)}},{key:"getEntityType",value:function(){return this.constructor.entityType}},{key:"hasChanges",value:function(){return JSON.stringify(this._draftData)!==JSON.stringify(this._initialDraftData)}},{key:"refresh",value:(ue=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.id){e.next=2;break}throw new R("Impossible de rafraîchir sans ID.");case 2:return e.abrupt("return",this.get());case 3:case"end":return e.stop()}}),e,this)}))),function(){return ue.apply(this,arguments)})},{key:"save",value:(ce=y(S().mark((function e(){var t;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=2;break}throw new R("Non connecté.");case 2:if(this._calledFromSave=!0,e.prev=3,t=O({},this._draftData),this.id||"function"!=typeof this._add){e.next=16;break}return e.next=8,this._add(t);case 8:if(!this.userContext){e.next=11;break}return e.next=11,this.userContext.refresh();case 11:return e.next=13,this.refresh();case 13:case 23:return e.abrupt("return",e.sent);case 16:if("function"!=typeof this._update){e.next=24;break}return e.next=19,this._update(t);case 19:if(!e.sent){e.next=24;break}return e.next=23,this.refresh();case 24:return e.abrupt("return",this._serverData);case 25:return e.prev=25,this._calledFromSave=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[3,,25,28]])}))),function(){return ce.apply(this,arguments)})},{key:"_setData",value:function(e){var t,n;this.userContext&&this.userContext!==this&&(null===(t=this.apiClient._logger)||void 0===t||null===(n=t.info)||void 0===n||n.call(t,"[".concat(this.__entityTag,"] Mise à jour liée à userContext : ").concat(this.userContext.id)));this._serverData=Q(O({},e));var r=this._buildDraftAndProxy({data:O(O({},e),this.defaultFields),serverData:this._serverData,constant:this.constructor.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields}),o=r.draft,i=r.proxy;this._initialDraftData=JSON.parse(JSON.stringify(o)),this._draftData=o,this.data=i,this._syncReactiveDraft&&this.setupReactiveSync()}},{key:"call",value:(se=y(S().mark((function e(t){var n,r=this,o=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:{},e.abrupt("return",this.apiClient.safeCall(y(S().mark((function e(){var o;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.apiClient.callEndpoint(t,n);case 2:return o=e.sent,r.apiClient.checkAndThrowApiResponseError(o),e.abrupt("return",o.data);case 5:case"end":return e.stop()}}),e)})))));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return se.apply(this,arguments)})},{key:"callNoConnected",value:(ae=y(S().mark((function e(t){var n,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:{},!this.isConnected){e.next=3;break}throw new $("Vous devez ne devez pas être connecté pour faire cette action.");case 3:return e.abrupt("return",this.call(t,n));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ae.apply(this,arguments)})},{key:"callIsConnected",value:(ie=y(S().mark((function e(t){var n,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:{},this.isConnected){e.next=3;break}throw new $("Vous devez être connecté pour faire cette action.");case 3:if("function"!=typeof t){e.next=7;break}return e.next=6,t();case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return",this.call(t,n));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return ie.apply(this,arguments)})},{key:"callIsMe",value:(oe=y(S().mark((function e(t){var n,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:{},this.isMe){e.next=3;break}throw new $("Vous devez être vous-même pour faire cette action.");case 3:if("function"!=typeof t){e.next=7;break}return e.next=6,t();case 6:case 9:return e.abrupt("return",e.sent);case 7:return e.next=9,this.callIsConnected(t,n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return oe.apply(this,arguments)})},{key:"_validateImage",value:(ne=y(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._validateUploadInput(t,{allowedMimeTypes:["image/jpeg","image/png","image/jpg"],expectedType:"image"});case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ne.apply(this,arguments)})},{key:"_validateFile",value:(ee=y(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._validateUploadInput(t,{allowedMimeTypes:["application/pdf","text/plain","text/csv"],expectedType:"file"});case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return ee.apply(this,arguments)})},{key:"_validateUploadInput",value:(X=y(S().mark((function e(t,n){var r,o,i,a,s,c,u,p,l,d,f,m,h,y,v,w,g,k;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.allowedMimeTypes,o=void 0===r?[]:r,i=n.expectedType,a=void 0===i?"any":i,t){e.next=3;break}throw new z("Le fichier est requis.");case 3:if(s="undefined"==typeof window&&"undefined"!=typeof process,c="",u=t,!("undefined"!=typeof File&&t instanceof File)){e.next=12;break}if(c=t.type,o.includes(c)){e.next=10;break}throw new z("Le type du fichier est invalide.");case 10:e.next=63;break;case 12:if(!("undefined"!=typeof Blob&&t instanceof Blob)){e.next=21;break}if(c=t.type,o.includes(c)){e.next=16;break}throw new z("Le type du fichier est invalide.");case 16:p=c.split("/")[1]||"bin",l="".concat(Date.now(),".").concat(p),u=new File([t],l,{type:c}),e.next=63;break;case 21:if(!s||!Buffer.isBuffer(t)){e.next=36;break}return e.next=24,re(t);case 24:if(d=e.sent,c=null==d?void 0:d.mime,d&&o.includes(c)){e.next=28;break}throw new z("Le type du fichier est invalide.");case 28:if("image"!==a){e.next=34;break}return f=d.ext,m="".concat(Date.now(),".").concat(f),e.next=33,this._createReadStreamFromBuffer(t,m,c);case 33:u=e.sent;case 34:e.next=63;break;case 36:if(!s||null==t||!t.readable||"function"!=typeof t._read){e.next=62;break}return h=[],e.next=40,this._passThrough();case 40:return y=e.sent,e.next=43,this._passThrough();case 43:return v=e.sent,w=0,t.on("data",(function(e){w<4100&&(h.push(e),w+=e.length)})),t.pipe(y).pipe(v),e.next=50,new Promise((function(e){return setTimeout(e,10)}));case 50:return g=Buffer.concat(h),e.next=53,re(g);case 53:if(k=e.sent,c=null==k?void 0:k.mime,k&&o.includes(c)){e.next=57;break}throw new z("Le type du fichier est invalide.");case 57:v.path="".concat(Date.now(),".").concat(k.ext),v.mimeType=c,u=v,e.next=63;break;case 62:throw new z("Type de fichier non reconnu.");case 63:return e.abrupt("return",u);case 64:case"end":return e.stop()}}),e,this)}))),function(e,t){return X.apply(this,arguments)})},{key:"_createReadStreamFromBuffer",value:(Y=y(S().mark((function e(t){var n,r,o,i=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:"file.bin",r=i.length>2&&void 0!==i[2]?i[2]:"application/octet-stream",e.next=4,this._bufferToReadable(t);case 4:return(o=e.sent).path=n,o.mimeType=r,e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"_bufferToReadable",value:(H=y(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof window){e.next=8;break}return e.next=3,Promise.resolve().then((function(){return Me}));case 3:return n=e.sent,r=n.bufferToReadable,e.abrupt("return",r(t));case 8:throw new Error("bufferToReadable ne doit pas être appelé dans le navigateur");case 9:case"end":return e.stop()}}),e)}))),function(e){return H.apply(this,arguments)})},{key:"_passThrough",value:(W=y(S().mark((function e(){var t,n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof window){e.next=8;break}return e.next=3,Promise.resolve().then((function(){return Me}));case 3:return t=e.sent,n=t.createPassThrough,e.abrupt("return",n());case 8:throw new Error("passThrough ne doit pas être appelé dans le navigateur");case 9:case"end":return e.stop()}}),e)}))),function(){return W.apply(this,arguments)})},{key:"_omitProps",value:function(e,t){if(!e||"object"!==N(e))return{};var n,r=O({},e),o=b(t);try{for(o.s();!(n=o.n()).done;){delete r[n.value]}}catch(e){o.e(e)}finally{o.f()}return r}},{key:"_pickProps",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||"object"!==N(e))return{};var r,o={},i=b(t);try{for(i.s();!(r=i.n()).done;){var a=r.value;if(a in e){var s=e[a];"function"==typeof n[a]?o[a]=n[a](s,e):o[a]=s}}}catch(e){i.e(e)}finally{i.f()}return o}},{key:"_hasAtLeastOne",value:function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).some((function(t){return t in e&&null!=e[t]}))}},{key:"_createFilteredProxy",value:function(e){return new Proxy(e,{get:function(e,t,n){return"string"!=typeof t||isNaN(t)?"length"===t?e.filter((function(e){return!e._isDeleted})).length:"function"==typeof e[t]?function(){var n;return(n=e.filter((function(e){return!e._isDeleted})))[t].apply(n,arguments)}:Reflect.get(e,t,n):e.filter((function(e){return!e._isDeleted}))[t]}})}},{key:"_newId",value:function(){return(new e).toString()}},{key:"_createDraftProxy",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};return new Proxy({},{get:function(e,r){var i=r in n?n[r]:t[r],a=o[r];return"function"==typeof a?a(i):i},set:function(t,o,a){if(!r.includes(o)){var s='[DraftProxy] Le champ "'.concat(o,"\" n'est pas autorisé.");if(i.throwOnError)throw new z(s,400,null,{field:o,value:a,allowedFields:r});return e._logger.warn(s),!1}return n[o]=a,!0},deleteProperty:function(e,t){return!!r.includes(t)&&(delete n[t],!0)},has:function(e,r){return r in n||r in t},ownKeys:function(){return D(new Set([].concat(D(Object.keys(t)),D(Object.keys(n)))))},getOwnPropertyDescriptor:function(){return{enumerable:!0,configurable:!0}}})}},{key:"_extractWritableFields",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{defs:{},visited:new Set};if(!t||"object"!==N(t))return[];if(t.$id&&r.visited.has(t.$id))return[];t.$id&&r.visited.add(t.$id),r.defs=t.$defs||t.definitions||r.defs;var o=[];if(t.$ref){var i,a=t.$ref.replace(/^#\/?(\$defs|definitions)\//,""),s=null===(i=r.defs)||void 0===i?void 0:i[a];s&&o.push.apply(o,D(this._extractWritableFields(s,n,r)))}if(t.allOf&&t.allOf.forEach((function(t){return o.push.apply(o,D(e._extractWritableFields(t,n,r)))})),t.if&&t.then){var c,u=null===(c=t.if)||void 0===c?void 0:c.properties,p=!0;if(u)for(var l in u){var d,f=null===(d=u[l])||void 0===d?void 0:d.const;if(n[l]!==f){p=!1;break}}p&&t.then?o.push.apply(o,D(this._extractWritableFields(t.then,n,r))):!p&&t.else&&o.push.apply(o,D(this._extractWritableFields(t.else,n,r)))}return t.properties&&o.push.apply(o,D(Object.entries(t.properties).filter((function(e){var t=j(e,2);t[0];var n=t[1];return!0!==n.readOnly&&void 0===n.const})).map((function(e){return j(e,1)[0]})))),D(new Set(o))}},{key:"_buildDraftAndProxy",value:function(e){var t,n=e.data,r=void 0===n?{}:n,o=e.serverData,i=void 0===o?null:o,a=e.constant,s=e.apiClient,c=e.transforms,u=void 0===c?{}:c,p=e.throwOnError,l=void 0===p||p,d=e.removeFields,f=void 0===d?[]:d,m={allOf:[],$defs:{}},h=b(Array.isArray(a)?a:[a]);try{for(h.s();!(t=h.n()).done;){var y=t.value,v=s.getRequestSchema(y);if(!v)throw new R("Unable to find schema for ".concat(y,"."));if(v.$defs)for(var w=0,g=Object.entries(v.$defs);w<g.length;w++){var k=j(g[w],2),x=k[0],_=k[1];m.$defs[x]?s._logger.warn("Duplicate $defs key '".concat(x,"' from schema '").concat(y,"'")):m.$defs[x]=_}m.allOf.push(v)}}catch(e){h.e(e)}finally{h.f()}var T={},E=this._extractWritableFields(m,r);r.id&&-1===E.indexOf("id")&&E.push("id"),r.slug&&-1===E.indexOf("slug")&&E.push("slug");var A,P=b(E=E.filter((function(e){return!f.includes(e)})));try{for(P.s();!(A=P.n()).done;){var O=A.value,S=r[O],I="function"==typeof u[O]?u[O](S,r):S;void 0!==I&&(T[O]=I)}}catch(e){P.e(e)}finally{P.f()}return{draft:T,proxy:this._createDraftProxy(s,i,T,E,u,{throwOnError:l})}}},{key:"_extractChangedFieldsFromSchema",value:function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],a=e.getRequestSchema(t),s=this._extractWritableFields(a,r),c={},u=(null==o?void 0:o())||{},p=b(s=s.filter((function(e){return!i.includes(e)})));try{for(p.s();!(n=p.n()).done;){var l=n.value;if(void 0!==r[l]){var d=r[l],f=u[l];JSON.stringify(d)!==JSON.stringify(f)&&(c[l]=d)}}}catch(e){p.e(e)}finally{p.f()}return Object.keys(c).length>0?c:null}},{key:"setupReactiveSync",value:function(){this._syncReactiveDraft||(this._syncReactiveDraft=!0),te(this)}},{key:"_resolveId",value:(J=y(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.id||!this.slug){e.next=23;break}return e.prev=1,e.next=4,this.endpointApi.getElementsKey({pathParams:{slug:this.slug}});case 4:if(null==(n=e.sent)||!n.contextId||(null==n?void 0:n.contextType)!==t){e.next=9;break}this._id(n.contextId),e.next=10;break;case 9:throw new U("Le slug ".concat(this.slug," ne correspond pas à un ").concat(t),200,n);case 10:case 20:e.next=23;break;case 12:if(e.prev=12,e.t0=e.catch(1),!(e.t0 instanceof U)){e.next=22;break}if((null===e.t0||void 0===e.t0||null===(r=e.t0.responseData)||void 0===r?void 0:r.contextType)===t){e.next=19;break}throw e.t0;case 19:throw new U("Impossible de récupérer l'identifiant pour le slug ".concat(this.slug),e.t0.status,e.t0.responseData);case 22:throw e.t0;case 23:return e.abrupt("return",this.id);case 24:case"end":return e.stop()}}),e,this,[[1,12]])}))),function(e){return J.apply(this,arguments)})},{key:"_getPublicProfile",value:(Z=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._resolveId(this.getEntityType());case 2:return e.abrupt("return",this.endpointApi.getElementsAbout({pathParams:{id:this.id,type:this.getEntityType()}}));case 3:case"end":return e.stop()}}),e,this)}))),function(){return Z.apply(this,arguments)})},{key:"_getEntityMeta",value:function(e){var t=this.constructor,n=this.__entityTag,r={EndpointApi:this.deps.EndpointApi,User:"User"===n?t:this.deps.User,Organization:"Organization"===n?t:this.deps.Organization,Project:"Project"===n?t:this.deps.Project,Event:"Event"===n?t:this.deps.Event,Poi:"Poi"===n?t:this.deps.Poi,Badge:"Badge"===n?t:this.deps.Badge,News:"News"===n?t:this.deps.News};return{citoyens:{entityClass:r.User,deps:r},organizations:{entityClass:r.Organization,deps:r},projects:{entityClass:r.Project,deps:r},events:{entityClass:r.Event,deps:O(O({},r),{},{Badge:void 0})},poi:{entityClass:r.Poi,deps:O(O({},r),{},{Badge:void 0,News:void 0})},news:{entityClass:r.News,deps:O({},r)},badges:{entityClass:r.Badge,deps:{EndpointApi:r.EndpointApi,User:r.User,Organization:r.Organization,Project:r.Project}}}[e]||null}},{key:"_linkEntity",value:function(e,t){var n=this._getEntityMeta(e);return n?n.entityClass.fromServerData(t,this,n.deps):t}},{key:"_linkEntityById",value:(K=y(S().mark((function e(t,n){var r,o,i,a=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.length>2&&void 0!==a[2]?a[2]:{},o=this._getEntityMeta(t)){e.next=4;break}return e.abrupt("return",null);case 4:if(i=new o.entityClass(this,{id:n},o.deps),null==r||!r.skipGet){e.next=7;break}return e.abrupt("return",i);case 7:return e.next=9,i.get();case 9:return e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return K.apply(this,arguments)})},{key:"_linkEntities",value:function(e){var t=this;return e.map((function(e){var n,r;return null!==(n=null===(r=t._linkEntity)||void 0===r?void 0:r.call(t,e.collection,e))&&void 0!==n?n:e}))}},{key:"linkEntitiesFromServerData",value:(V=y(S().mark((function e(t){var n,r,o,i,a,s,c,u,p,l,d,f,m=this,h=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=h.length>1&&void 0!==h[1]?h[1]:{},i=(o=h.length>2&&void 0!==h[2]?h[2]:{}).key||t,a="function"==typeof o.mapFn?o.mapFn:null,s=function(e){return!0===e||"true"===e},c=function(e){return!1===e||"false"===e},u=null===(n=this.serverData)||void 0===n?void 0:n[i],p=[],!(u&&"object"===N(u)&&Object.keys(u).length>0)){e.next=18;break}l=S().mark((function e(){var n,o,i,l,h,y;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=f[d],o=u[n],i=Object.entries(r).every((function(e){var t=j(e,2),n=t[0],r=t[1],i=o[n];if("function"==typeof r)try{return r(i)}catch(e){return console.warn("Erreur dans le filtre personnalisé pour ".concat(n),e),!1}return r instanceof RegExp?"string"==typeof i&&r.test(i):"string"==typeof r&&"string"==typeof i?i.toLowerCase().includes(r.toLowerCase()):s(r)?s(i):c(r)?c(i):"string"!=typeof i||"string"!=typeof r||isNaN(Date.parse(i))||isNaN(Date.parse(r))?i===r:new Date(i).getTime()===new Date(r).getTime()})),i){e.next=5;break}return e.abrupt("return",1);case 5:return e.prev=5,e.next=8,m._linkEntityById(t,n);case 8:(l=e.sent)&&(l.meta=o,p.push(a?a(l):l)),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(5),null===(h=m._logger)||void 0===h||null===(y=h.error)||void 0===y||y.call(h,"Erreur lors de la récupération de l'entité ".concat(t," (").concat(n,") :"),e.t0);case 15:case"end":return e.stop()}}),e,null,[[5,12]])})),d=0,f=Object.keys(u);case 11:if(!(d<f.length)){e.next=18;break}return e.delegateYield(l(),"t0",13);case 13:if(!e.t0){e.next=15;break}return e.abrupt("continue",15);case 15:d++,e.next=11;break;case 18:return e.abrupt("return",p);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return V.apply(this,arguments)})},{key:"_entityInstanceData",value:function(e,t){var n=this._getEntityMeta(e),r=this.__entityTag,o=this.constructor;return new n.entityClass(this,t,O(x({},r,o),n.deps))}},{key:"entity",value:(G=y(S().mark((function e(t){var n,r,o,i=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=i.length>1&&void 0!==i[1]?i[1]:{},e.prev=1,r=this._entityInstanceData(t,n),!(o={citoyens:["id","slug"],organizations:["id","slug"],projects:["id","slug"],events:["id","slug"],poi:["id","slug"],news:["id"],badges:["id"]}[t])||!this._hasAtLeastOne(n,o)){e.next=8;break}return e.next=8,r.get();case 8:return e.abrupt("return",r);case 11:throw e.prev=11,e.t0=e.catch(1),this.apiClient._logger.error("[Api.".concat(this.__entityTag,".").concat(t,"] Erreur lors de la création d'une instance ").concat(t," :"),e.t0.message),e.t0;case 15:case"end":return e.stop()}}),e,this,[[1,11]])}))),function(e){return G.apply(this,arguments)})},{key:"_buildLinkFilters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.linkType,r=t.isAdmin,o=t.isAdminPending,i=t.isInviting,a=t.toBeValidated,s=void 0!==a&&a,c=t.roles,u=void 0===c?[]:c;if("string"!=typeof e)throw new TypeError("id doit être une chaîne.");if("string"!=typeof n)throw new TypeError("linkType doit être une chaîne.");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError("isAdmin doit être un booléen.");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("isAdminPending doit être un booléen.");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("isInviting doit être un booléen.");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("toBeValidated doit être un booléen.");if(!Array.isArray(u))throw new TypeError("roles doit être un tableau de chaînes.");var p="links.".concat(n,".").concat(e),l=x({},"".concat(p),{$exists:!0});return"boolean"==typeof s&&(l["".concat(p,".toBeValidated")]={$exists:s}),"boolean"==typeof i&&(l["".concat(p,".isInviting")]={$exists:i}),!0===r&&(l["".concat(p,".isAdmin")]={$exists:!0}),!0===o&&(l["".concat(p,".isAdminPending")]={$exists:!0}),u.length>0&&(l["".concat(p,".roles")]={$in:u}),l}},{key:"_getLinkMeta",value:function(){var e=this.getEntityType(),t={organizations:{linkType:"memberOf",connectTypeConnect:"member",connectTypeDisconnect:"members"},projects:{linkType:"projects",connectTypeConnect:"contributor",connectTypeDisconnect:"contributors"},events:{linkType:"events",connectTypeConnect:"attendee",connectTypeDisconnect:"attendees"},citoyens:{linkType:"friends",connectTypeConnect:"friend",connectTypeDisconnect:"friends"}}[e];if(!t)throw new R("Aucune correspondance de lien définie pour le type d'entité \"".concat(e,'"'));return t}},{key:"_checkLinkableEntity",value:function(){try{this._getLinkMeta()}catch(e){if(e instanceof R)throw new R("L'entité \"".concat(this.getEntityType(),'" ne prend pas en charge les actions de lien.'));throw e}}},{key:"_getLinkFromConnectedUser",value:function(){var e,t=this._getLinkMeta().linkType;return(null==this||null===(e=this.userContext)||void 0===e||null===(e=e.serverData)||void 0===e||null===(e=e.links)||void 0===e||null===(e=e[t])||void 0===e?void 0:e[this.id])||null}},{key:"_submitLinkRequest",value:(F=y(S().mark((function e(){var t,n,r,o,i,a=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.id){e.next=2;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 2:if(t=this._getLinkMeta(),n=t.connectTypeConnect,r=this._getLinkFromConnectedUser()){e.next=12;break}return o={parentType:this.getEntityType(),parentId:this.id,connectType:n},e.next=8,this.callIsMe((function(){return a.endpointApi.connect(o)}));case 8:return i=e.sent,e.next=11,this.userContext.refresh();case 11:return e.abrupt("return",i);case 12:if(!r.isInviting){e.next=14;break}return e.abrupt("return",this._acceptLinkRequest());case 14:if(!r.toBeValidated){e.next=16;break}throw new R("Vous êtes déjà en attente de validation.");case 16:throw new R("Vous êtes déjà connecté à cette entité.");case 17:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"_submitLinkRequestAdmin",value:(B=y(S().mark((function e(){var t,n,r,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.id){e.next=2;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 2:if(t=this._getLinkFromConnectedUser()){e.next=11;break}return n={parentType:this.getEntityType(),parentId:this.id,connectType:"admin"},e.next=7,this.callIsMe((function(){return o.endpointApi.connect(n)}));case 7:return r=e.sent,e.next=10,this.userContext.refresh();case 10:return e.abrupt("return",r);case 11:if(!t.isInviting){e.next=13;break}return e.abrupt("return",this._acceptLinkRequest());case 13:if(!t.toBeValidated||!t.isAdminPending){e.next=15;break}throw new R("Vous êtes déjà en attente de validation pour devenir admin.");case 15:if(!t.toBeValidated){e.next=17;break}throw new R("Vous êtes déjà en attente de validation pour rejoindre cette entité.");case 17:throw new R("Vous êtes déjà connecté à cette entité.");case 18:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"_acceptLinkRequest",value:(q=y(S().mark((function e(){var t,n,r=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.id){e.next=2;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 2:if(!this._getLinkFromConnectedUser().isInviting){e.next=11;break}return t={parentType:this.getEntityType(),parentId:this.id,linkOption:"isInviting"},e.next=7,this.callIsMe((function(){return r.endpointApi.linkValidate(t)}));case 7:return n=e.sent,e.next=10,this.userContext.refresh();case 10:return e.abrupt("return",n);case 11:throw new R("Vous n'avez pas d'invitation à valider.");case 12:case"end":return e.stop()}}),e,this)}))),function(){return q.apply(this,arguments)})},{key:"_leaveLinkRequest",value:(M=y(S().mark((function e(){var t,n,r,o,i=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.id){e.next=2;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 2:if(t=this._getLinkMeta(),n=t.connectTypeDisconnect,this._getLinkFromConnectedUser()){e.next=6;break}throw new R("Vous n'êtes pas connecté à cette entité.");case 6:return r={parentType:this.getEntityType(),parentId:this.id,connectType:n},e.next=9,this.callIsMe((function(){return i.endpointApi.disconnect(r)}));case 9:return o=e.sent,e.next=12,this.userContext.refresh();case 12:return e.abrupt("return",o);case 13:case"end":return e.stop()}}),e,this)}))),function(){return M.apply(this,arguments)})},{key:"get",value:function(){var e=y(S().mark((function e(){var t=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.apiClient.safeCall(y(S().mark((function e(){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._getPublicProfile();case 2:return n=e.sent,t._setData(n),e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"updateSettings",value:(L=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=r.length>0&&void 0!==r[0]?r[0]:{}).idEntity=this.id,t.typeEntity=this.getEntityType(),e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.updateSettings(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return L.apply(this,arguments)})},{key:"updateDescription",value:(C=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=r.length>0&&void 0!==r[0]?r[0]:{}).typeElement=this.getEntityType(),t.id=this.id,e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.updateBlockDescription(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return C.apply(this,arguments)})},{key:"updateInfo",value:(I=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=r.length>0&&void 0!==r[0]?r[0]:{}).typeElement=this.getEntityType(),t.id=this.id,e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.updateBlockInfo(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"updateSocial",value:(P=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=r.length>0&&void 0!==r[0]?r[0]:{}).typeElement=this.getEntityType(),t.id=this.id,e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.updateBlockSocial(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"updateLocality",value:(A=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=r.length>0&&void 0!==r[0]?r[0]:{}).typeElement=this.getEntityType(),t.id=this.id,e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.updateBlockLocality(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return A.apply(this,arguments)})},{key:"updateSlug",value:(E=y(S().mark((function e(t){var n,r=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.slug,e.prev=1,e.next=4,this.endpointApi.check({type:this.getEntityType(),id:this.id,slug:n});case 4:e.next=11;break;case 6:if(e.prev=6,e.t0=e.catch(1),!(e.t0 instanceof U)){e.next=10;break}throw new U("Erreur lors de la vérification du slug.",e.t0.status,e.t0.data);case 10:throw e.t0;case 11:return e.abrupt("return",this.callIsConnected((function(){return r.endpointApi.updateBlockSlug({typeElement:r.getEntityType(),id:r.id,slug:n})})));case 12:case"end":return e.stop()}}),e,this,[[1,6]])}))),function(e){return E.apply(this,arguments)})},{key:"updateImageProfil",value:(T=y(S().mark((function e(t){var n,r,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.profil_avatar,e.next=3,this._validateImage(n);case 3:return n=e.sent,r={pathParams:{folder:this.getEntityType(),ownerId:this.id},profil_avatar:n},e.abrupt("return",this.callIsConnected((function(){return o.endpointApi.profilImage(r)})));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"organization",value:(_=y(S().mark((function e(){var t,n=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},this.isMe){e.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour créer une organisation.");case 3:return e.abrupt("return",this.entity("organizations",t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"project",value:(g=y(S().mark((function e(){var t,n=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},this.isConnected){e.next=3;break}throw new R("Vous devez être connecté pour créer un projet.");case 3:return e.abrupt("return",this.entity("projects",t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"poi",value:(v=y(S().mark((function e(){var t,n=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},this.isConnected){e.next=3;break}throw new R("Vous devez être connecté pour créer un POI.");case 3:return e.abrupt("return",this.entity("poi",t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"event",value:(h=y(S().mark((function e(){var t,n=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},this.isConnected){e.next=3;break}throw new R("Vous devez être connecté pour créer un événement.");case 3:return e.abrupt("return",this.entity("events",t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"badge",value:(m=y(S().mark((function e(){var t,n=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},this.isConnected){e.next=3;break}throw new R("Vous devez être connecté pour créer un badge.");case 3:return e.abrupt("return",this.entity("badges",t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"news",value:(f=y(S().mark((function e(){var t,n=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},this.isConnected){e.next=3;break}throw new R("Vous devez être connecté.");case 3:return e.abrupt("return",this.entity("news",t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getOrganizations",value:(d=y(S().mark((function e(){var t,n,r,o,i,a,s=this,c=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>0&&void 0!==c[0]?c[0]:{},this.isMe?n.pathParams={type:this.getEntityType(),id:this.id}:(null==n||delete n.pathParams,n.filters=x(x(x({},"links.members.".concat(this.id),{$exists:!0}),"links.members.".concat(this.id,".toBeValidated"),{$exists:!1}),"links.members.".concat(this.id,".isInviting"),{$exists:!1})),r=this.isMe?function(){return s.callIsMe((function(){return s.endpointApi.getOrganizationsAdmin(n)}))}:function(){return s.endpointApi.getOrganizationsNoAdmin(n)},e.next=5,r();case 5:if(o=e.sent,Array.isArray(o.results)){e.next=8;break}throw new U("Erreur lors de la récupération des organisations.",500,o.results);case 8:return null==o||null===(t=o.count)||void 0===t||delete t.spam,i=Object.values(o.count||{}).reduce((function(e,t){return e+t}),0),o.count.total=i,a=this._linkEntities(o.results),e.abrupt("return",{count:o.count,results:a});case 13:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getProjects",value:(l=y(S().mark((function e(){var t,n,r,o,i,a,s=this,c=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=c.length>0&&void 0!==c[0]?c[0]:{},this.isMe?r.pathParams={type:this.getEntityType(),id:this.id}:(null==r||delete r.pathParams,r.filters=x({$or:x(x({},"links.contributors.".concat(this.id),{$exists:!0}),"parent.".concat(this.id),{$exists:!0})},"links.contributors.".concat(this.id),{$exists:!0})),o=this.isMe?function(){return s.callIsMe((function(){return s.endpointApi.getProjectsAdmin(r)}))}:function(){return s.endpointApi.getProjectsNoAdmin(r)},e.next=5,o();case 5:if(i=e.sent,Array.isArray(i.results)){e.next=8;break}throw new U("Erreur lors de la récupération des projets.",500,i.results);case 8:return a=this._linkEntities(i.results),e.abrupt("return",{count:null!==(t=null==i||null===(n=i.count)||void 0===n?void 0:n.projects)&&void 0!==t?t:0,results:a});case 10:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getPois",value:(p=y(S().mark((function e(){var t,n,r,o,i,a,s=this,c=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=c.length>0&&void 0!==c[0]?c[0]:{},this.isMe?r.pathParams={type:this.getEntityType(),id:this.id}:(null==r||delete r.pathParams,r.filters=x({},"parent.".concat(this.id),{$exists:!0})),o=this.isMe?function(){return s.callIsMe((function(){return s.endpointApi.getPoisAdmin(r)}))}:function(){return s.endpointApi.getPoisNoAdmin(r)},e.next=5,o();case 5:if(i=e.sent,Array.isArray(i.results)){e.next=8;break}throw new U("Erreur lors de la récupération des POIs.",500,i.results);case 8:return a=this._linkEntities(i.results),e.abrupt("return",{count:null!==(t=null===(n=i.count)||void 0===n?void 0:n.poi)&&void 0!==t?t:0,results:a});case 10:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"getSubscribers",value:(u=y(S().mark((function e(){var t,n,r,o=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==(t=o.length>0&&void 0!==o[0]?o[0]:{})||delete t.pathParams,t.filters=x(x(x({},"links.follows.".concat(this.id),{$exists:!0}),"links.follows.".concat(this.id,".toBeValidated"),{$exists:!1}),"links.follows.".concat(this.id,".isInviting"),{$exists:!1}),e.next=5,this.endpointApi.getSubscribers(t);case 5:if(n=e.sent,Array.isArray(n.results)){e.next=8;break}throw new U("Erreur lors de la récupération des abonnés.",500,n.results);case 8:return r=this._linkEntities(n.results),e.abrupt("return",{count:n.count,results:r});case 10:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getBadgesIssuer",value:(c=y(S().mark((function e(){var t,n,r,o,i,a=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==(r=a.length>0&&void 0!==a[0]?a[0]:{})||delete r.pathParams,r.filters=r.filters||{},r.filters.$or={},r.filters.$or["issuer.".concat(this.id)]={$exists:!0},e.next=7,this.endpointApi.getBadges(r);case 7:if(o=e.sent,Array.isArray(o.results)){e.next=10;break}throw new U("Erreur lors de la récupération des badges.",500,o.results);case 10:return i=this._linkEntities(o.results),e.abrupt("return",{count:null!==(t=null===(n=o.count)||void 0===n?void 0:n.badges)&&void 0!==t?t:0,results:i});case 12:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getNews",value:(s=y(S().mark((function e(){var t,n,r,o=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=o.length>0&&void 0!==o[0]?o[0]:{}).pathParams={type:this.getEntityType(),id:this.id},e.next=4,this.endpointApi.getNews(t);case 4:if(n=e.sent,Array.isArray(n)){e.next=7;break}throw new U("Erreur lors de la récupération des actualités.",500,n);case 7:return r=this._linkEntities(n),e.abrupt("return",this._createFilteredProxy(r));case 9:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"requestToJoin",value:(a=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMe){e.next=2;break}throw new R("Vous devez être connecté pour envoyer une demande de participation.");case 2:return this._checkLinkableEntity(),e.abrupt("return",this._submitLinkRequest());case 4:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"requestToJoinAdmin",value:(i=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMe){e.next=2;break}throw new R("Vous devez être connecté pour envoyer une demande de participation.");case 2:return this._checkLinkableEntity(),e.abrupt("return",this._submitLinkRequestAdmin());case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"acceptInvitation",value:(o=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMe){e.next=2;break}throw new R("Vous devez être connecté pour envoyer une demande de participation.");case 2:return this._checkLinkableEntity(),e.abrupt("return",this._acceptLinkRequest());case 4:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"leave",value:(r=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMe){e.next=2;break}throw new R("Vous devez être connecté pour envoyer une demande de participation.");case 2:return this._checkLinkableEntity(),e.abrupt("return",this._leaveLinkRequest());case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"follow",value:(n=y(S().mark((function e(){var t,n,r,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMe){e.next=2;break}throw new R("Vous devez être connecté pour suivre cette entité.");case 2:if(this.id){e.next=4;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 4:if(null===(t=this.userContext)||void 0===t||null===(t=t.serverData)||void 0===t||null===(t=t.links)||void 0===t||null===(t=t.follows)||void 0===t?void 0:t[this.id]){e.next=13;break}return n={parentType:this.getEntityType(),parentId:this.id},e.next=9,this.callIsMe((function(){return o.endpointApi.follow(n)}));case 9:return r=e.sent,e.next=12,this.userContext.refresh();case 12:return e.abrupt("return",r);case 13:throw new R("Vous êtes déjà abonné à cette entité.");case 14:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"unfollow",value:(t=y(S().mark((function e(){var t,n,r,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMe){e.next=2;break}throw new R("Vous devez être connecté pour vous désabonner.");case 2:if(this.id){e.next=4;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 4:if(!(null===(t=this.userContext)||void 0===t||null===(t=t.serverData)||void 0===t||null===(t=t.links)||void 0===t||null===(t=t.follows)||void 0===t?void 0:t[this.id])){e.next=13;break}return n={parentType:this.getEntityType(),parentId:this.id,connectType:"followers"},e.next=9,this.callIsMe((function(){return o.endpointApi.disconnect(n)}));case 9:return r=e.sent,e.next=12,this.userContext.refresh();case 12:return e.abrupt("return",r);case 13:throw new R("Vous n'êtes pas abonné à cette entité.");case 14:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_checkAccess",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"effectuer cette action";if(!this.isMe)throw new R("Vous devez être connecté pour ".concat(e));if(!this.id)throw new R("".concat(this.constructor.name," non enregistrée."))}},{key:"_validateUserLink",value:function(e){if(!e)return!1;var t=e.toBeValidated,n=e.isInviting;return!t&&!n}},{key:"_assertEntityType",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Array.isArray(t[0])?t[0]:t;if(!r.includes(this.getEntityType()))throw new R("L'entité doit être de type : ".concat(r.join(", "),", reçu : ").concat(this.getEntityType()))}},{key:"_isLinked",value:function(e){var t;return!(null===(t=this.userContext)||void 0===t||null===(t=t.serverData)||void 0===t||null===(t=t.links)||void 0===t||null===(t=t[e])||void 0===t||!t[this.id])}},{key:"isAuthor",value:function(){var e;if(this._checkAccess("vérifier l'auteur"),!this.serverData)throw new R("Aucune donnée serveur disponible.");return this.userId&&(null===(e=this.serverData)||void 0===e?void 0:e.creator)===this.userId}},{key:"isAdmin",value:function(){this._checkAccess("vérifier l'administrateur."),this._assertEntityType("organizations","projects","events");var e=this._getLinkFromConnectedUser();return this._validateUserLink(e)&&!0===(null==e?void 0:e.isAdmin)&&!(null!=e&&e.isAdminPending)}},{key:"isAuthorOrAdmin",value:function(){return this._checkAccess("vérifier l'auteur ou l'administrateur."),this.isAuthor()||this.isAdmin()}},{key:"isMember",value:function(){this._checkAccess("vérifier le membre."),this._assertEntityType("organizations");var e=this._getLinkFromConnectedUser();return this._validateUserLink(e)}},{key:"isContributor",value:function(){this._checkAccess("vérifier le contributeur."),this._assertEntityType("projects");var e=this._getLinkFromConnectedUser();return this._validateUserLink(e)}},{key:"isAttendee",value:function(){this._checkAccess("vérifier si vous êtes un participant."),this._assertEntityType("events");var e=this._getLinkFromConnectedUser();return this._validateUserLink(e)}},{key:"isFollower",value:function(){return this._checkAccess("vérifier si il vous suit."),this._assertEntityType("citoyens","organizations","projects","events","poi"),this._isLinked("followers")}},{key:"isFollowing",value:function(){return this._checkAccess("vérifier si vous le suivez."),this._assertEntityType("citoyens","organizations","projects","events","poi"),this._isLinked("follows")}}],[{key:"fromServerData",value:function(e,t,n){var r=new this(t,{},n);return r._setData(e),r}}]);var t,n,r,o,i,a,s,c,u,p,l,d,f,m,h,v,g,_,T,E,A,P,I,C,L,M,q,B,F,G,V,K,Z,J,W,H,Y,X,ee,ne,oe,ie,ae,se,ce,ue}(),ie=function(){function e(){var t;w(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return x(t=v(this,e,[].concat(r)),"defaultFields",{}),x(t,"removeFields",[]),x(t,"transforms",{}),t}return E(e,oe),k(e,[{key:"_add",value:(m=y(S().mark((function t(n){var r,o,i,a,s,c,u,p,l;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._calledFromSave){t.next=2;break}throw new R("utilisation invalide de _add, utilisez save");case 2:n.id=null===(r=this._newId)||void 0===r?void 0:r.call(this),n.slug&&delete n.slug,o=b(e.ADD_BLOCKS),t.prev=5,o.s();case 7:if((i=o.n()).done){t.next=17;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){})))&&Object.keys(u).length>0)){t.next=15;break}return t.next=13,this[c](u);case 13:l=t.sent,!this.id&&null!=l&&null!==(p=l.map)&&void 0!==p&&p.id&&(this._draftData.id=l.map.id,this._draftData.slug=l.map.slug);case 15:t.next=7;break;case 17:t.next=22;break;case 19:t.prev=19,t.t0=t.catch(5),o.e(t.t0);case 22:return t.prev=22,o.f(),t.finish(22);case 25:case"end":return t.stop()}}),t,this,[[5,19,22,25]])}))),function(e){return m.apply(this,arguments)})},{key:"_update",value:(f=y(S().mark((function t(n){var r,o,i,a,s,c,u,p=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._calledFromSave){t.next=2;break}throw new R("utilisation invalide de _update, utilisez save");case 2:n.id&&delete n.id,r=!1,o=b(e.UPDATE_BLOCKS),t.prev=5,o.s();case 7:if((i=o.n()).done){t.next=16;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){return p.initialDraftData}),this.removeFields))&&Object.keys(u).length>0)){t.next=14;break}return t.next=13,this[c](u);case 13:r=!0;case 14:t.next=7;break;case 16:t.next=21;break;case 18:t.prev=18,t.t0=t.catch(5),o.e(t.t0);case 21:return t.prev=21,o.f(),t.finish(21);case 24:return t.abrupt("return",r);case 25:case"end":return t.stop()}}),t,this,[[5,18,21,24]])}))),function(e){return f.apply(this,arguments)})},{key:"getOrganizations",value:(d=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getOrganizations n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getProjects",value:(l=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getProjects n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getEvents",value:(p=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getEvents n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"getPois",value:(u=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getPois n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getBadgesIssuer",value:(c=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getBadgesIssuer n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getNews",value:(s=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getNews n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getSubscribers",value:(a=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getSubscribers n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"project",value:(i=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("project n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"poi",value:(o=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("poi n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"event",value:(r=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("event n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"badge",value:(n=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("badge n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"news",value:(t=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("news n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]);var t,n,r,o,i,a,s,c,u,p,l,d,f,m}();x(ie,"entityType","badges"),x(ie,"SCHEMA_CONSTANTS",["ADD_BADGES"]),x(ie,"ADD_BLOCKS",new Map([["ADD_BADGES","addBadges"]])),x(ie,"UPDATE_BLOCKS",new Map([]));var ae=function(){return k((function e(t){w(this,e),this.apiClient=t}),[{key:"isConnected",get:function(){return this.apiClient.isConnected}},{key:"userId",get:function(){return this.apiClient.userId}},{key:"call",value:(Be=y(S().mark((function e(t){var n,r=this,o=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:{},e.abrupt("return",this.apiClient.safeCall(y(S().mark((function e(){var o;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.apiClient.callEndpoint(t,n);case 2:return o=e.sent,r.apiClient.checkAndThrowApiResponseError(o),e.abrupt("return",o.data);case 5:case"end":return e.stop()}}),e)})))));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return Be.apply(this,arguments)})},{key:"callNoConnected",value:(Re=y(S().mark((function e(t){var n,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:{},!this.isConnected){e.next=3;break}throw new $("Vous ne devez pas être connecté pour faire cette action.");case 3:return e.abrupt("return",this.call(t,n));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return Re.apply(this,arguments)})},{key:"callIsConnected",value:(qe=y(S().mark((function e(t){var n,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]?r[1]:{},this.isConnected){e.next=3;break}throw new $("Vous devez être connecté pour effectuer cette action.");case 3:return e.abrupt("return",this.call(t,n));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return qe.apply(this,arguments)})},{key:"personRegister",value:(Me=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callNoConnected("PERSON_REGISTER",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Me.apply(this,arguments)})},{key:"authenticateUrl",value:(Ne=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callNoConnected("AUTHENTICATE_URL",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Ne.apply(this,arguments)})},{key:"refreshTokenUrl",value:(Le=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("REFRESH_TOKEN_URL",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Le.apply(this,arguments)})},{key:"meInfoUrl",value:(De=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.callIsConnected("ME_INFO_URL"));case 1:case"end":return e.stop()}}),e,this)}))),function(){return De.apply(this,arguments)})},{key:"passwordRecovery",value:(Ce=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callNoConnected("PASSWORD_RECOVERY",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Ce.apply(this,arguments)})},{key:"serverExchangeToken",value:(je=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("SERVER_EXCHANGE_TOKEN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return je.apply(this,arguments)})},{key:"changePassword",value:(Ie=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("CHANGE_PASSWORD",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Ie.apply(this,arguments)})},{key:"deleteAccount",value:(Se=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("DELETE_ACCOUNT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Se.apply(this,arguments)})},{key:"updateSettings",value:(Oe=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("UPDATE_SETTINGS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Oe.apply(this,arguments)})},{key:"updateBlockDescription",value:(Pe=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("UPDATE_BLOCK_DESCRIPTION",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Pe.apply(this,arguments)})},{key:"updateBlockInfo",value:(Ae=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("UPDATE_BLOCK_INFO",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Ae.apply(this,arguments)})},{key:"updateBlockSocial",value:(Ee=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("UPDATE_BLOCK_SOCIAL",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Ee.apply(this,arguments)})},{key:"updateBlockLocality",value:(Te=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("UPDATE_BLOCK_LOCALITY",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Te.apply(this,arguments)})},{key:"updateBlockSlug",value:(_e=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("UPDATE_BLOCK_SLUG",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return _e.apply(this,arguments)})},{key:"check",value:(xe=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("CHECK",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return xe.apply(this,arguments)})},{key:"profilImage",value:(be=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("PROFIL_IMAGE",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return be.apply(this,arguments)})},{key:"getElementsAbout",value:(ke=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_ELEMENTS_ABOUT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ke.apply(this,arguments)})},{key:"multiconnect",value:(ge=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("MULTICONNECT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ge.apply(this,arguments)})},{key:"getNews",value:(we=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_NEWS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return we.apply(this,arguments)})},{key:"getNewsById",value:(ve=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_NEWS_BY_ID",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ve.apply(this,arguments)})},{key:"addNews",value:(ye=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_NEWS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ye.apply(this,arguments)})},{key:"addImageNews",value:(he=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_IMAGE_NEWS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"addFileNews",value:(me=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_FILE_NEWS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return me.apply(this,arguments)})},{key:"deleteNews",value:(fe=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("DELETE_NEWS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return fe.apply(this,arguments)})},{key:"updateNews",value:(de=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("UPDATE_NEWS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return de.apply(this,arguments)})},{key:"shareNews",value:(le=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("SHARE_NEWS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return le.apply(this,arguments)})},{key:"getComments",value:(pe=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_COMMENTS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return pe.apply(this,arguments)})},{key:"addComments",value:(ue=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_COMMENTS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ue.apply(this,arguments)})},{key:"deleteComments",value:(ce=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("DELETE_COMMENTS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ce.apply(this,arguments)})},{key:"updateComments",value:(se=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("UPDATE_COMMENTS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return se.apply(this,arguments)})},{key:"searchTags",value:(ae=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("SEARCH_TAGS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ae.apply(this,arguments)})},{key:"showVote",value:(ie=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("SHOW_VOTE",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ie.apply(this,arguments)})},{key:"globalAutocomplete",value:(oe=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GLOBAL_AUTOCOMPLETE",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return oe.apply(this,arguments)})},{key:"cityAutocomplete",value:(re=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("CITY_AUTOCOMPLETE",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return re.apply(this,arguments)})},{key:"suggestionInput",value:(ne=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("SUGGESTION_INPUT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ne.apply(this,arguments)})},{key:"getProjectsNoAdmin",value:(te=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_PROJECTS_NO_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return te.apply(this,arguments)})},{key:"getProjectsAdmin",value:(ee=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_PROJECTS_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return ee.apply(this,arguments)})},{key:"getPoisNoAdmin",value:(X=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_POIS_NO_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"getPoisAdmin",value:(Y=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_POIS_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"getOrganizationsNoAdmin",value:(Q=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_ORGANIZATIONS_NO_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Q.apply(this,arguments)})},{key:"getOrganizationsAdmin",value:(H=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_ORGANIZATIONS_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return H.apply(this,arguments)})},{key:"getMembersNoAdmin",value:(W=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_MEMBERS_NO_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"getMembersAdmin",value:(J=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_MEMBERS_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return J.apply(this,arguments)})},{key:"getFriendsAdmin",value:(Z=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_FRIENDS_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return Z.apply(this,arguments)})},{key:"getSubscriptions",value:(K=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_SUBSCRIPTIONS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"getSubscriptionsAdmin",value:(V=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_SUBSCRIPTIONS_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return V.apply(this,arguments)})},{key:"getSubscribers",value:(G=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_SUBSCRIBERS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"getSubscribersAdmin",value:(U=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_SUBSCRIBERS_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"getContributorsNoAdmin",value:(F=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_CONTRIBUTORS_NO_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return F.apply(this,arguments)})},{key:"getContributorsAdmin",value:(z=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_CONTRIBUTORS_ADMIN",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return z.apply(this,arguments)})},{key:"getBadges",value:(B=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_BADGES",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"getBadgesFilters",value:(R=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_BADGES_FILTERS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return R.apply(this,arguments)})},{key:"connect",value:(q=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("CONNECT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"disconnect",value:(M=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("DISCONNECT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"getElementsKey",value:(L=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_ELEMENTS_KEY",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"getFavoris",value:(D=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_FAVORIS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return D.apply(this,arguments)})},{key:"deleteFavoris",value:(C=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("DELETE_FAVORIS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"addFavoris",value:(j=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_FAVORIS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"addOrganization",value:(I=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_ORGANIZATION",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"addProject",value:(O=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_PROJECT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"addPoi",value:(P=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_POI",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return P.apply(this,arguments)})},{key:"addEvent",value:(A=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_EVENT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return A.apply(this,arguments)})},{key:"deletePoi",value:(E=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("DELETE_POI",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"deleteEvent",value:(T=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("DELETE_EVENT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"deleteElement",value:(_=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("DELETE_ELEMENT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"addImageElement",value:(x=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_IMAGE_ELEMENT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"linkValidate",value:(b=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("LINK_VALIDATE",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"searchMemberAutocomplete",value:(g=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("SEARCH_MEMBER_AUTOCOMPLETE",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"getNotifications",value:(v=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_NOTIFICATIONS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"getNotificationsCount",value:(h=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("GET_NOTIFICATIONS_COUNT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"notificationUpdate",value:(m=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("NOTIFICATION_UPDATE",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"removeAllNotifications",value:(f=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.callIsConnected("REMOVE_ALL_NOTIFICATIONS"));case 1:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"markNotificationAsRead",value:(d=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("MARK_NOTIFICATION_AS_READ",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"activitypubSearch",value:(l=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("ACTIVITYPUB_SEARCH",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"activitypubLink",value:(p=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ACTIVITYPUB_LINK",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"activitypubGetCommunity",value:(u=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("ACTIVITYPUB_GET_COMMUNITY",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getBadge",value:(c=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_BADGE",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"getEmetteurBadges",value:(s=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.call("GET_EMETTEUR_BADGES"));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"addBadges",value:(a=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ADD_BADGES",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"assignBadges",value:(i=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("ASSIGN_BADGES",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getEvents",value:(o=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_EVENTS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"shareEvents",value:(r=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("SHARE_EVENTS",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"inviteEvent",value:(n=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("INVITE_EVENT",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"follow",value:(t=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.callIsConnected("FOLLOW",t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getCostumJson",value:(e=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&"object"===N(t)){e.next=2;break}throw new TypeError("Le paramètre data doit être un objet.");case 2:return e.abrupt("return",this.call("GET_COSTUM_JSON",t));case 3:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,o,i,a,s,c,u,p,l,d,f,m,h,v,g,b,x,_,T,E,A,P,O,I,j,C,D,L,M,q,R,B,z,F,U,G,V,K,Z,J,W,H,Q,Y,X,ee,te,ne,re,oe,ie,ae,se,ce,ue,pe,le,de,fe,me,he,ye,ve,we,ge,ke,be,xe,_e,Te,Ee,Ae,Pe,Oe,Se,Ie,je,Ce,De,Le,Ne,Me,qe,Re,Be}(),se=function(){function e(){var t;w(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return x(t=v(this,e,[].concat(r)),"defaultFields",{}),x(t,"removeFields",["typeElement"]),x(t,"transforms",{}),t}return E(e,oe),k(e,[{key:"_add",value:(g=y(S().mark((function t(n){var r,o,i,a,s,c,u,p,l;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._calledFromSave){t.next=2;break}throw new R("utilisation invalide de _add, utilisez save");case 2:n.id=null===(r=this._newId)||void 0===r?void 0:r.call(this),n.slug&&delete n.slug,o=b(e.ADD_BLOCKS),t.prev=5,o.s();case 7:if((i=o.n()).done){t.next=17;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){})))&&Object.keys(u).length>0)){t.next=15;break}return t.next=13,this[c](u);case 13:l=t.sent,!this.id&&null!=l&&null!==(p=l.map)&&void 0!==p&&p.id&&(this._draftData.id=l.map.id,this._draftData.slug=l.map.slug);case 15:t.next=7;break;case 17:t.next=22;break;case 19:t.prev=19,t.t0=t.catch(5),o.e(t.t0);case 22:return t.prev=22,o.f(),t.finish(22);case 25:case"end":return t.stop()}}),t,this,[[5,19,22,25]])}))),function(e){return g.apply(this,arguments)})},{key:"_update",value:(h=y(S().mark((function t(n){var r,o,i,a,s,c,u,p=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.isAdmin()){t.next=2;break}throw new R("Vous n'avez pas les droits pour modifier cet événement",403);case 2:if(this._calledFromSave){t.next=4;break}throw new R("utilisation invalide de _update, utilisez save");case 4:n.id&&delete n.id,r=!1,o=b(e.UPDATE_BLOCKS),t.prev=7,o.s();case 9:if((i=o.n()).done){t.next=18;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){return p.initialDraftData}),this.removeFields))&&Object.keys(u).length>0)){t.next=16;break}return t.next=15,this[c](u);case 15:r=!0;case 16:t.next=9;break;case 18:t.next=23;break;case 20:t.prev=20,t.t0=t.catch(7),o.e(t.t0);case 23:return t.prev=23,o.f(),t.finish(23);case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),t,this,[[7,20,23,26]])}))),function(e){return h.apply(this,arguments)})},{key:"getOrganizations",value:(m=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getOrganizations n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"getProjects",value:(f=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getProjects n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getEvents",value:(d=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getEvents - les sous-events ne sont pas encore implémentés dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getPois",value:(l=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getPois n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getBadgesIssuer",value:(p=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getBadgesIssuer n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"getNews",value:(u=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getNews",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"getSubscribers",value:(c=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getSubscribers",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"project",value:(s=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("project n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"poi",value:(a=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("poi n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"event",value:(i=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("les sous-events ne sont pas encore implémentés dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"badge",value:(o=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("badge n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"news",value:(r=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"news",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"follow",value:(n=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"follow",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"unfollow",value:(t=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"unfollow",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})}]);var t,n,r,o,i,a,s,c,u,p,l,d,f,m,h,g}();x(se,"entityType","events"),x(se,"SCHEMA_CONSTANTS",["ADD_EVENT"]),x(se,"ADD_BLOCKS",new Map([["ADD_EVENT","addEvent"]])),x(se,"UPDATE_BLOCKS",new Map([]));var ce=function(){function e(){var t;w(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return x(t=v(this,e,[].concat(r)),"defaultFields",{}),x(t,"removeFields",[]),x(t,"transforms",{scope:function(e){return null==e?void 0:e.type},mentions:function(e){return Array.isArray(e)?e.map((function(e){return O(O({},e),{},{count:parseInt(e.count)})})):[]},mediaImg:function(e){var t,n=(null==e||null===(t=e.images)||void 0===t?void 0:t.map((function(e){return e.id})).filter(Boolean))||[];return n.length>0?{countImages:n.length,images:n}:void 0},mediaFile:function(e){var t,n=(null==e||null===(t=e.files)||void 0===t?void 0:t.map((function(e){return e.id})).filter(Boolean))||[];return n.length>0?{countFiles:n.length,files:n}:void 0}}),t}return E(e,oe),k(e,[{key:"get",value:function(){var e=y(S().mark((function e(){var t,n,r=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.id){e.next=2;break}throw new R("Impossible de rafraîchir sans ID.");case 2:return e.next=4,this.callIsConnected((function(){return r.endpointApi.getNewsById({ids:[r.id]})}));case 4:if(!(t=e.sent)||!Array.isArray(t)||1!==t.length){e.next=9;break}return n=t[0],this._setData(n),e.abrupt("return",this.serverData);case 9:throw new R("Aucune actualité trouvée pour l'ID ".concat(this.id));case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"_add",value:(c=y(S().mark((function t(n){var r,o,i,a,s,c,u,p;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._calledFromSave){t.next=2;break}throw new Error("utilisation invalide de _add, utilisez save");case 2:""===n.text&&(n.text=" "),n.parentId=this.parent.id,n.parentType=this.parent.getEntityType(),r=b(e.ADD_BLOCKS),t.prev=6,r.s();case 8:if((o=r.n()).done){t.next=18;break}if(i=j(o.value,2),a=i[0],s=i[1],!((c=this._extractChangedFieldsFromSchema(this.apiClient,a,O(O({},n),this.defaultFields),(function(){})))&&Object.keys(c).length>0)){t.next=16;break}return t.next=14,this[s](c);case 14:p=t.sent,!this.id&&null!=p&&null!==(u=p.object)&&void 0!==u&&u.id&&(this._draftData.id=p.object.id);case 16:t.next=8;break;case 18:t.next=23;break;case 20:t.prev=20,t.t0=t.catch(6),r.e(t.t0);case 23:return t.prev=23,r.f(),t.finish(23);case 26:case"end":return t.stop()}}),t,this,[[6,20,23,26]])}))),function(e){return c.apply(this,arguments)})},{key:"_update",value:(s=y(S().mark((function e(t){var n,r,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._calledFromSave){e.next=2;break}throw new Error("utilisation invalide de _update, utilisez save");case 2:return t.id&&delete t.id,""===(null==t?void 0:t.text)&&(t.text=" "),t.parentId=this.parent.id,t.parentType=this.parent.getEntityType(),t.idNews=this.id,n=!1,e.next=10,this.callIsConnected((function(){return o.endpointApi.updateNews(t)}));case 10:return null!=(r=e.sent)&&r.object&&(this._serverData=O({},r.object)),n=!0,e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"addNews",value:(a=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.addNews(t)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateNews",value:(i=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.updateNews(t)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"addMention",value:(o=y(S().mark((function e(t){var n,r,o,i,a;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.slug,r=t.id,e.prev=1,n||r){e.next=4;break}throw new R("Vous devez fournir un slug ou un id pour ajouter une mention.");case 4:return e.next=6,this.entity("citoyens",{id:r,slug:n});case 6:if(o=e.sent,i=o.serverData,this._draftData.mentions||(this._draftData.mentions=[]),!this._draftData.mentions.find((function(e){return e.id===i.id}))){e.next=12;break}return this._draftData.mentions=this._draftData.mentions.map((function(e){return e.id===i.id&&(e.count+=1),e})),e.abrupt("return",this._draftData.mentions);case 12:return a={id:i.id,slug:i.slug,type:o.getEntityType(),name:i.name,value:i.name,count:1},this._draftData.mentions.push(a),e.abrupt("return",this._draftData.mentions);case 17:throw e.prev=17,e.t0=e.catch(1),this.apiClient._logger.error("Erreur lors de l'ajout de la mention :",e.t0),e.t0;case 21:case"end":return e.stop()}}),e,this,[[1,17]])}))),function(e){return o.apply(this,arguments)})},{key:"addImage",value:(r=y(S().mark((function e(t){var n,r,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._validateImage(t);case 2:return t=e.sent,n={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsImage:t},e.next=6,this.callIsConnected((function(){return o.endpointApi.addImageNews(n)}));case 6:return r=e.sent,this._draftData.mediaImg?(this._draftData.mediaImg.countImages=this._draftData.mediaImg.countImages+1,this._draftData.mediaImg.images.push(r.id)):this._draftData.mediaImg={countImages:1,images:[r.id]},e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"addFile",value:(n=y(S().mark((function e(t){var n,r,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._validateFile(t);case 2:return t=e.sent,n={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsFile:t},e.next=6,this.callIsConnected((function(){return o.endpointApi.addFileNews(n)}));case 6:return r=e.sent,this._draftData.mediaFile?(this._draftData.mediaFile.countFiles=this._draftData.mediaFile.countFiles+1,this._draftData.mediaFile.files.push(r)):this._draftData.mediaFile={countFiles:1,files:[r]},e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"delete",value:(t=y(S().mark((function e(){var t,n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.id){e.next=2;break}throw new R("Vous devez fournir un id pour supprimer une news.");case 2:return t={pathParams:{id:this.id}},e.next=5,this.callIsConnected((function(){return n.endpointApi.deleteNews(t)}));case 5:this._draftData={},this._serverData=null,this._draftData.id=null,this._isDeleted=!0;case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]);var t,n,r,o,i,a,s,c}();x(ce,"entityType","news"),x(ce,"SCHEMA_CONSTANTS",["ADD_NEWS"]),x(ce,"ADD_BLOCKS",new Map([["ADD_NEWS","addNews"]])),x(ce,"UPDATE_BLOCKS",new Map([["ADD_NEWS","updateNews"]]));var ue=function(){function e(){var t;w(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return x(t=v(this,e,[].concat(r)),"defaultFields",{typeElement:t.getEntityType()}),x(t,"removeFields",["typeElement"]),x(t,"transforms",{github:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.github},gitlab:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.gitlab},facebook:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.facebook},twitter:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.twitter},instagram:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.instagram},diaspora:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.diaspora},mastodon:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.mastodon},telegram:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.telegram},signal:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.signal}}),t}return E(e,oe),k(e,[{key:"_add",value:(D=y(S().mark((function t(n){var r,o,i,a,s,c,u,p,l;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._calledFromSave){t.next=2;break}throw new R("utilisation invalide de _add, utilisez save");case 2:n.id=null===(r=this._newId)||void 0===r?void 0:r.call(this),n.slug&&delete n.slug,o=b(e.ADD_BLOCKS),t.prev=5,o.s();case 7:if((i=o.n()).done){t.next=17;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){})))&&Object.keys(u).length>0)){t.next=15;break}return t.next=13,this[c](u);case 13:l=t.sent,!this.id&&null!=l&&null!==(p=l.map)&&void 0!==p&&p.id&&(this._draftData.id=l.map.id,this._draftData.slug=l.map.slug);case 15:t.next=7;break;case 17:t.next=22;break;case 19:t.prev=19,t.t0=t.catch(5),o.e(t.t0);case 22:return t.prev=22,o.f(),t.finish(22);case 25:case"end":return t.stop()}}),t,this,[[5,19,22,25]])}))),function(e){return D.apply(this,arguments)})},{key:"_update",value:(I=y(S().mark((function t(n){var r,o,i,a,s,c,u,p=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.isAdmin()){t.next=2;break}throw new R("Vous n'avez pas les droits pour modifier cette organisation",403);case 2:if(this._calledFromSave){t.next=4;break}throw new R("utilisation invalide de _update, utilisez save");case 4:n.id&&delete n.id,r=!1,o=b(e.UPDATE_BLOCKS),t.prev=7,o.s();case 9:if((i=o.n()).done){t.next=18;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){return p.initialDraftData}),this.removeFields))&&Object.keys(u).length>0)){t.next=16;break}return t.next=15,this[c](u);case 15:r=!0;case 16:t.next=9;break;case 18:t.next=23;break;case 20:t.prev=20,t.t0=t.catch(7),o.e(t.t0);case 23:return t.prev=23,o.f(),t.finish(23);case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),t,this,[[7,20,23,26]])}))),function(e){return I.apply(this,arguments)})},{key:"addOrganization",value:(P=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.addOrganization(t)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"getOrganizations",value:(A=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getOrganizations n'existe pas dans Organization");case 1:case"end":return e.stop()}}),e)}))),function(){return A.apply(this,arguments)})},{key:"getProjects",value:(T=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getProjects",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return T.apply(this,arguments)})},{key:"getEvents",value:(_=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getEvents pas encore implémenté dans Organization");case 1:case"end":return e.stop()}}),e)}))),function(){return _.apply(this,arguments)})},{key:"getPois",value:(g=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getPois",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return g.apply(this,arguments)})},{key:"getBadgesIssuer",value:(h=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getBadgesIssuer",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return h.apply(this,arguments)})},{key:"getNews",value:(m=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getNews",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return m.apply(this,arguments)})},{key:"getSubscribers",value:(f=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getSubscribers",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return f.apply(this,arguments)})},{key:"getMembers",value:(d=y(S().mark((function e(){var t,n,r,o,i,a,s,c,u,p,l,d=this,f=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=f.length>0&&void 0!==f[0]?f[0]:{},r=(n=f.length>1&&void 0!==f[1]?f[1]:{}).toBeValidated,o=n.isAdmin,i=n.isAdminPending,a=n.isInviting,s=n.roles,c=void 0===s?[]:s,this.isMe?(t.pathParams={type:this.getEntityType(),id:this.id},t.filters=this._buildLinkFilters(this.id,{linkType:"memberOf",toBeValidated:r,isAdmin:o,isAdminPending:i,isInviting:a,roles:c})):(null==t||delete t.pathParams,t.filters=this._buildLinkFilters(this.id,{linkType:"memberOf",toBeValidated:"false",isAdmin:o,isInviting:a,roles:c})),u=this.isMe?function(){return d.callIsMe((function(){return d.endpointApi.getMembersAdmin(t)}))}:function(){return d.endpointApi.getMembersNoAdmin(t)},e.next=7,u();case 7:if(p=e.sent,Array.isArray(p.results)){e.next=10;break}throw new U("Erreur lors de la récupération des membres",500,p.results);case 10:return l=this._linkEntities(p.results),e.abrupt("return",{count:p.count,results:l});case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"project",value:(l=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isAdmin()){t.next=3;break}throw new R("Vous n'avez pas les droits pour créer un projet dans cette organisation",403);case 3:return t.abrupt("return",C(e,"project",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return l.apply(this,arguments)})},{key:"poi",value:(p=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isAdmin()){t.next=3;break}throw new R("Vous n'avez pas les droits pour créer un projet dans cette organisation",403);case 3:return t.abrupt("return",C(e,"poi",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return p.apply(this,arguments)})},{key:"event",value:(u=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isAdmin()){t.next=3;break}throw new R("Vous n'avez pas les droits pour créer un projet dans cette organisation",403);case 3:return t.abrupt("return",C(e,"event",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"badge",value:(c=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isAdmin()){t.next=3;break}throw new R("Vous n'avez pas les droits pour créer un projet dans cette organisation",403);case 3:return t.abrupt("return",C(e,"badge",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"news",value:(s=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"news",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"requestToJoin",value:(a=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"requestToJoin",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"requestToJoinAdmin",value:(i=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"requestToJoinAdmin",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"acceptInvitation",value:(o=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"acceptInvitation",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"leave",value:(r=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"leave",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"follow",value:(n=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"follow",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"unfollow",value:(t=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"unfollow",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})}]);var t,n,r,o,i,a,s,c,u,p,l,d,f,m,h,g,_,T,A,P,I,D}();x(ue,"entityType","organizations"),x(ue,"SCHEMA_CONSTANTS",["ADD_ORGANIZATION","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"]),x(ue,"ADD_BLOCKS",new Map([["ADD_ORGANIZATION","addOrganization"],["PROFIL_IMAGE","updateImageProfil"]])),x(ue,"UPDATE_BLOCKS",new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]));var pe=function(){function e(){var t;w(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return x(t=v(this,e,[].concat(r)),"defaultFields",{typeElement:t.getEntityType()}),x(t,"removeFields",["typeElement"]),x(t,"transforms",{}),t}return E(e,oe),k(e,[{key:"_add",value:(_=y(S().mark((function t(n){var r,o,i,a,s,c,u,p,l;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._calledFromSave){t.next=2;break}throw new R("utilisation invalide de _add, utilisez save");case 2:n.id=null===(r=this._newId)||void 0===r?void 0:r.call(this),n.slug&&delete n.slug,o=b(e.ADD_BLOCKS),t.prev=5,o.s();case 7:if((i=o.n()).done){t.next=17;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){})))&&Object.keys(u).length>0)){t.next=15;break}return t.next=13,this[c](u);case 13:l=t.sent,!this.id&&null!=l&&null!==(p=l.map)&&void 0!==p&&p.id&&(this._draftData.id=l.map.id,this._draftData.slug=l.map.slug);case 15:t.next=7;break;case 17:t.next=22;break;case 19:t.prev=19,t.t0=t.catch(5),o.e(t.t0);case 22:return t.prev=22,o.f(),t.finish(22);case 25:case"end":return t.stop()}}),t,this,[[5,19,22,25]])}))),function(e){return _.apply(this,arguments)})},{key:"_update",value:(g=y(S().mark((function t(n){var r,o,i,a,s,c,u,p=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.isAuthor()){t.next=2;break}throw new R("Vous n'avez pas les droits pour modifier ce POI",403);case 2:if(this._calledFromSave){t.next=4;break}throw new R("utilisation invalide de _update, utilisez save");case 4:n.id&&delete n.id,r=!1,o=b(e.UPDATE_BLOCKS),t.prev=7,o.s();case 9:if((i=o.n()).done){t.next=18;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){return p.initialDraftData}),this.removeFields))&&Object.keys(u).length>0)){t.next=16;break}return t.next=15,this[c](u);case 15:r=!0;case 16:t.next=9;break;case 18:t.next=23;break;case 20:t.prev=20,t.t0=t.catch(7),o.e(t.t0);case 23:return t.prev=23,o.f(),t.finish(23);case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),t,this,[[7,20,23,26]])}))),function(e){return g.apply(this,arguments)})},{key:"addPoi",value:(h=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe||(t.parent={},t.parent["".concat(this.parent.id)]={type:this.parent.getEntityType(),name:this.parent.name}),e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.addPoi(t)})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"getOrganizations",value:(m=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getOrganizations n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"getProjects",value:(f=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getProjects n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getEvents",value:(d=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getEvents n'existe pas dans".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getPois",value:(l=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getPois n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getBadgesIssuer",value:(p=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getBadgesIssuer n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"getNews",value:(u=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getNews",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"getSubscribers",value:(c=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getSubscribers",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"project",value:(s=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("project n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"poi",value:(a=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("poi n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"event",value:(i=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("event n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"badge",value:(o=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("badge n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"news",value:(r=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"news",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"follow",value:(n=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"follow",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"unfollow",value:(t=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"unfollow",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})}]);var t,n,r,o,i,a,s,c,u,p,l,d,f,m,h,g,_}();x(pe,"entityType","poi"),x(pe,"SCHEMA_CONSTANTS",["ADD_POI","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"]),x(pe,"ADD_BLOCKS",new Map([["ADD_POI","addPoi"],["PROFIL_IMAGE","updateImageProfil"]])),x(pe,"UPDATE_BLOCKS",new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]));var le=function(){function e(){var t;w(this,e);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return x(t=v(this,e,[].concat(r)),"defaultFields",{typeElement:t.getEntityType()}),x(t,"removeFields",["typeElement"]),x(t,"transforms",{github:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.github},gitlab:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.gitlab},facebook:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.facebook},twitter:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.twitter},instagram:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.instagram},diaspora:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.diaspora},mastodon:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.mastodon},telegram:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.telegram},signal:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.signal},parent:function(e){return e&&"object"===N(e)?Object.fromEntries(Object.entries(e).map((function(e){var t,n,r=j(e,2),o=r[0],i=r[1];return[o,{type:null!==(t=null==i?void 0:i.type)&&void 0!==t?t:null,name:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:null}]}))):null}}),t}return E(e,oe),k(e,[{key:"_add",value:(D=y(S().mark((function t(n){var r,o,i,a,s,c,u,p,l;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._calledFromSave){t.next=2;break}throw new R("utilisation invalide de _add, utilisez save");case 2:n.id=null===(r=this._newId)||void 0===r?void 0:r.call(this),n.slug&&delete n.slug,o=b(e.ADD_BLOCKS),t.prev=5,o.s();case 7:if((i=o.n()).done){t.next=17;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){})))&&Object.keys(u).length>0)){t.next=15;break}return t.next=13,this[c](u);case 13:l=t.sent,!this.id&&null!=l&&null!==(p=l.map)&&void 0!==p&&p.id&&(this._draftData.id=l.map.id,this._draftData.slug=l.map.slug);case 15:t.next=7;break;case 17:t.next=22;break;case 19:t.prev=19,t.t0=t.catch(5),o.e(t.t0);case 22:return t.prev=22,o.f(),t.finish(22);case 25:case"end":return t.stop()}}),t,this,[[5,19,22,25]])}))),function(e){return D.apply(this,arguments)})},{key:"_update",value:(I=y(S().mark((function t(n){var r,o,i,a,s,c,u,p=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.isAdmin()){t.next=2;break}throw new R("Vous n'avez pas les droits pour modifier ce projet",403);case 2:if(this._calledFromSave){t.next=4;break}throw new R("utilisation invalide de _update, utilisez save");case 4:n.id&&delete n.id,r=!1,o=b(e.UPDATE_BLOCKS),t.prev=7,o.s();case 9:if((i=o.n()).done){t.next=18;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){return p.initialDraftData}),this.removeFields))&&Object.keys(u).length>0)){t.next=16;break}return t.next=15,this[c](u);case 15:r=!0;case 16:t.next=9;break;case 18:t.next=23;break;case 20:t.prev=20,t.t0=t.catch(7),o.e(t.t0);case 23:return t.prev=23,o.f(),t.finish(23);case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),t,this,[[7,20,23,26]])}))),function(e){return I.apply(this,arguments)})},{key:"addProject",value:(P=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe||(t.parent={},t.parent["".concat(this.parent.id)]={type:this.parent.getEntityType(),name:this.parent.name}),e.abrupt("return",this.callIsConnected((function(){return n.endpointApi.addProject(t)})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"getOrganizations",value:(A=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getOrganizations n'existe pas dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return A.apply(this,arguments)})},{key:"getProjects",value:(T=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getProjects",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return T.apply(this,arguments)})},{key:"getEvents",value:(_=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("getEvents pas encore implémenté dans ".concat(this.constructor.name));case 1:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"getPois",value:(g=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getPois",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return g.apply(this,arguments)})},{key:"getBadgesIssuer",value:(h=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getBadgesIssuer",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return h.apply(this,arguments)})},{key:"getNews",value:(m=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getNews",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return m.apply(this,arguments)})},{key:"getSubscribers",value:(f=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getSubscribers",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return f.apply(this,arguments)})},{key:"getContributors",value:(d=y(S().mark((function e(){var t,n,r,o,i,a,s,c,u,p,l,d=this,f=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=f.length>0&&void 0!==f[0]?f[0]:{},r=(n=f.length>1&&void 0!==f[1]?f[1]:{}).toBeValidated,o=n.isAdmin,i=n.isInviting,a=n.isAdminPending,s=n.roles,c=void 0===s?[]:s,this.isMe?(t.pathParams={type:this.getEntityType(),id:this.id},t.filters=this._buildLinkFilters(this.id,{linkType:"projects",toBeValidated:r,isAdmin:o,isAdminPending:a,isInviting:i,roles:c})):(null==t||delete t.pathParams,t.filters=this._buildLinkFilters(this.id,{linkType:"projects",toBeValidated:"false",isAdmin:o,isInviting:i,roles:c})),u=this.isMe?function(){return d.callIsMe((function(){return d.endpointApi.getContributorsAdmin(t)}))}:function(){return d.endpointApi.getContributorsNoAdmin(t)},e.next=7,u();case 7:if(p=e.sent,Array.isArray(p.results)){e.next=10;break}throw new U("Erreur lors de la récupération des contributeurs",500,p.results);case 10:return l=this._linkEntities(p.results),e.abrupt("return",{count:p.count,results:l});case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"project",value:(l=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isAdmin()){t.next=3;break}throw new R("Vous n'avez pas les droits pour créer un projet dans ce projet",403);case 3:return t.abrupt("return",C(e,"project",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return l.apply(this,arguments)})},{key:"poi",value:(p=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isAdmin()){t.next=3;break}throw new R("Vous n'avez pas les droits pour créer un POI dans ce projet",403);case 3:return t.abrupt("return",C(e,"poi",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return p.apply(this,arguments)})},{key:"event",value:(u=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isAdmin()){t.next=3;break}throw new R("Vous n'avez pas les droits pour créer un événement dans ce projet",403);case 3:return t.abrupt("return",C(e,"event",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"badge",value:(c=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isAdmin()){t.next=3;break}throw new R("Vous n'avez pas les droits pour créer un badge dans ce projet",403);case 3:return t.abrupt("return",C(e,"badge",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"news",value:(s=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"news",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"requestToJoin",value:(a=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"requestToJoin",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"requestToJoinAdmin",value:(i=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"requestToJoinAdmin",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"acceptInvitation",value:(o=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"acceptInvitation",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"leave",value:(r=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"leave",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"follow",value:(n=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"follow",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"unfollow",value:(t=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",C(e,"unfollow",this,3)([]));case 1:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})}]);var t,n,r,o,i,a,s,c,u,p,l,d,f,m,h,g,_,T,A,P,I,D}();x(le,"entityType","projects"),x(le,"SCHEMA_CONSTANTS",["ADD_PROJECT","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"]),x(le,"ADD_BLOCKS",new Map([["ADD_PROJECT","addProject"],["PROFIL_IMAGE","updateImageProfil"]])),x(le,"UPDATE_BLOCKS",new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]));var de=function(){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(w(this,e),!o.EndpointApi)throw new R("EndpointApi class must be injected to avoid circular dependency.");if(!(null!=r&&r.id||null!=r&&r.slug))throw new R("Vous devez fournir un id ou un slug pour créer un User.");if(!o.Organization)throw new R("Organization class must be injected.");if(!o.Project)throw new R("Project class must be injected.");if(!o.Event)throw new R("Event class must be injected.");if(!o.Poi)throw new R("Poi class must be injected.");if(!o.Badge)throw new R("Badge class must be injected.");if(!o.News)throw new R("News class must be injected.");return x(n=v(this,e,[t,r,o]),"defaultFields",{typeElement:n.getEntityType()}),x(n,"removeFields",["typeElement"]),x(n,"transforms",{github:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.github},gitlab:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.gitlab},facebook:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.facebook},twitter:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.twitter},instagram:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.instagram},diaspora:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.diaspora},mastodon:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.mastodon},telegram:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.telegram},signal:function(e,t){var n;return null==t||null===(n=t.socialNetwork)||void 0===n?void 0:n.signal}}),n}return E(e,oe),k(e,[{key:"slug",get:function(){return this._draftData.slug||null}},{key:"isMe",get:function(){return this.isConnected&&this.userId===this.id}},{key:"parentIsMe",get:function(){return C(e,"isMe",this,1)}},{key:"isActingUser",get:function(){return this.parentIsMe&&!this.isMe}},{key:"get",value:function(){var e=y(S().mark((function e(){var t=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.apiClient.safeCall(y(S().mark((function e(){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.isMe){e.next=8;break}return e.next=3,t.endpointApi.meInfoUrl();case 3:return n=e.sent,t._setData(n),e.abrupt("return",n);case 8:return e.next=10,t._getPublicProfile();case 10:return r=e.sent,t._setData(r),e.abrupt("return",r);case 13:case"end":return e.stop()}}),e)})))));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"changePassword",value:(K=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},e.abrupt("return",this.callIsMe((function(){return n.endpointApi.changePassword(t)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return K.apply(this,arguments)})},{key:"delete",value:(V=y(S().mark((function e(){var t,n=this,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},e.abrupt("return",this.callIsMe((function(){return n.endpointApi.deleteAccount(t)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"save",value:(G=y(S().mark((function t(){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.isMe){t.next=2;break}throw new R("Vous devez être connecté et être l'utilisateur pour sauvegarder.");case 2:return t.next=4,C(e,"save",this,3)([]);case 4:case"end":return t.stop()}}),t,this)}))),function(){return G.apply(this,arguments)})},{key:"_add",value:($=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new R("Vous ne pouvez pas ajouter un utilisateur par ce moyen.");case 1:case"end":return e.stop()}}),e)}))),function(){return $.apply(this,arguments)})},{key:"_update",value:(F=y(S().mark((function t(n){var r,o,i,a,s,c,u,p=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._calledFromSave){t.next=2;break}throw new Error("utilisation invalide de _update, utilisez save");case 2:n.id&&delete n.id,r=!1,o=b(e.UPDATE_BLOCKS),t.prev=5,o.s();case 7:if((i=o.n()).done){t.next=16;break}if(a=j(i.value,2),s=a[0],c=a[1],!((u=this._extractChangedFieldsFromSchema(this.apiClient,s,O(O({},n),this.defaultFields),(function(){return p.initialDraftData}),this.removeFields))&&Object.keys(u).length>0)){t.next=14;break}return t.next=13,this[c](u);case 13:r=!0;case 14:t.next=7;break;case 16:t.next=21;break;case 18:t.prev=18,t.t0=t.catch(5),o.e(t.t0);case 21:return t.prev=21,o.f(),t.finish(21);case 24:return t.abrupt("return",r);case 25:case"end":return t.stop()}}),t,this,[[5,18,21,24]])}))),function(e){return F.apply(this,arguments)})},{key:"updateSettings",value:(z=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour mettre à jour les paramètres.");case 3:return t.next=5,C(e,"updateSettings",this,3)([n]);case 5:return t.next=7,this.refresh();case 7:case"end":return t.stop()}}),t,this)}))),function(){return z.apply(this,arguments)})},{key:"updateDescription",value:(B=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour mettre à jour la description.");case 3:return t.abrupt("return",C(e,"updateDescription",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return B.apply(this,arguments)})},{key:"updateInfo",value:(q=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour mettre à jour les informations.");case 3:return t.abrupt("return",C(e,"updateInfo",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return q.apply(this,arguments)})},{key:"updateSocial",value:(M=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour mettre à jour les réseaux sociaux.");case 3:return t.abrupt("return",C(e,"updateSocial",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return M.apply(this,arguments)})},{key:"updateLocality",value:(N=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour mettre à jour la localité.");case 3:return t.abrupt("return",C(e,"updateLocality",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return N.apply(this,arguments)})},{key:"updateSlug",value:(L=y(S().mark((function t(n){var r;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.slug,this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour mettre à jour le slug.");case 3:return t.abrupt("return",C(e,"updateSlug",this,3)([{slug:r}]));case 4:case"end":return t.stop()}}),t,this)}))),function(e){return L.apply(this,arguments)})},{key:"updateImageProfil",value:(D=y(S().mark((function t(n){var r;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.profil_avatar,this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour mettre à jour l'image de profil.");case 3:return t.abrupt("return",C(e,"updateImageProfil",this,3)([{profil_avatar:r}]));case 4:case"end":return t.stop()}}),t,this)}))),function(e){return D.apply(this,arguments)})},{key:"getOrganizations",value:(I=y(S().mark((function e(){var t,n,r,o,i,a,s=this,c=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==(n=c.length>0&&void 0!==c[0]?c[0]:{})||delete n.pathParams,r=this.isMe?function(){return s.callIsMe((function(){return s.endpointApi.getOrganizationsAdmin(n)}))}:function(){return s.endpointApi.getOrganizationsNoAdmin(n)},this.isMe||n.filters||(n.filters=x(x(x({},"links.members.".concat(this.id),{$exists:!0}),"links.members.".concat(this.id,".toBeValidated"),{$exists:!1}),"links.members.".concat(this.id,".isInviting"),{$exists:!1})),e.next=6,r();case 6:if(o=e.sent,Array.isArray(o.results)){e.next=9;break}throw new U("Erreur lors de la récupération des organisations.",500,o.results);case 9:return null==o||null===(t=o.count)||void 0===t||delete t.spam,i=Object.values(o.count||{}).reduce((function(e,t){return e+t}),0),o.count.total=i,a=this._linkEntities(o.results),e.abrupt("return",{count:o.count,results:a});case 14:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"getProjects",value:(P=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getProjects",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return P.apply(this,arguments)})},{key:"getPois",value:(A=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getPois",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return A.apply(this,arguments)})},{key:"getNews",value:(T=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getNews",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return T.apply(this,arguments)})},{key:"getFriends",value:(_=y(S().mark((function e(){var t,n,r,o,i,a=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==(r=a.length>0&&void 0!==a[0]?a[0]:{})||delete r.pathParams,this.isMe||(r.pathParams={id:this.id}),e.next=5,this.endpointApi.getFriendsAdmin(r);case 5:if(o=e.sent,Array.isArray(o.results)){e.next=8;break}throw new U("Erreur lors de la récupération des amis administrables.",500,o);case 8:return i=this._linkEntities(o.results),e.abrupt("return",{count:null!==(t=null==o||null===(n=o.count)||void 0===n?void 0:n.citoyens)&&void 0!==t?t:0,results:i});case 10:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"getSubscriptions",value:(g=y(S().mark((function e(){var t,n,r,o,i=this,a=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==(t=a.length>0&&void 0!==a[0]?a[0]:{})||delete t.pathParams,n=this.isMe?function(){return i.callIsMe((function(){return i.endpointApi.getSubscriptionsAdmin(t)}))}:function(){return i.endpointApi.getSubscriptions(t)},this.isMe||t.filters||(t.filters=x({},"links.followers.".concat(this.id),{$exists:!0})),e.next=6,n();case 6:if(r=e.sent,Array.isArray(r.results)){e.next=9;break}throw new U("Erreur lors de la récupération des abonnements.",500,r.results);case 9:return o=this._linkEntities(r.results),e.abrupt("return",{count:r.count,results:o});case 11:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"getSubscribers",value:(h=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getSubscribers",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return h.apply(this,arguments)})},{key:"getBadgesIssuer",value:(m=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>0&&void 0!==r[0]?r[0]:{},t.abrupt("return",C(e,"getBadgesIssuer",this,3)([n]));case 2:case"end":return t.stop()}}),t,this)}))),function(){return m.apply(this,arguments)})},{key:"getBadges",value:(f=y(S().mark((function e(){var t,n,r=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},e.next=3,this.linkEntitiesFromServerData("badges",t);case 3:return n=e.sent,e.abrupt("return",n);case 5:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"user",value:(d=y(S().mark((function t(n){var r;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.isMe){t.next=2;break}throw new R("Vous devez être connecté et être l'utilisateur");case 2:if(n.id||n.slug){t.next=4;break}throw new R("Vous devez fournir un id ou un slug pour créer un User.");case 4:return r=new e(this,n,this.deps),t.next=7,r.get();case 7:return t.abrupt("return",r);case 8:case"end":return t.stop()}}),t,this)}))),function(e){return d.apply(this,arguments)})},{key:"organization",value:(l=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour créer une organisation.");case 3:return t.abrupt("return",C(e,"organization",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return l.apply(this,arguments)})},{key:"project",value:(p=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour créer un projet.");case 3:return t.abrupt("return",C(e,"project",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return p.apply(this,arguments)})},{key:"news",value:(u=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour créer une actualité.");case 3:return t.abrupt("return",C(e,"news",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"poi",value:(c=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour créer un POI.");case 3:return t.abrupt("return",C(e,"poi",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"event",value:(s=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour créer un événement.");case 3:return t.abrupt("return",C(e,"event",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"badge",value:(a=y(S().mark((function t(){var n,r=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.length>0&&void 0!==r[0]?r[0]:{},this.isMe){t.next=3;break}throw new R("Vous devez être connecté et être l'utilisateur pour créer un badge.");case 3:return t.abrupt("return",C(e,"badge",this,3)([n]));case 4:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"sendFriendRequest",value:(i=y(S().mark((function e(){var t,n,r,o,i;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isActingUser){e.next=2;break}throw new R("Vous devez être connecté pour envoyer une demande d'amis.");case 2:if(this._checkLinkableEntity(),this.id){e.next=5;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 5:if(t=this._getLinkMeta(),n=t.connectTypeConnect,r=this._getLinkFromConnectedUser()){e.next=15;break}return o={parentType:this.getEntityType(),parentId:this.id,connectType:n},e.next=11,this.endpointApi.connect(o);case 11:return i=e.sent,e.next=14,this.userContext.refresh();case 14:return e.abrupt("return",i);case 15:if(!r.isInviting||r.invitorId!==this.id){e.next=17;break}return e.abrupt("return",this.acceptFriendRequest());case 17:if(!r.isInviting||r.invitorId!==this.userId){e.next=19;break}throw new R("Vous avez déjà envoyé une demande d'amis à cet utilisateur.");case 19:throw new R("Vous êtes déjà connecté à cette entité.");case 20:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"acceptFriendRequest",value:(o=y(S().mark((function e(){var t,n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isActingUser){e.next=2;break}throw new R("Vous devez être connecté pour accepter une demande d'amitié.");case 2:if(this._checkLinkableEntity(),this.id){e.next=5;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 5:if(null==(t=this._getLinkFromConnectedUser())||!t.isInviting||t.invitorId!==this.id){e.next=14;break}return n={parentType:this.getEntityType(),parentId:this.id,linkOption:"isInviting"},e.next=10,this.endpointApi.linkValidate(n);case 10:return r=e.sent,e.next=13,this.userContext.refresh();case 13:return e.abrupt("return",r);case 14:throw new R("Vous n'avez pas d'invitation à valider.");case 15:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"removeFriend",value:(r=y(S().mark((function e(){var t,n,r,o;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isActingUser){e.next=2;break}throw new R("Vous devez être connecté pour supprimer un ami.");case 2:if(this._checkLinkableEntity(),this.id){e.next=5;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 5:if(t=this._getLinkMeta(),n=t.connectTypeDisconnect,this._getLinkFromConnectedUser()){e.next=9;break}throw new R("Vous n'êtes pas connecté à cette entité.");case 9:return r={parentType:this.getEntityType(),parentId:this.id,connectType:n},e.next=12,this.endpointApi.disconnect(r);case 12:return o=e.sent,e.next=15,this.userContext.refresh();case 15:return e.abrupt("return",o);case 16:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"requestToJoin",value:function(){throw new R("l'utilisation de requestToJoin n'est pas autorisée sur un utilisateur.")}},{key:"requestToJoinAdmin",value:function(){throw new R("l'utilisation de requestToJoinAdmin n'est pas autorisée sur un utilisateur.")}},{key:"acceptInvitation",value:function(){throw new R("l'utilisation de acceptInvitation n'est pas autorisée sur un utilisateur.")}},{key:"leave",value:function(){throw new R("l'utilisation de leave n'est pas autorisée sur un utilisateur.")}},{key:"follow",value:(n=y(S().mark((function e(){var t,n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isActingUser){e.next=2;break}throw new R("Vous devez être connecté pour suivre un utilisateur.");case 2:if(this.id){e.next=4;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 4:if(null===(t=this.userContext)||void 0===t||null===(t=t.serverData)||void 0===t||null===(t=t.links)||void 0===t||null===(t=t.follows)||void 0===t?void 0:t[this.id]){e.next=13;break}return n={parentType:this.getEntityType(),parentId:this.id},e.next=9,this.endpointApi.follow(n);case 9:return r=e.sent,e.next=12,this.userContext.refresh();case 12:return e.abrupt("return",r);case 13:throw new R("Vous êtes déjà abonné à cet utilisateur.");case 14:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"unfollow",value:(t=y(S().mark((function e(){var t,n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isActingUser){e.next=2;break}throw new R("Vous devez être connecté pour vous désabonner d'un utilisateur.");case 2:if(this.id){e.next=4;break}throw new R("".concat(this.constructor.name," non enregistrée."));case 4:if(!(null===(t=this.userContext)||void 0===t||null===(t=t.serverData)||void 0===t||null===(t=t.links)||void 0===t||null===(t=t.follows)||void 0===t?void 0:t[this.id])){e.next=13;break}return n={parentType:this.getEntityType(),parentId:this.id,connectType:"followers"},e.next=9,this.endpointApi.disconnect(n);case 9:return r=e.sent,e.next=12,this.userContext.refresh();case 12:return e.abrupt("return",r);case 13:throw new R("Vous n'êtes pas abonné à cet utilisateur.");case 14:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"isFriend",value:function(){if(!this.isActingUser)throw new R("Vous devez être connecté pour vérifier si vous êtes ami.");this._assertEntityType("citoyens");var e=this._getLinkFromConnectedUser();return this._validateUserLink(e)}},{key:"isFollower",value:function(){if(!this.isActingUser)throw new R("Vous devez être connecté pour vérifier si il vous suit.");if(!this.id)throw new R("".concat(this.constructor.name," non enregistrée."));return this._assertEntityType("citoyens"),this._isLinked("followers")}},{key:"isFollowing",value:function(){if(!this.isActingUser)throw new R("Vous devez être connecté pour vérifier si vous le suivez.");if(!this.id)throw new R("".concat(this.constructor.name," non enregistrée."));return this._assertEntityType("citoyens"),this._isLinked("follows")}}],[{key:"fromServerData",value:function(t,n,r){return new e(n.apiClient,t,r)}}]);var t,n,r,o,i,a,s,c,u,p,l,d,f,m,h,g,_,T,A,P,I,D,L,N,M,q,B,z,F,$,G,V,K}();x(de,"entityType","citoyens"),x(de,"SCHEMA_CONSTANTS",["UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"]),x(de,"UPDATE_BLOCKS",new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]])),Object.assign(de.prototype,{});var fe={_looksLikeObjectID:function(e){return 24===e.length&&/^[0-9a-f]*$/.test(e)}};fe.ObjectID=function(){return k((function e(t){if(w(this,e),t){if(t=t.toLowerCase(),!fe._looksLikeObjectID(t))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=t}}),[{key:"equals",value:function(e){return e instanceof fe.ObjectID&&this.valueOf()===e.valueOf()}},{key:"toString",value:function(){return'ObjectID("'.concat(this._str,'")')}},{key:"clone",value:function(){return new fe.ObjectID(this._str)}},{key:"typeName",value:function(){return"oid"}},{key:"getTimestamp",value:function(){return Number.parseInt(this._str.substr(0,8),16)}},{key:"valueOf",value:function(){return this._str}},{key:"toJSONValue",value:function(){return this.valueOf()}},{key:"toHexString",value:function(){return this.valueOf()}}])}();var me={common1:{type:"string"},common2:{format:"email",type:"string"},common3:{type:"boolean"},common4:{format:"uri",type:"string"},common5:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common6:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},required:["id"],type:"object"},common8:{additionalProperties:!1,properties:{reason:{default:"",type:"string"}},required:["reason"],type:"object"},common10:{default:"",type:"string"},common11:{pattern:"^[a-f0-9]{24}$",type:"string"},common12:{const:"citoyens"},common13:{properties:{value:{type:"boolean"}}},common15:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},common16:{},common17:{else:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},if:{properties:{typeElement:{const:"citoyens"}}},then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}}},common20:{properties:{typeElement:{const:"citoyens"}}},common23:{not:{type:"null"}},common25:{default:"citoyens",enum:["citoyens","projects","organizations","poi"],type:"string"},common26:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common27:{items:{type:"string"},type:"array"},common28:{enum:[""],type:"string"},common29:{properties:{name:{not:{type:"null"}}},required:["name"]},common31:{properties:{url:{not:{type:"null"}}},required:["url"]},common33:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common35:{properties:{email:{not:{type:"null"}}},required:["email"]},common37:{const:"info",default:"info",type:"string"},common38:{$ref:"#/$defs/sharedFields/email"},common39:{$ref:"#/$defs/sharedFields/name"},common40:{$ref:"#/$defs/sharedFields/tags"},common41:{default:"citoyens",enum:["citoyens"],type:"string"},common42:{$ref:"#/$defs/sharedFields/url"},common43:{const:"projects"},common44:{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type","name"],type:"object"},common45:{name:{type:"string"},type:{type:"string"}},common46:{const:"organizations"},common47:{properties:{type:{not:{type:"null"}}},required:["type"]},common49:{enum:["link","tool","machine","software","rh","Resource material","Financial Ressource","ficheBlanche","geoJson","compostPickup","video","sharedLibrary","recoveryCenter","trash","history","something2See","funPlace","place","artPiece","streetArts","openScene","stand","parking","other"],type:"string"},common50:{enum:["poi"],type:"string"},common51:{$ref:"#/$defs/socialField"},common52:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},common55:{additionalProperties:!1,properties:{"@type":{const:"PostalAddress",type:"string"},addressCountry:{type:"string"},addressLocality:{type:"string"},codeInsee:{type:"string"},level1:{type:"string"},level1Name:{type:"string"},level3:{minLength:0,type:"string"},level3Name:{minLength:0,type:"string"},level4:{minLength:0,type:"string"},level4Name:{minLength:0,type:"string"},localityId:{type:"string"},postalCode:{type:"string"},streetAddress:{type:"string"}},required:["@type","addressCountry","codeInsee","addressLocality","localityId","level1","level1Name"],type:"object"},common59:{additionalProperties:!1,properties:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},required:["latitude","longitude"],type:"object"},common63:{additionalProperties:!0,properties:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},required:["type","coordinates","float"],type:"object"},common66:{type:"number"},common67:{const:!0,default:!0,type:"boolean"},common69:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common72:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common73:{properties:{type:{const:"citoyens"}}},common75:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},common77:{properties:{folder:{const:"citoyens"}}},common79:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common81:{properties:{parentId:{pattern:"^[a-f0-9]{24}$"}}},common83:{properties:{parentType:{const:"citoyens"}}},common85:{properties:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common87:{default:!0,type:"boolean"},common88:{default:0,type:"integer"},common89:{required:["text"]},common90:{required:["mediaImg"]},common91:{required:["mediaFile"]},common92:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common94:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common96:{items:{properties:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common100:{default:"public",enum:["public","private","restricted"],type:"string"},common101:{const:"news",default:"news",type:"string"},common102:{additionalProperties:!1,else:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{folder:{const:"citoyens"}}},properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},required:["folder","ownerId"],then:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common104:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common105:{default:!1,type:"boolean"},common106:{properties:{childId:{pattern:"^[a-f0-9]{24}$"}}},common108:{properties:{childType:{const:"citoyens"}}},common110:{const:"share",default:"share",type:"string"},common111:{properties:{childId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common113:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common115:{default:"news",enum:["news"],type:"string"},common116:{items:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common119:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common120:{const:!1,default:!1,type:"boolean"},common121:{const:"",default:"",type:"string"},common122:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common124:{default:0,minimum:0,type:"integer"},common125:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common127:{$exists:!0},common128:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common131:{default:30,type:"integer"},common132:{additionalProperties:!1,else:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{type:{const:"citoyens"}}},properties:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},required:["type","id"],then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common134:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common135:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common137:{$exists:!1},common138:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common140:{const:!1},common141:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common143:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common145:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common148:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common150:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},type:"array"},common152:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common155:{"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"}},common156:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common159:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common161:{const:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common163:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common165:{const:!0,type:"boolean"},common166:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common169:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"}},common170:{indexMax:30,indexMin:0},common171:{properties:{parentType:{const:"organizations"}}},common173:{properties:{parentType:{const:"projects"}}},common175:{properties:{parentType:{const:"events"}}},common178:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common179:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common180:{enum:["citoyens","organizations","projects","events"],type:"string"},common181:{const:"citoyens",default:"citoyens",type:"string"},common182:{const:"@userId",default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common183:{default:{isOpenData:!0,isOpenEdition:!0},properties:{isOpenData:{default:!0,type:"boolean"},isOpenEdition:{default:!0,type:"boolean"}},required:["isOpenData","isOpenEdition"],type:"object"},common186:{additionalProperties:!1,default:{"@userId":{type:"citoyens"}},patternProperties:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},type:"object"},common189:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},common191:{const:"poi",default:"poi",type:"string"},common192:{const:"events",default:"events",type:"string"},common193:{format:"date-time",type:"string"},common194:{pattern:"^([01]\\d|2[0-3]):[0-5]\\d$",type:"string"},common195:{enum:["workshop","competition","concert","contest","conference","debate","exhibition","festival","crowdfunding","fair","course","protest","market","film","getTogether","meeting","spectacle","internship","stand","others"],type:"string"},common196:{type:"integer"},common197:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^[a-f0-9]{24}$",type:"string"},type:{const:"citoyens",default:"citoyens",type:"string"}},required:["type","id"],type:"object"},common200:{const:"badges",default:"badges",type:"string"},common201:{const:"badge",default:"badge",type:"string"},common202:{patternProperties:{"^[0-9a-f]{24}$":{additionalProperties:!1,properties:{isAdmin:{default:"",enum:["","admin"],type:"string"},name:{type:"string"},roles:{items:{type:"string"},type:"array"}},required:["name"],type:"object"}},type:"object"},common206:{default:"",enum:["","admin"],type:"string"}},he={endpoints:[{auth:"none",constant:"PERSON_REGISTER",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/register",request:{additionalProperties:!1,properties:{app:me.common1,email:me.common2,isInvitation:me.common3,mode:me.common1,name:me.common1,pendingUserId:me.common1,pwd:me.common1,username:me.common1},required:["name","username","email","pwd"],type:"object"}},{auth:"none",constant:"AUTHENTICATE_URL",contentType:"application/json",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/api/cocolight/authenticate",postActions:[{path:"accessToken",type:"setToken"},{path:"refreshToken",type:"setRefreshToken"},{event:"userLoggedIn",path:"user",type:"emitEvent"}],request:{additionalProperties:!1,properties:{email:me.common2,password:me.common1},required:["email","password"],type:"object"}},{auth:"none",constant:"REFRESH_TOKEN_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/refreshtoken",request:{additionalProperties:!1,properties:{refreshToken:me.common1},required:["refreshToken"],type:"object"}},{auth:"bearer",constant:"ME_INFO_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/me"},{auth:"none",constant:"PASSWORD_RECOVERY",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/sendemail",request:{additionalProperties:!1,properties:{email:me.common2,type:{const:"password",default:"password",type:"string"}},required:["email","type"],type:"object"}},{auth:"bearer",constant:"SERVER_EXCHANGE_TOKEN",contentType:"application/json",method:"POST",path:"/api/cocolight/exchangetoken",request:{additionalProperties:!1,properties:{serverUrl:me.common4},required:["serverUrl"],type:"object"}},{auth:"bearer",constant:"CHANGE_PASSWORD",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/person/changepassword",request:{additionalProperties:!1,properties:{mode:{const:"changePassword",default:"changePassword",type:"string"},newPassword:me.common1,newPassword2:me.common1,oldPassword:me.common1,scope:{default:"",type:["string"]},userId:me.common5},required:["mode","userId","oldPassword","newPassword","newPassword2"],type:"object"}},{auth:"bearer",constant:"DELETE_ACCOUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/id/{id}/type/citoyens",pathParams:me.common6,postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:me.common8},{auth:"bearer",constant:"UPDATE_SETTINGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatesettings",request:{additionalProperties:!1,allOf:[{else:{properties:{idEntity:me.common11}},if:{properties:{typeEntity:me.common12}},then:{properties:{idEntity:me.common5}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:me.common12}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:me.common12}},then:me.common13},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:me.common12}}},then:me.common13}],properties:{idEntity:me.common1,type:me.common1,typeEntity:me.common15,value:me.common16},required:["type","value","typeEntity","idEntity"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_DESCRIPTION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{additionalProperties:!1,allOf:[me.common17,{anyOf:[{properties:{description:me.common23},required:["description"]},{properties:{shortDescription:me.common23},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:me.common10,description:me.common1,id:me.common1,scope:{default:"",type:["string","null"]},shortDescription:me.common1,typeElement:me.common25},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_INFO",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{sharedFields:{email:me.common2,name:me.common1,tags:me.common26,url:me.common4}},allOf:[{if:me.common20,then:{additionalProperties:!1,anyOf:[me.common29,{properties:{birthDate:me.common23},required:["birthDate"]},{properties:{fixe:me.common23},required:["fixe"]},{properties:{mobile:me.common23},required:["mobile"]},me.common31,me.common33,me.common35],properties:{birthDate:{format:"date",type:"string"},block:me.common37,email:me.common38,fixe:me.common1,id:me.common5,mobile:me.common1,name:me.common39,scope:me.common10,tags:me.common40,typeElement:me.common41,url:me.common42}}},{if:{properties:{typeElement:me.common43}},then:{additionalProperties:!1,anyOf:[me.common29,me.common31,me.common33,me.common35,{properties:{avancement:me.common23},required:["avancement"]},{properties:{parent:me.common23},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:me.common37,email:me.common38,id:me.common1,name:me.common39,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":me.common44},type:"object"},scope:me.common10,tags:me.common40,typeElement:{default:"citoyens",enum:["projects"],type:"string"},url:me.common42}}},{if:{properties:{typeElement:me.common46}},then:{additionalProperties:!1,anyOf:[me.common29,me.common31,me.common33,me.common35,me.common47],properties:{block:me.common37,email:me.common38,id:me.common1,name:me.common39,scope:me.common10,tags:me.common40,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:{enum:["organizations"],type:"string"},url:me.common42}}},{if:{properties:{typeElement:{const:"poi"}}},then:{additionalProperties:!1,anyOf:[me.common29,me.common31,me.common33,me.common35,me.common47,{properties:{urls:me.common23},required:["urls"]}],properties:{block:me.common37,email:me.common38,id:me.common1,name:me.common39,scope:me.common10,tags:me.common40,type:me.common49,typeElement:me.common50,url:me.common42,urls:me.common27}}}],properties:{block:me.common37,id:me.common1,scope:me.common10,typeElement:me.common25},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SOCIAL",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{socialField:{anyOf:[me.common28,me.common4]}},allOf:[me.common17,{anyOf:[{properties:{gitlab:me.common23},required:["gitlab"]},{properties:{github:me.common23},required:["github"]},{properties:{twitter:me.common23},required:["twitter"]},{properties:{facebook:me.common23},required:["facebook"]},{properties:{instagram:me.common23},required:["instagram"]},{properties:{diaspora:me.common23},required:["diaspora"]},{properties:{mastodon:me.common23},required:["mastodon"]},{properties:{telegram:me.common23},required:["telegram"]},{properties:{signal:me.common23},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:me.common51,facebook:me.common51,github:me.common51,gitlab:me.common51,id:me.common1,instagram:me.common51,mastodon:me.common51,scope:me.common10,signal:me.common51,telegram:me.common51,twitter:me.common51,typeElement:me.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_LOCALITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:me.common52,if:me.common20,properties:{address:me.common55,block:{const:"localities",default:"localities",type:"string"},geo:me.common59,geoPosition:me.common63,id:me.common1,scope:me.common10,typeElement:me.common25},required:["block","typeElement","id","address"],then:me.common69,type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:me.common52,if:me.common20,properties:{block:me.common37,id:me.common1,scope:me.common10,slug:me.common72,typeElement:me.common25},required:["block","typeElement","id","slug"],then:me.common69,type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,else:me.common52,if:me.common73,properties:{block:me.common37,id:me.common1,slug:me.common72,type:me.common15},required:["block","type","id","slug"],then:me.common69,type:"object"}},{auth:"bearer",constant:"PROFIL_IMAGE",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/profil_avatar/contentKey/profil/docType/image",pathParams:{additionalProperties:!1,else:me.common75,if:me.common77,properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations","events","poi"],type:"string"},ownerId:me.common1},required:["folder","ownerId"],then:me.common79,type:"object"},request:{additionalProperties:!1,properties:{profil_avatar:me.common16},required:["profil_avatar"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_ABOUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/about/type/{type}/id/{id}/json/true",pathParams:{additionalProperties:!1,else:me.common52,if:me.common73,properties:{id:me.common1,type:{default:"citoyens",enum:["citoyens","projects","organizations","events","poi","badges"],type:"string"}},required:["type","id"],then:me.common69,type:"object"},request:{additionalProperties:!1,properties:{tpl:{const:"ficheInfoElement",default:"ficheInfoElement",type:"string"}},required:["tpl"],type:"object"}},{auth:"bearer",constant:"MULTICONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:me.common81,if:me.common83,properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:me.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:me.common1,parentType:me.common15},required:["parentId","parentType","listInvite"],then:me.common85,type:"object"}},{auth:"none",constant:"GET_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/get/type/{type}/id/{id}/isLive/{isLive}/json/true",pathParams:{additionalProperties:!1,else:me.common52,if:me.common73,properties:{id:me.common1,isLive:me.common87,type:me.common15},required:["isLive","type","id"],then:me.common69,type:"object"},request:{additionalProperties:!1,properties:{dateLimit:me.common88,indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:me.common10},required:["name"],type:"object"}},required:["dateLimit","indexStep"],type:"object"}},{auth:"none",constant:"GET_NEWS_BY_ID",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/getbyids",request:{additionalProperties:!1,properties:{ids:{items:me.common11,type:"array"}},required:["ids"],type:"object"}},{auth:"bearer",constant:"ADD_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/save",request:{additionalProperties:!1,anyOf:[me.common89,me.common90,me.common91],else:me.common81,if:me.common83,properties:{json:me.common67,markdownActive:me.common87,mediaFile:me.common92,mediaImg:me.common94,mentions:me.common96,parentId:me.common1,parentType:me.common15,scope:me.common100,tags:me.common26,text:me.common1,type:me.common101},required:["scope","markdownActive","parentId","parentType","type","json"],then:me.common85,type:"object"}},{auth:"bearer",constant:"ADD_IMAGE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/newsImage/docType/image/contentKey/slider",pathParams:me.common102,request:{additionalProperties:!1,properties:{newsImage:me.common16},required:["newsImage"],type:"object"}},{auth:"bearer",constant:"ADD_FILE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}}/input/newsFile/docType/file",pathParams:me.common102,request:{additionalProperties:!1,properties:{newsFile:me.common16},required:["newsFile"],type:"object"}},{auth:"bearer",constant:"DELETE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/delete/id/{id}",pathParams:me.common104,request:{additionalProperties:!1,properties:{isLive:me.common105},required:["isLive"],type:"object"}},{auth:"bearer",constant:"UPDATE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/update",request:{additionalProperties:!1,anyOf:[me.common89,me.common90,me.common91],else:me.common81,if:me.common83,properties:{idNews:me.common11,markdownActive:me.common87,mediaFile:me.common92,mediaImg:me.common94,mentions:me.common96,parentId:me.common1,parentType:me.common15,scope:me.common100,tags:me.common26,text:me.common1,type:me.common101},required:["idNews","scope","markdownActive","parentId","parentType","type"],then:me.common85,type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:me.common106,if:me.common108,properties:{childId:me.common11,childType:me.common15,comment:me.common1,connectType:me.common110,parentId:me.common11,parentType:me.common101},required:["parentId","parentType","childId","childType","connectType"],then:me.common111,type:"object"}},{auth:"none",constant:"GET_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/index/type/{type}/id/{id}/json/true",pathParams:me.common113},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:me.common10,contextId:me.common11,contextType:me.common115,mentions:me.common116,parentCommentId:me.common11,path:me.common10,text:me.common1},required:["text","contextId","contextType"],type:"object"}},{auth:"bearer",constant:"DELETE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/delete/id/{id}",pathParams:me.common104},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:me.common11,params:{properties:{mentions:me.common116,text:me.common1},required:["text"],type:"object"}},required:["id","params"],type:"object"}},{auth:"none",constant:"SEARCH_TAGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/tags/search?q={q}",pathParams:{additionalProperties:!1,properties:{q:me.common1},required:["q"],type:"object"}},{auth:"none",constant:"SHOW_VOTE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/action/list/type/{type}/id/{id}/actionType/vote/json/true",pathParams:me.common113},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:me.common119,type:"array"},fediverse:me.common120,filters:me.common121,indexMin:{const:0,default:0,type:"number"},indexStep:me.common66,initType:me.common121,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:me.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:me.common1,notSourceKey:me.common67,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":me.common122},type:"object"},searchTags:me.common27,searchType:{items:me.common119,type:"array"}},required:["name","searchType","countType","indexMin","indexStep","initType","count","notSourceKey","filters","fediverse"],type:"object"}},{auth:"none",constant:"CITY_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{minimum:5,type:"integer"},indexMin:{minimum:0,type:"integer"},locality:me.common121,name:me.common1,searchBy:{const:"ALL",default:"ALL",type:"string"},searchType:{const:["cities"],default:["cities"],items:{enum:["cities"],type:"string"},type:"array"}},required:["name","locality","searchType"],type:"object"}},{auth:"none",constant:"SUGGESTION_INPUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{default:20,minimum:20,type:"integer"},indexMin:me.common124,name:me.common1,searchType:{items:{enum:["organizations","projects","poi"],type:"string"},type:"array"}},required:["name","searchType","indexMin","indexMax"],type:"object"}},{auth:"none",constant:"GET_PROJECTS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common125,fediverse:me.common120,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":me.common127,"parent.@userId":me.common127},"links.contributors.@userId":me.common127},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":me.common128},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":me.common128,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":me.common128},type:"object"}},required:["$or"],type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common125},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_PROJECTS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:me.common132,request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common125,fediverse:me.common120,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":me.common127,"parent.@{pathParams.id}":me.common127},"links.contributors.@{pathParams.id}":me.common127},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128},type:"object"}},required:["$or"],type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common125},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_POIS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common134,fediverse:me.common120,filters:{additionalProperties:!1,default:{"parent.@userId":me.common127},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":me.common128},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_POIS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:me.common132,request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common134,fediverse:me.common120,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":me.common127},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_ORGANIZATIONS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common135,fediverse:me.common120,filters:{additionalProperties:!1,default:{"links.members.@userId":me.common127,"links.members.@userId.isInviting":me.common137,"links.members.@userId.toBeValidated":me.common137},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":me.common128,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":me.common138,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":me.common138},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common135},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_ORGANIZATIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,else:me.common52,if:me.common73,properties:{id:me.common1,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],then:me.common69,type:"object"},request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common135,fediverse:me.common120,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":me.common127,"links.members.@{pathParams.id}.isInviting":me.common137,"links.members.@{pathParams.id}.toBeValidated":me.common137},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":me.common138,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":me.common138},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common135},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_MEMBERS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common141,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$":me.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":me.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdminPending$":me.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":me.common143,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":me.common145,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":me.common138},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common141},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_MEMBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/organizations/id/{id}/canSee/true",pathParams:me.common104,request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common141,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.memberOf.@{pathParams.id}":me.common127,"links.memberOf.@{pathParams.id}.isInviting":me.common137,"links.memberOf.@{pathParams.id}.toBeValidated":me.common137},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":me.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdminPending$":me.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":me.common143,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":me.common145,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":me.common143},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common141},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_FRIENDS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:me.common6,request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common148,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.friends.@{pathParams.id}":me.common127,"links.friends.@{pathParams.id}.isInviting":me.common137,"links.friends.@{pathParams.id}.toBeValidated":me.common137},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":me.common143,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":me.common143},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common148},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIPTIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common150,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[me.common152],default:{"links.followers.@userId":me.common127,"links.followers.@{userId}.isInviting":me.common137,"links.followers.@{userId}.toBeValidated":me.common137},patternProperties:me.common155,type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common150},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIPTIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:me.common6,request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common150,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[me.common152],default:{"links.followers.@{pathParams.id}":me.common127,"links.followers.@{pathParams.id}.isInviting":me.common137,"links.followers.@{pathParams.id}.toBeValidated":me.common137},patternProperties:me.common155,type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common150},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIBERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common148,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[me.common156],default:{"links.follows.@userId":me.common127,"links.follows.@{userId}.isInviting":me.common137,"links.follows.@{userId}.toBeValidated":me.common137},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":me.common138,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":me.common138},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common148},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,allOf:[{else:me.common52,if:me.common73,then:me.common69}],properties:{id:me.common1,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common148,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[me.common156],default:{"links.follows.@{pathParams.id}":me.common127},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common148},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_CONTRIBUTORS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common141,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$":me.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":me.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdminPending$":me.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":me.common143,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":me.common145,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":me.common138},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common141},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_CONTRIBUTORS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/projects/id/{id}/canSee/true",pathParams:me.common104,request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common141,fediverse:me.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.projects.@{pathParams.id}":me.common127,"links.projects.@{pathParams.id}.isInviting":me.common137,"links.projects.@{pathParams.id}.toBeValidated":me.common137},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":me.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":me.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdminPending$":me.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":me.common143,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":me.common145,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":me.common143},type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common141},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common159,fediverse:me.common120,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":me.common128},type:"object"},isParcours:me.common3,"preferences.private":me.common120},required:["preferences.private"],type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,searchType:me.common159},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES_FILTERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:me.common67,countType:me.common161,fediverse:me.common120,fields:me.common159,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":me.common163}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":me.common163,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":me.common166,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":me.common166}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:me.common169},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:me.common169,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":me.common165}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":me.common163}}],type:"object"},indexMin:me.common124,indexStep:me.common131,initType:me.common121,locality:me.common121,name:me.common1,notSourceKey:me.common67,ranges:{additionalProperties:!1,default:{Cooperative:me.common170,GovernmentOrganization:me.common170,Group:me.common170,LocalBusiness:me.common170,NGO:me.common170,citoyens:me.common170,projects:me.common170},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":me.common122},type:"object"},searchType:me.common161},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"CONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/connect",request:{additionalProperties:!1,allOf:[{if:me.common83,then:{properties:{connectType:{const:"friend",default:"friend"}}}},{if:me.common171,then:{properties:{connectType:{enum:["admin","member"]}}}},{if:me.common173,then:{properties:{connectType:{enum:["admin","contributor"]}}}},{if:me.common175,then:{properties:{connectType:{default:"attendee",enum:["attendee","connect"]}}}}],properties:{childId:me.common178,childType:me.common179,connectType:{enum:["admin","member","contributor","attendee","friend","connect"],type:"string"},parentId:me.common11,parentType:me.common180},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"bearer",constant:"DISCONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/disconnect",request:{additionalProperties:!1,allOf:[{if:me.common83,then:{properties:{connectType:{default:"friends",enum:["friends","followers"]}}}},{if:me.common171,then:{properties:{connectType:{default:"members",enum:["members","followers"]}}}},{if:me.common173,then:{properties:{connectType:{default:"contributors",enum:["contributors","followers"]}}}},{if:me.common175,then:{properties:{connectType:{default:"attendees",enum:["attendees","followers"]}}}}],properties:{childId:me.common178,childType:me.common179,connectType:{enum:["members","contributors","attendees","friends","followers"],type:"string"},parentId:me.common11,parentType:me.common180},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_KEY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/getinfo/key/{slug}",pathParams:{additionalProperties:!1,properties:{slug:{pattern:"^([a-zA-Z0-9-_]+)$",type:"string"}},required:["slug"],type:"object"}},{auth:"bearer",constant:"GET_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/config/type/citoyens/id/{id}/json/true",pathParams:me.common6},{auth:"bearer",constant:"DELETE_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue?index={index}",pathParams:{properties:{index:me.common66},type:"object"},request:{additionalProperties:!1,properties:{collection:me.common181,id:me.common182,path:{const:"preferences.search.@{pathParams.index}",default:"preferences.search.@{pathParams.index}",type:"string"},pull:{const:"preferences.search",type:"string"},value:me.common121},required:["id","collection","path","pull","value"],type:"object"}},{auth:"bearer",constant:"ADD_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue",request:{additionalProperties:!1,properties:{arrayForm:me.common165,collection:me.common181,id:me.common182,path:{const:"preferences.search",default:"preferences.search",type:"string"},value:{additionalProperties:!1,properties:{description:me.common1,locality:{patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:me.common45,required:["name","type"]}},type:"object"},name:me.common1,tags:me.common27,url:me.common1},required:["url","name"],type:"object"}},required:["id","collection","path","arrayForm","value"],type:"object"}},{auth:"bearer",constant:"ADD_ORGANIZATION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:me.common55,collection:{const:"organizations",default:"organizations",type:"string"},email:me.common2,geo:me.common59,geoPosition:me.common63,id:me.common11,key:{const:"organization",default:"organization",type:"string"},name:{minLength:3,type:"string"},preferences:me.common183,role:{enum:["admin","member"],type:"string"},scope:me.common121,shortDescription:me.common1,tags:me.common27,type:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},url:me.common4},required:["id","collection","key","name","type","role","scope"],type:"object"}},{auth:"bearer",constant:"ADD_PROJECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:me.common55,collection:{const:"projects",default:"projects",type:"string"},geo:me.common59,geoPosition:me.common63,id:me.common11,key:{const:"project",default:"project",type:"string"},name:me.common1,parent:me.common186,preferences:{default:{crowdfunding:!0,isOpenData:!1,isOpenEdition:!1},properties:{crowdfunding:me.common87,isOpenData:me.common105,isOpenEdition:me.common105},required:["isOpenData","isOpenEdition"],type:"object"},public:me.common87,scope:me.common121,shortDescription:me.common1,tags:me.common27,url:me.common4},required:["id","collection","key","parent","name","public","scope"],type:"object"}},{auth:"bearer",constant:"ADD_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:me.common55,collection:me.common191,description:me.common1,geo:me.common59,geoPosition:me.common63,id:me.common11,key:me.common191,name:me.common1,parent:me.common186,scope:me.common121,tags:me.common27,type:me.common49,urls:me.common27},required:["id","collection","key","parent","type","name"],type:"object"}},{auth:"bearer",constant:"ADD_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,else:{required:["openingHours"]},if:{properties:{recurrency:me.common140}},properties:{address:me.common55,collection:me.common192,email:me.common2,endDate:me.common193,geo:me.common59,geoPosition:me.common63,id:me.common11,key:{const:"event",default:"event",type:"string"},name:me.common1,openingHours:{default:["","","","","","",""],items:{anyOf:[{const:"",type:"string"},{additionalProperties:!1,properties:{dayOfWeek:{enum:["Mo","Tu","We","Th","Fr","Sa","Su"],type:"string"},hours:{default:[],items:{additionalProperties:!1,properties:{closes:me.common194,opens:me.common194},required:["opens","closes"],type:"object"},type:"array"}},required:["dayOfWeek","hours"],type:"object"}]},maxItems:7,minItems:7,type:"array"},organizer:me.common186,parent:{additionalProperties:!1,patternProperties:me.common189,type:"object"},preferences:{default:{isOpenData:!1,isOpenEdition:!1},properties:{isOpenData:me.common105,isOpenEdition:me.common105},required:["isOpenData","isOpenEdition"],type:"object"},public:me.common87,recurrency:me.common105,scope:me.common121,shortDescription:me.common1,startDate:me.common193,tags:me.common27,timeZone:me.common1,type:me.common195,url:me.common4},required:["id","collection","key","organizer","type","name","scope"],startBeforeEnd:!0,then:{required:["startDate","endDate"]},type:"object"}},{auth:"bearer",constant:"DELETE_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/poi/id/{id}",pathParams:me.common104,request:me.common8},{auth:"bearer",constant:"DELETE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/events/id/{id}/",pathParams:me.common104,request:me.common8},{auth:"bearer",constant:"DELETE_ELEMENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/{type}/id/{id}",pathParams:{additionalProperties:!1,properties:{id:me.common11,type:me.common1},required:["type","id"],type:"object"},request:me.common8},{auth:"bearer",constant:"ADD_IMAGE_ELEMENT",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/qqfile/docType/image/contentKey/profil",pathParams:{additionalProperties:!1,properties:{folder:{enum:["badges","events"],type:"string"},ownerId:me.common11},required:["folder","ownerId"],type:"object"},request:{additionalProperties:!1,properties:{qqfile:me.common16,qqfilename:me.common1,qqtotalfilesize:me.common196,qquuid:me.common11},required:["qquuid","qqfilename","qqtotalfilesize","qqfile"],type:"object"}},{auth:"bearer",constant:"LINK_VALIDATE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/validate",request:{additionalProperties:!1,properties:{childId:me.common5,childType:me.common41,linkOption:{enum:["isInviting","toBeValidated","isAdminPending"],type:"string"},parentId:me.common11,parentType:me.common180},required:["childId","childType","parentType","parentId"],type:"object"}},{auth:"none",constant:"SEARCH_MEMBER_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/searchmemberautocomplete",request:{additionalProperties:!1,properties:{search:me.common1,searchMode:{default:"personOnly",enum:["personOnly","organizationOnly","mixte"],type:"string"}},required:["search","searchMode"],type:"object"}},{auth:"bearer",constant:"GET_NOTIFICATIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/getnotifications/type/{type}/id/{id}",pathParams:me.common197,request:{additionalProperties:!1,properties:{indexMin:me.common88},type:"object"}},{auth:"bearer",constant:"GET_NOTIFICATIONS_COUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/getnotifications/type/{type}/id/{id}",pathParams:me.common197,request:{additionalProperties:!1,properties:{refreshTimestamp:me.common196},type:"object"}},{auth:"bearer",constant:"NOTIFICATION_UPDATE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/update",request:{additionalProperties:!1,properties:{action:{enum:["seen","read"],type:"string"},all:me.common67},required:["action","all"],type:"object"}},{auth:"bearer",constant:"REMOVE_ALL_NOTIFICATIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/removeall"},{auth:"bearer",constant:"MARK_NOTIFICATION_AS_READ",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/marknotificationasread",request:me.common104},{auth:"none",constant:"ACTIVITYPUB_SEARCH",contentType:"application/x-www-form-urlencoded",method:"GET",params:[me.common16],path:"/api/activitypub/search?address={address}",pathParams:{additionalProperties:!1,properties:{address:me.common1},required:["address"],type:"object"}},{auth:"bearer",constant:"ACTIVITYPUB_LINK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/activitypub/link",request:{additionalProperties:!1,properties:{action:{enum:["undo_follow","accept_invitation","reject_invitation","undo_accept","undo_request_follow","follow","remove_follow","accept_follower","reject_follower","remove_follower","remove_invitation"],type:"string"},actor:{additionalProperties:!1,properties:{id:me.common1,name:me.common1,type:{enum:["person"],type:"string"}},required:["id","type","name"],type:"object"},payload:me.common4},required:["action","payload","actor"],type:"object"}},{auth:"none",constant:"ACTIVITYPUB_GET_COMMUNITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/activitypub/getcommunity/userId/${userId}/type/${type}/actor/person",pathParams:{additionalProperties:!1,properties:{type:{enum:["follows","followers"],type:"string"},userId:me.common11},required:["userId","type"],type:"object"}},{auth:"none",constant:"GET_BADGE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/page/type/badges/id/{id}/json/true",pathParams:me.common104},{auth:"none",constant:"GET_EMETTEUR_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/badge/json/true"},{auth:"bearer",constant:"ADD_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{collection:me.common200,criteria:{additionalProperties:!1,properties:{narrative:me.common1},required:["narrative"],type:"object"},description:me.common1,id:me.common11,isParcours:me.common105,issuer:{additionalProperties:!1,patternProperties:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:me.common1,type:{enum:["citoyens","organizations","projects"],type:"string"}},required:["type"],type:"object"}},type:"object"},key:me.common201,name:me.common1,parent:{additionalProperties:!1,patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:{name:me.common1,type:me.common200},required:["type"],type:"object"}},type:"object"},preferences:me.common183,public:me.common87,scope:me.common121,tags:me.common27},required:["id","collection","key","name","public","scope","issuer","criteria"],type:"object"}},{auth:"bearer",constant:"ASSIGN_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/badges/assign",request:{additionalProperties:!1,properties:{award:{patternProperties:{"^[0-9a-f]{24}$":me.common44},type:"object"},badgeId:me.common11,collection:me.common200,evidences:{items:{additionalProperties:!1,properties:{narative:me.common1,url:me.common4},required:["narative"],type:"object"},type:"array"},key:me.common201,narative:me.common1,scope:me.common121},required:["key","collection","badgeId","award"],type:"object"}},{auth:"none",constant:"GET_EVENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/agenda",request:{additionalProperties:!1,properties:{count:me.common105,countType:{const:["events"],default:["events"],type:"array"},endDateUTC:me.common193,fediverse:me.common105,indexMin:me.common88,indexStep:{default:100,type:"integer"},locality:{patternProperties:{"^[^\\s]+$":{type:"object"}},type:"object"},name:me.common1,searchType:{const:["events"],default:["events"],items:me.common1,type:"array"},startDate:me.common66,startDateUTC:me.common193,type:me.common195},required:["searchType","indexMin","indexStep","startDate","startDateUTC","fediverse"],type:"object"}},{auth:"bearer",constant:"SHARE_EVENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:me.common106,if:me.common108,properties:{childId:me.common11,childType:me.common15,comment:me.common1,connectType:me.common110,parentId:me.common11,parentType:me.common192},required:["parentId","childId","childType","connectType","parentType"],then:me.common111,type:"object"}},{auth:"bearer",constant:"INVITE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:me.common81,if:me.common83,properties:{listInvite:{additionalProperties:!1,minProperties:1,properties:{citoyens:me.common202,invites:{patternProperties:{"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$":{additionalProperties:!1,properties:{email:me.common2,isAdmin:me.common206,msg:me.common1,name:me.common1,roles:me.common27},required:["name","email"],type:"object"}},type:"object"},organizations:me.common202,projects:me.common202},type:"object"},parentId:me.common1,parentType:me.common15},required:["parentId","parentType","listInvite"],then:me.common85,type:"object"}},{auth:"bearer",constant:"FOLLOW",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/follow",request:{additionalProperties:!1,properties:{childId:me.common178,childType:me.common179,parentId:me.common11,parentType:me.common180},required:["childId","childType","parentType","parentId"],type:"object"}},{auth:"none",constant:"GET_COSTUM_JSON",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/cms/getcostumjson?slug={slug}",pathParams:{slug:me.common1}}]},ye=function(){return k((function e(){w(this,e)}),[{key:"getAccessToken",value:function(){throw new Error("getAccessToken() doit être implémenté")}},{key:"setAccessToken",value:function(e){throw new Error("setAccessToken() doit être implémenté")}},{key:"getRefreshToken",value:function(){throw new Error("getRefreshToken() doit être implémenté")}},{key:"setRefreshToken",value:function(e){throw new Error("setRefreshToken() doit être implémenté")}},{key:"clear",value:function(){throw new Error("clear() doit être implémenté")}}])}(),ve=function(){function e(){var t;return w(this,e),(t=v(this,e))._accessToken=null,t._refreshToken=null,t}return E(e,ye),k(e,[{key:"getAccessToken",value:function(){return this._accessToken}},{key:"setAccessToken",value:function(e){this._accessToken=e}},{key:"getRefreshToken",value:function(){return this._refreshToken}},{key:"setRefreshToken",value:function(e){this._refreshToken=e}},{key:"clear",value:function(){this._accessToken=null,this._refreshToken=null}}])}(),we=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cocolight";return w(this,e),(t=v(this,e)).prefix=n,t}return E(e,ye),k(e,[{key:"getAccessToken",value:function(){return"undefined"!=typeof localStorage?localStorage.getItem("".concat(this.prefix,"_accessToken")):null}},{key:"setAccessToken",value:function(e){"undefined"!=typeof localStorage&&localStorage.setItem("".concat(this.prefix,"_accessToken"),e)}},{key:"getRefreshToken",value:function(){return"undefined"!=typeof localStorage?localStorage.getItem("".concat(this.prefix,"_refreshToken")):null}},{key:"setRefreshToken",value:function(e){"undefined"!=typeof localStorage&&localStorage.setItem("".concat(this.prefix,"_refreshToken"),e)}},{key:"clear",value:function(){"undefined"!=typeof localStorage&&(localStorage.removeItem("".concat(this.prefix,"_accessToken")),localStorage.removeItem("".concat(this.prefix,"_refreshToken")))}}])}(),ge=function(){function e(){var t;return w(this,e),(t=v(this,e))._currentBaseURL=null,t}return E(e,ye),k(e,[{key:"use",value:function(e){if(!e)throw new Error("baseURL est requis");this._currentBaseURL=e.replace(/\/+$/,"")}},{key:"_ensureContext",value:function(){if(!this._currentBaseURL)throw new Error("baseURL non défini. Appelez use(baseURL)")}},{key:"getServers",value:function(){throw new Error("getServers() doit être implémenté")}},{key:"exportAll",value:function(){throw new Error("exportAll() doit être implémenté")}}])}(),ke=function(){function e(){var t;return w(this,e),(t=v(this,e))._storage=new Map,t}return E(e,ge),k(e,[{key:"getAccessToken",value:function(){var e;return this._ensureContext(),(null===(e=this._storage.get(this._currentBaseURL))||void 0===e?void 0:e.accessToken)||null}},{key:"setAccessToken",value:function(e){this._ensureContext();var t=this._storage.get(this._currentBaseURL)||{};this._storage.set(this._currentBaseURL,O(O({},t),{},{accessToken:e}))}},{key:"getRefreshToken",value:function(){var e;return this._ensureContext(),(null===(e=this._storage.get(this._currentBaseURL))||void 0===e?void 0:e.refreshToken)||null}},{key:"setRefreshToken",value:function(e){this._ensureContext();var t=this._storage.get(this._currentBaseURL)||{};this._storage.set(this._currentBaseURL,O(O({},t),{},{refreshToken:e}))}},{key:"clear",value:function(){this._ensureContext(),this._storage.delete(this._currentBaseURL)}},{key:"getServers",value:function(){return D(this._storage.keys())}},{key:"exportAll",value:function(){return Object.fromEntries(this._storage.entries())}}])}(),be=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cocolight";return w(this,e),(t=v(this,e)).prefix=n,t}return E(e,ge),k(e,[{key:"_key",value:function(e){return"".concat(this.prefix,"_tokens_").concat(e)}},{key:"_getData",value:function(){this._ensureContext();var e=localStorage.getItem(this._key(this._currentBaseURL));return e?JSON.parse(e):{}}},{key:"_setData",value:function(e){localStorage.setItem(this._key(this._currentBaseURL),JSON.stringify(e))}},{key:"getAccessToken",value:function(){return this._getData().accessToken||null}},{key:"setAccessToken",value:function(e){var t=this._getData();t.accessToken=e,this._setData(t)}},{key:"getRefreshToken",value:function(){return this._getData().refreshToken||null}},{key:"setRefreshToken",value:function(e){var t=this._getData();t.refreshToken=e,this._setData(t)}},{key:"clear",value:function(){localStorage.removeItem(this._key(this._currentBaseURL))}},{key:"getServers",value:function(){var e=this;return Object.keys(localStorage).filter((function(t){return t.startsWith("".concat(e.prefix,"_tokens_"))})).map((function(t){return t.replace("".concat(e.prefix,"_tokens_"),"")}))}},{key:"exportAll",value:function(){var e,t={},n=b(this.getServers());try{for(n.s();!(e=n.n()).done;){var r=e.value,o=localStorage.getItem(this._key(r));o&&(t[r]=JSON.parse(o))}}catch(e){n.e(e)}finally{n.f()}return t}}])}();c.addType("oid",(function(e){return new fe.ObjectID(e)}));var xe=function(){function e(){var t,n,r,c,u,l,d=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},f=d.baseURL,m=d.accessToken,h=d.refreshToken,g=d.refreshUrl,k=void 0===g?"/api/cocolight/refreshtoken":g,b=d.endpoints,_=void 0===b?he.endpoints:b,T=d.timeout,E=void 0===T?3e4:T,A=d.debug,P=void 0!==A&&A,O=d.maxRetries,I=void 0===O?0:O,j=d.circuitBreakerThreshold,C=void 0===j?5:j,D=d.circuitBreakerResetTime,L=void 0===D?6e4:D,N=d.fromJSONValue,M=void 0===N||N,q=d.tokenStorageStrategy,R=void 0===q?null:q;if(w(this,e),x(l=v(this,e),"_imageFields",["profilImageUrl","profilThumbImageUrl","profilMediumImageUrl","profilMarkerImageUrl","profilBannerUrl","profilRealBannerUrl","imagePath","imageThumbPath","docPath"]),x(l,"_dateFields",["modified","created","updated","birthDate","lastLoginDate","startDate","endDate","date","issuedOn"]),x(l,"_startBeforeEndValidate",(function(e,t){if(!t.startDate||!t.endDate)return!0;var n=new Date(t.startDate)<new Date(t.endDate);return n||(l._startBeforeEndValidate.errors=[{instancePath:"",schemaPath:"#/startBeforeEnd",keyword:"startBeforeEnd",params:{},message:"startDate must be before endDate"}]),n})),!f)throw new B('Le paramètre "baseURL" est obligatoire.',500);l.__entityTag="ApiClient",l._baseURL=f,l._refreshUrl=k,l._endpoints=_,l._debug=P;var z=null;if(l._offlineClientManager=null,l._fromJSONValue=M,Object.defineProperty(l,"userId",{get:function(){return z},set:function(){throw new Error("Modification directe de userId non autorisée.")},enumerable:!0}),l._setUserId=function(e){z=e,l._logger.debug("[ApiClient] userId set: ".concat(e))},l._ajv=new o({strict:!1,useDefaults:!0,allErrors:!0,verbose:!0}),i(l._ajv),l._ajv.addKeyword({keyword:"startBeforeEnd",type:"object",errors:!0,validate:l._startBeforeEndValidate}),l._logger=p({transport:{target:"pino-pretty",options:{colorize:!0}},level:P?"debug":"info"}),l._client=a.create({baseURL:f,timeout:E}),I>0&&(s(l._client,{retries:I,retryDelay:s.exponentialDelay,retryCondition:function(e){return s.isNetworkError(e)||s.isRetryableError(e)},onRetry:function(e,t,n){l._logger.warn("[Retry] Tentative #".concat(e," pour ").concat(null==n?void 0:n.url)),l.emit("retryAttempt",{retryCount:e,url:null==n?void 0:n.url})}}),l._logger.info("[ApiClient] Retry activé : ".concat(I," max"))),l._breakerThreshold=C,l._breakerResetTime=L,l._breakerErrorCount=0,l._breakerOpen=!1,l._lastBreakerOpenTime=null,l._accessToken=null,l._refreshToken=null,R instanceof ge&&R.use(l._baseURL),l._tokenStorage=R||new ve,"function"!=typeof(null===(t=l._tokenStorage)||void 0===t?void 0:t.getAccessToken)||"function"!=typeof(null===(n=l._tokenStorage)||void 0===n?void 0:n.setAccessToken)||"function"!=typeof(null===(r=l._tokenStorage)||void 0===r?void 0:r.getRefreshToken)||"function"!=typeof(null===(c=l._tokenStorage)||void 0===c?void 0:c.setRefreshToken)||"function"!=typeof(null===(u=l._tokenStorage)||void 0===u?void 0:u.clear))throw new Error("[ApiClient] La stratégie de stockage des tokens n’est pas valide. Elle doit implémenter les méthodes requises.");h&&l.setRefreshToken(h),m&&l.setToken(m);var F=l._tokenStorage.getAccessToken();F&&l.setToken(F);var U=l._tokenStorage.getRefreshToken();return U&&l.setRefreshToken(U),l._client.interceptors.response.use((function(e){return e}),function(){var e=y(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=t.config)._retry){e.next=4;break}throw l._logger.error("[ApiClient] Requête déjà retentée, échec définitif."),t;case 4:if(!t.response||401!==t.response.status||!l._refreshToken){e.next=26;break}return n._retry=!0,e.prev=6,l._logger.info("[ApiClient] Tentative de refresh du token..."),e.next=10,l._refreshAccessToken();case 10:if(!e.sent){e.next=18;break}return l._logger.info("[ApiClient] Token rafraîchi avec succès."),n.headers.Authorization="Bearer "+l.getToken(),l._logger.info("[ApiClient] Retente la requête originale avec le nouveau token."),e.abrupt("return",l._client.request(n));case 18:throw l.resetSession(),new B("Impossible de rafraîchir le token.",401);case 20:e.next=26;break;case 22:throw e.prev=22,e.t0=e.catch(6),l.resetSession(),new B("Erreur lors du rafraîchissement du token.",401,e.t0);case 26:throw t;case 27:case"end":return e.stop()}}),e,null,[[6,22]])})));return function(t){return e.apply(this,arguments)}}()),l}return E(e,n),k(e,[{key:"setToken",value:function(e){this._accessToken=e,this._tokenStorage.setAccessToken(e),this._client.defaults.headers.common.Authorization="Bearer "+e;var t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug("[ApiClient] userId extrait et défini : ".concat(t))),this._logger.debug("[ApiClient] setToken: ".concat(e))}},{key:"getToken",value:function(){return this._accessToken}},{key:"setRefreshToken",value:function(e){if(this._refreshToken=e,this._tokenStorage.setRefreshToken(e),null===this.userId){var t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug("[ApiClient] userId extrait depuis refreshToken : ".concat(t)))}this._logger.debug("[ApiClient] setRefreshToken: ".concat(e))}},{key:"getRefreshToken",value:function(){return this._refreshToken}},{key:"isConnected",get:function(){return!!this._accessToken}},{key:"_getIdFromToken",value:function(e){if(!e)return null;try{var t=u(e);return this._logger.debug("[ApiClient] Payload décodé :",t),t.id||t.userId||null}catch(e){return this._logger.error("[ApiClient] Erreur lors du décodage du token :",e),null}}},{key:"_refreshAccessToken",value:(d=y(S().mark((function e(){var t,n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._refreshToken){e.next=2;break}return e.abrupt("return",!1);case 2:return t=a.create({baseURL:this._baseURL,timeout:1e4,headers:{"Content-Type":"application/json"}}),e.prev=3,e.next=6,t.post(this._refreshUrl,{refreshToken:this._refreshToken});case 6:if(!(n=e.sent).data||!n.data.token){e.next=12;break}return this.setToken(n.data.token),n.data.refreshToken&&this.setRefreshToken(n.data.refreshToken),this.emit("refreshSuccess",n.data),e.abrupt("return",!0);case 12:return e.abrupt("return",!1);case 15:return e.prev=15,e.t0=e.catch(3),this.emit("refreshFailed",{error:e.t0.message}),this.resetSession(),this._logger.error("[ApiClient] Refresh Error : ".concat(e.t0.message)),e.abrupt("return",!1);case 21:case"end":return e.stop()}}),e,this,[[3,15]])}))),function(){return d.apply(this,arguments)})},{key:"_checkCircuitBreaker",value:function(){return!this._breakerOpen||Date.now()-this._lastBreakerOpenTime>this._breakerResetTime&&(this._breakerOpen=!1,this._breakerErrorCount=0,this._logger.warn("[ApiClient] Circuit breaker réinitialisé"),this.emit("circuitBreakerReset"),!0)}},{key:"_updateCircuitBreakerError",value:function(){this._breakerErrorCount+=1,this._logger.warn("[ApiClient] Erreur #".concat(this._breakerErrorCount," sur ").concat(this._breakerThreshold)),this._breakerErrorCount>=this._breakerThreshold&&(this._breakerOpen=!0,this._lastBreakerOpenTime=Date.now(),this._logger.error("[ApiClient] Circuit breaker ACTIVÉ - L'API est considérée indisponible"),this.emit("circuitBreakerOpen",{timestamp:this._lastBreakerOpenTime}))}},{key:"_resetCircuitBreakerSuccess",value:function(){this._breakerErrorCount=0,this._breakerOpen&&(this._breakerOpen=!1,this._logger.warn("[ApiClient] Circuit breaker refermé suite à un succès"))}},{key:"_resolveSpecialValuesInPlace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={userId:function(){return t.userId},accessToken:function(){return t._accessToken},refreshToken:function(){return t._refreshToken},baseURL:function(){return t._baseURL},pathParams:function(e){var r=t._getValueByPath(n,e);return null!=r?r:void 0}},o=/@(?:\{([^}]+)\}|([\w.]+))/g,i=function(e){return"string"!=typeof e?e:e.replace(o,(function(t,n,o){if(n){if(n.startsWith("pathParams.")){var i=n.substring(11),a=r.pathParams(i);return null!=a?a:"@{".concat(n,"}")}var s=r[n];if("function"==typeof s){var c=s();return null!=c?c:"@{".concat(n,"}")}return"@{".concat(n,"}")}if(o){if(o.startsWith("pathParams.")){var u=o.match(/^pathParams\.([^.]+)(.*)$/);if(u){var p=u[1],l=u[2],d=r.pathParams(p);return null!=d?d+l:"@".concat(o)}return"@".concat(o)}var f=r[o];if("function"==typeof f){var m=f();return null!=m?m:"@".concat(o)}return"@".concat(o)}return e}))},a=function(e){if(function(e){return e&&"object"===N(e)&&("function"==typeof e.pipe||"undefined"!=typeof Buffer&&e instanceof Buffer)}(e))return e;if(Array.isArray(e))return e.map(a);if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e)){for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var o=j(r[n],2),s=o[0],c=o[1];t[i(s)]=a(c)}return t}return"string"==typeof e?i(e):e};return a(e)}},{key:"_cleanSchemaLeftoverAlias",value:function(e){var t=this,n=/@\w+/;if(Array.isArray(e))return e.map((function(e){return t._cleanSchemaLeftoverAlias(e)}));if(e&&"object"===N(e)){for(var r={},o=0,i=Object.keys(e);o<i.length;o++){var a=i[o],s=e[a];if(!n.test(a)){if("default"===a){if("string"==typeof s&&n.test(s))continue;if(s&&"object"===N(s)){var c=this._cleanSchemaLeftoverAlias(s);Object.keys(c).length>0&&(r[a]=c);continue}}"string"==typeof s&&n.test(s)||(r[a]=this._cleanSchemaLeftoverAlias(s))}}return r}return e}},{key:"safeCall",value:(l=y(S().mark((function e(t){var n,r,o,i=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,n=i.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=i[o];return e.next=4,t.apply(void 0,r);case 4:return e.abrupt("return",e.sent);case 7:throw e.prev=7,e.t0=e.catch(0),this._logger.error("[ApiClient.safeCall] Erreur: ".concat(e.t0.message)),e.t0;case 11:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(e){return l.apply(this,arguments)})},{key:"callEndpoint",value:(t=y(S().mark((function t(n){var r,o,i,a,s,c,u,p,l,d,f,m,h,y,v,w,g,k,b,_,T,E,A,P,I,j,C,D,L,N,M,q,R,U,$=this,G=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=G.length>1&&void 0!==G[1]?G[1]:{},i=!(G.length>2&&void 0!==G[2])||G[2],a=!(G.length>3&&void 0!==G[3])||G[3],s=this._endpoints.find((function(e){return e.constant===n}))){t.next=6;break}throw new B("Endpoint introuvable : ".concat(n),404);case 6:if(c=s.path,u=s.method,p=s.contentType,l=s.auth,d=s.pathParams,f=s.request,m=s.responses,h=(u||"GET").toLowerCase(),v={"Content-Type":y=p||"application/json"},!this._accessToken){t.next=14;break}"bearer"===l?v.Authorization="Bearer ".concat(this._accessToken):l&&"none"!==l||v.Authorization||(v.Authorization="Bearer ".concat(this._accessToken)),t.next=16;break;case 14:if("bearer"!==l){t.next=16;break}throw new B("Token requis pour l'endpoint sécurisé : ".concat(n),401);case 16:if(w=c,g={},!d){t.next=30;break}if(k=d,"none"===l&&null===this.userId&&(k=this._cleanSchemaLeftoverAlias(d)),b=o.pathParams||{},(_=this._ajv.compile(k))(b)){t.next=28;break}throw T=this._ajvErrorHuman(_.errors),this.emit("validationError",{stage:"pathParams",errors:_.errors}),new z("callEndpoint: ".concat(n," - Path parameter validation failed."),400,T,_.errors);case 28:g=this._resolveSpecialValuesInPlace(b),w=w.replace(/\{(\w+)\}/g,(function(e,t){var n=g[t];if(void 0!==n)return encodeURIComponent(n);throw new B("Path param manquant ou non résolu : {".concat(t,"}"),400)}));case 30:if(!f){t.next=43;break}if(E=f,"none"===l&&null===this.userId&&(E=this._cleanSchemaLeftoverAlias(f)),delete(A=O({},o)).pathParams,P=e.stripNullsInPlace(A),(I=this._ajv.compile(E))(P)){t.next=42;break}throw j=I.errors?this._ajvErrorHuman(I.errors):[],this.emit("validationError",{stage:"request",errors:I.errors}),new z("callEndpoint: ".concat(n," - Request validation failed."),400,j,I.errors);case 42:o=this._resolveSpecialValuesInPlace(P,g);case 43:if(null===(r=this._offlineClientManager)||void 0===r||!r.isOffline()){t.next=55;break}if("function"!=typeof this._offlineClientManager._enqueueOfflineAction){t.next=53;break}return this._logger.warn("[ApiClient] Mode dégradé : mise en file de ".concat(n)),t.next=48,this._offlineClientManager._enqueueOfflineAction({constant:n,data:o,options:{transformResponseData:i,validateResponseSchema:a}});case 48:return this._logger.info("[ApiClient] Requête ".concat(n," mise en file (offline mode)")),this.emit("queuedOffline",{constant:n,reason:"offlineMode",data:o}),t.abrupt("return",{data:null,offline:!0});case 53:throw this._logger.warn("[ApiClient] Mode dégradé actif mais offlineManager non initialisé correctement"),new B("Mode hors-ligne actif, mais gestionnaire offline non disponible.",503);case 55:if(this._checkCircuitBreaker()){t.next=64;break}if(!1!==(null===(C=this._offlineClientManager)||void 0===C||null===(D=C.isOffline)||void 0===D?void 0:D.call(C))||"function"!=typeof this._offlineClientManager._enqueueOfflineAction){t.next=63;break}return this._logger.warn("[ApiClient] Circuit breaker actif → mise en file de ".concat(n)),t.next=60,this._offlineClientManager._enqueueOfflineAction({constant:n,data:o,options:{transformResponseData:i,validateResponseSchema:a}});case 60:return this._logger.info("[ApiClient] Requête ".concat(n," mise en file (circuit breaker)")),this.emit("queuedOffline",{constant:n,reason:"circuitBreaker",data:o}),t.abrupt("return",{data:null,breaker:!0});case 63:throw new F("Le circuit breaker est activé, impossible d'appeler l'API");case 64:return"application/json"===y||"multipart/form-data"===y?L=o:"application/x-www-form-urlencoded"===y&&(L=e.toURLSearchParams(o)),this._logger.debug("[ApiClient] callEndpoint: ".concat(n," -> ").concat(w,", method=").concat(h)),t.prev=66,t.next=69,this._client.request(x({url:w,method:h,headers:v},"get"===h?"params":"data",L));case 69:if(N=t.sent,!a){t.next=80;break}if(M=N.status.toString(),!(q=null==m?void 0:m[M])){t.next=80;break}if((R=this._ajv.compile(q))(N.data)){t.next=80;break}throw U=this._ajvErrorHuman(R.errors),this.emit("validationError",{stage:"response",errors:R.errors}),new z("Response validation failed.",M,U,R.errors);case 80:return this._resetCircuitBreakerSuccess(),"function"==typeof i?N.data=i(N.data):!0===i&&(N.data=this._transformData(N.data)),Array.isArray(s.postActions)&&s.postActions.forEach((function(e){var t=e.path?$._getValueByPath(N.data,e.path):null;switch(e.type){case"setToken":$.setToken(t);break;case"setRefreshToken":$.setRefreshToken(t);break;case"resetSession":$.resetSession();break;case"emitEvent":e.event&&($.emit(e.event,t),$._logger.debug("[ApiClient] Event émis : ".concat(e.event),t));break;case"callMethod":"function"==typeof $[e.method]?($[e.method](),$._logger.debug("[ApiClient] Méthode appelée : ".concat(e.method))):$._logger.warn("[ApiClient] Méthode inconnue : ".concat(e.method));break;default:$._logger.warn("[ApiClient] Action inconnue : ".concat(e.type))}})),t.abrupt("return",N);case 86:if(t.prev=86,t.t0=t.catch(66),this._updateCircuitBreakerError(),this._logger.error("[ApiClient] Erreur lors de l'appel de ".concat(n,": ").concat(t.t0.message)),!(t.t0 instanceof z)){t.next=94;break}throw t.t0;case 94:throw new B("Erreur lors de l'appel de l'API : ".concat(t.t0.message),t.t0.response?t.t0.response.status:500,t.t0.response?t.t0.response.data:null);case 95:case"end":return t.stop()}}),t,this,[[66,86]])}))),function(e){return t.apply(this,arguments)})},{key:"_ajvErrorHuman",value:function(e){try{return new r(e).errors.map((function(e){return e.message}))}catch(t){return this._logger.error("[ApiClient] _ajvErrorHuman",t),e.map((function(e){return e.message}))}}},{key:"checkAndThrowApiResponseError",value:function(e){var t=e.data;if(!t||"object"!==N(t))return e;if("boolean"==typeof t.result&&!1===t.result)throw new U(t.msg||"Erreur inconnue",e.status,t);if(t.resultErrors&&"object"===N(t.resultErrors)&&"boolean"==typeof t.resultErrors.result&&!1===t.resultErrors.result)throw new U(t.resultErrors.msg||"Erreur inconnue",e.status,t);return e}},{key:"resetSession",value:function(){this.setToken(null),this.setRefreshToken(null),this._setUserId(null),this._tokenStorage.clear(),delete this._client.defaults.headers.common.Authorization,this._logger.info("[ApiClient] Session utilisateur réinitialisée."),this.emit("sessionReset")}},{key:"_getValueByPath",value:function(e,t){if(t)return t.split(".").reduce((function(e,t){return e&&e[t]}),e)}},{key:"_transformData",value:function(e){var t,n,r=this;if(e&&"object"===N(e))if(null!==(t=e.resultGoods)&&void 0!==t&&t.msg)e=this._normalizeJsonData(O({msg:e.resultGoods.msg},e));else if(null!==(n=e.resultErrors)&&void 0!==n&&n.msg)e=this._normalizeJsonData(O({msg:e.resultErrors.msg},e));else if(e.results&&"object"===N(e.results)&&!Array.isArray(e.results))e.results=Object.keys(e.results).map((function(t){return r._normalizeJsonData(O({id:t},e.results[t]))}));else if(Array.isArray(e.results))e.results=e.results.map((function(e){return r._normalizeJsonData(e)}));else if(e.news&&Array.isArray(e.news)&&0===e.news.length)e=e.news;else if(e.news&&"object"===N(e.news)&&!Array.isArray(e.news))e=Object.keys(e.news).map((function(t){return r._normalizeJsonData(O({id:t},e.news[t]))}));else if(e.notif&&"object"===N(e.notif)&&!Array.isArray(e.notif))e.notif=Object.keys(e.notif).map((function(t){return r._normalizeJsonData(O({id:t},e.notif[t]))}));else if(e.citoyens&&"object"===N(e.citoyens)&&!Array.isArray(e.citoyens)&&e.organizations&&"object"===N(e.organizations)&&!Array.isArray(e.organizations))e=[].concat(D(Object.keys(e.citoyens).map((function(t){return r._normalizeJsonData(O({id:t},e.citoyens[t]))}))),D(Object.keys(e.organizations).map((function(t){return r._normalizeJsonData(O({id:t},e.organizations[t]))}))));else if(e.citoyens&&"object"===N(e.citoyens)&&!Array.isArray(e.citoyens))e=Object.keys(e.citoyens).map((function(t){return r._normalizeJsonData(O({id:t},e.citoyens[t]))}));else if(e.cities&&"object"===N(e.cities)&&!Array.isArray(e.cities))e=Object.keys(e.cities).map((function(t){return r._normalizeJsonData(O({id:t},e.cities[t]))}));else if(e.cities&&Array.isArray(e.cities)&&0===e.cities.length)e=e.cities;else if(e.newComment&&"object"===N(e.newComment))e.newComment=this._normalizeJsonData(O({},e.newComment));else if(Array.isArray(e))e=e.map((function(e){return r._normalizeJsonData(e)}));else if(e.map&&"object"===N(e.map))e.map=this._normalizeJsonData(e.map);else if(e.object&&"object"===N(e.object))e.object=this._normalizeJsonData(e.object);else if("object"===N(e)&&Object.keys(e).length>0){var o=Object.keys(e).every((function(e){return/^[0-9a-fA-F]{24}$/.test(e)}));e=o?Object.keys(e).map((function(t){return O({id:t},r._normalizeJsonData(e[t]))})):this._normalizeJsonData(e)}return e}},{key:"_normalizeJsonData",value:function(e){var t,n,r,o,i,a,s=this;if(!e||"object"!==N(e))return e;if(null!==(t=e=this._normalizeRecursively(e))&&void 0!==t&&null!==(t=t.mediaImg)&&void 0!==t&&t.images&&Array.isArray(e.mediaImg.images)&&e.mediaImg.images.length>0&&(e.mediaImg.countImages=e.mediaImg.images.length),null!==(n=e)&&void 0!==n&&null!==(n=n.mediaFile)&&void 0!==n&&n.files&&Array.isArray(e.mediaFile.files)&&e.mediaFile.files.length>0&&(e.mediaFile.countFiles=e.mediaFile.files.length),null!==(r=e)&&void 0!==r&&null!==(r=r.src)&&void 0!==r&&r.changes&&"object"===N(e.src.changes)&&Object.keys(e.src.changes).length>0&&Object.keys(e.src.changes).forEach((function(t){e.src.changes[t]&&(e.src.changes[t]=s._ensureFullURL(e.src.changes[t]))})),null!==(o=e)&&void 0!==o&&o.openingHours&&Array.isArray(e.openingHours)&&e.openingHours.length>0&&(e.openingHours=e.openingHours.filter((function(e){return e.dayOfWeek&&e.hours&&e.hours[0]&&e.hours[0].opens}))),e.replies&&"object"===N(e.replies)&&Object.keys(e.replies).length>0&&(e.replies=Object.keys(e.replies).map((function(t){return s._normalizeJsonData(O({id:t},e.replies[t]))}))),null!==(i=e)&&void 0!==i&&i.author&&"object"===N(e.author)&&Object.keys(e.author).length>0&&!("profilThumbImageUrl"in e.author)){var u=Object.keys(e.author)[0];e.author=O({},e.author[u])}return null!==(a=e)&&void 0!==a&&a.timeAgo&&delete e.timeAgo,this._fromJSONValue?c.fromJSONValue(e):e}},{key:"_ensureFullURL",value:function(e){if(!e)return e;if(!(e=e.trim())||/^https?:\/\//i.test(e))return e;var t="/";return t=this._baseURL.endsWith("/")&&e.startsWith("/")||this._baseURL.endsWith("/")||e.startsWith("/")?"":"/","".concat(this._baseURL).concat(t).concat(e)}},{key:"_normalizeString",value:function(e){return"true"===e||"false"!==e&&e}},{key:"_normalizeId",value:function(e){return e._id&&e._id.$id&&/^[0-9a-fA-F]{24}$/.test(e._id.$id)&&(e.id=e._id.$id,e._id={$type:"oid",$value:e._id.$id}),e.id&&e.id.$id&&/^[0-9a-fA-F]{24}$/.test(e.id.$id)&&(e._id={$type:"oid",$value:e.id.$id},e.id=e.id.$id),e}},{key:"_normalizeDate",value:function(e){return e&&"object"===N(e)&&"number"==typeof e.sec?{$date:1e3*e.sec}:"number"==typeof e?{$date:1e3*e}:e}},{key:"_normalizeImage",value:function(e){return"string"==typeof e&&""!==e.trim()?this._ensureFullURL(e):e}},{key:"_normalizeRecursively",value:function(e){var t=this;if("string"==typeof e)return this._normalizeString(e);if(Array.isArray(e))return e.map((function(e){return t._normalizeRecursively(e)}));if(null!==e&&"object"===N(e)){var n={};return Object.keys(e).forEach((function(r){var o=t._normalizeRecursively(e[r]);t._dateFields.includes(r)&&(o=t._normalizeDate(o)),t._imageFields.includes(r)&&(o=t._normalizeImage(o)),"content"===r&&o&&"object"===N(o)&&o.image&&(o.image=t._normalizeImage(o.image)),n[r]=o})),this._normalizeId(n)}return e}},{key:"getRequestSchema",value:function(e){var t=this._endpoints.find((function(t){return t.constant===e}));return(null==t?void 0:t.request)||null}},{key:"getPathSchema",value:function(e){var t;return(null===(t=this._endpoints.find((function(t){return t.constant===e})))||void 0===t?void 0:t.pathParams)||null}},{key:"onEvent",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=0,n=["retryAttempt","queuedOffline","circuitBreakerOpen","circuitBreakerReset","refreshSuccess","refreshFailed","sessionReset","validationError","offlineModeChanged","userLoggedIn"];t<n.length;t++){var r=n[t];"function"==typeof e[r]&&this.on(r,e[r])}}},{key:"getDeclaredEvents",value:function(){var e,t=new Set,n=b(this._endpoints);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(Array.isArray(r.postActions)){var o,i=b(r.postActions);try{for(i.s();!(o=i.n()).done;){var a=o.value;"emitEvent"===a.type&&a.event&&t.add(a.event)}}catch(e){i.e(e)}finally{i.f()}}}}catch(e){n.e(e)}finally{n.f()}return Array.from(t)}}],[{key:"stripNullsInPlace",value:function(t){if(t&&"object"===N(t)&&t.value&&"function"==typeof t.value.pipe)return t;if(Array.isArray(t))for(var n=t.length-1;n>=0;n--)null===t[n]||void 0===t[n]?t.splice(n,1):"object"===N(t[n])&&e.stripNullsInPlace(t[n]);else if(t&&"object"===N(t))for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(null===t[r]||void 0===t[r]?delete t[r]:"object"===N(t[r])&&e.stripNullsInPlace(t[r]));return t}},{key:"toURLSearchParams",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this._buildParams(e,new URLSearchParams,t)}},{key:"_buildParams",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==N(e)||null===e)throw new TypeError("La donnée doit être un objet non nul.");var r=n.dots,o=void 0!==r&&r,i=n.indexes,a=void 0!==i&&i,s=n.metaTokens,c=void 0===s||s,u=[];function p(e){return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)}function l(e){return e.endsWith("[]")?e.slice(0,-2):e}function d(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e?e.concat(t).map((function(e,t){return e=l(e),!n&&t?"[".concat(e,"]"):e})).join(n?".":""):t}function f(e){return null==e?"":e instanceof Date?e.toISOString():(e instanceof Blob||e instanceof File||e instanceof ArrayBuffer||ArrayBuffer.isView(e),e)}return function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];null==n||u.includes(n)||(u.push(n),Object.entries(n).forEach((function(n){var i=j(n,2),s=i[0],u=i[1];void 0!==u&&function(e,n,r){if(e&&"object"===N(e)){if(n.endsWith("{}"))return n=c?n:n.slice(0,-2),t.append(d(r,n,o),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(p)||n.endsWith("[]"))return n=l(n),e.forEach((function(e,i){if(null!=e){var s=a?d(r.concat(n),i,o):"".concat(d(r,n,o),"[]");t.append(s,f(e))}})),!1}return!!p(e)||(t.append(d(r,n,o),f(e)),!1)}(u,s.trim(),r)&&e(u,r.concat(l(s)))})),u.pop())}(e),t}}]);var t,l,d}(),_e=function(){return k((function e(t){w(this,e),this.client=t instanceof xe?t:new xe(t),this.loggedUser=null}),[{key:"isConnected",get:function(){return this.client.isConnected}},{key:"userId",get:function(){return this.client.userId}},{key:"login",value:(r=y(S().mark((function e(t,n){var r=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.client.safeCall(y(S().mark((function e(){var o;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.client.callEndpoint("AUTHENTICATE_URL",{email:t,password:n});case 2:return o=e.sent,r.loggedUser=new de(r.client,o.data.user,{EndpointApi:ae,Organization:ue,Project:le,Event:se,Poi:pe,Badge:ie,News:ce}),e.abrupt("return",r.loggedUser);case 5:case"end":return e.stop()}}),e)})))));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"meIsconnected",value:(n=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.client.isConnected&&this.client.userId){e.next=2;break}throw new R("User not connected",401);case 2:return this.client._logger.info("UserApi","meIsconnected",this.client.userId),this.loggedUser=new de(this.client,{id:this.client.userId},{EndpointApi:ae,Organization:ue,Project:le,Event:se,Poi:pe,Badge:ie,News:ce}),e.abrupt("return",this.loggedUser);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"register",value:(t=y(S().mark((function e(){var t,n,r,o,i,a=this,s=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(t=s.length>0&&void 0!==s[0]?s[0]:{}).name,r=t.username,o=t.email,i=t.pwd,e.abrupt("return",this.client.safeCall(y(S().mark((function e(){var t,s;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.client.callEndpoint("PERSON_REGISTER",{name:n,username:r,email:o,pwd:i});case 2:if(!1!==(null==(s=e.sent)||null===(t=s.data)||void 0===t?void 0:t.result)){e.next=5;break}throw new U(s.data.msg,s.status,s.data);case 5:return e.abrupt("return",s.data);case 6:case"end":return e.stop()}}),e)})))));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"recoverPassword",value:(e=y(S().mark((function e(t){var n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.client.safeCall(y(S().mark((function e(){var r,o;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.client.callEndpoint("PASSWORD_RECOVERY",{email:t});case 2:if(!1!==(null==(o=e.sent)||null===(r=o.data)||void 0===r?void 0:r.result)){e.next=5;break}throw new U(o.data.msg,o.status,o.data);case 5:return e.abrupt("return",o.data);case 6:case"end":return e.stop()}}),e)})))));case 1:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r}(),Te=function(){function e(t,n){w(this,e),this._loggedUser=t,this._client=n}return k(e,[{key:"me",value:(a=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loggedUser){e.next=2;break}throw new $("Accès refusé : utilisateur non authentifié.");case 2:return e.next=4,this._loggedUser.get();case 4:return e.abrupt("return",this._loggedUser);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"user",value:(i=y(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t.id||t.slug){e.next=5;break}return e.abrupt("return",new de(this._client,t,{EndpointApi:ae,Organization:ue,Project:le,Event:se,Poi:pe,Badge:ie,News:ce}));case 5:return n=new de(this._client,t,{EndpointApi:ae,Organization:ue,Project:le,Event:se,Poi:pe,Badge:ie,News:ce}),e.next=8,n.get();case 8:return e.abrupt("return",n);case 9:e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(0),console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :",e.t0.message),e.t0;case 15:case"end":return e.stop()}}),e,this,[[0,11]])}))),function(e){return i.apply(this,arguments)})},{key:"organization",value:(o=y(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,n=new ue(this._client,t,{EndpointApi:ae,User:de,Project:le,Event:se,Poi:pe,Badge:ie,News:ce}),t.id||t.slug){e.next=4;break}throw new Error("Vous devez fournir un id ou un slug pour créer une instance Organization.");case 4:return e.next=6,n.get();case 6:return e.abrupt("return",n);case 9:throw e.prev=9,e.t0=e.catch(0),console.error("[Api.organization] Erreur lors de la création d'un objet organisation :",e.t0.message),e.t0;case 13:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(e){return o.apply(this,arguments)})},{key:"project",value:(r=y(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,n=new le(this._client,t,{EndpointApi:ae,User:de,Event:se,Poi:pe,Badge:ie,News:ce}),t.id||t.slug){e.next=4;break}throw new Error("Vous devez fournir un id ou un slug pour créer une instance Project.");case 4:return e.next=6,n.get();case 6:return e.abrupt("return",n);case 9:throw e.prev=9,e.t0=e.catch(0),console.error("[Api.project] Erreur lors de la création d'un objet projet :",e.t0.message),e.t0;case 13:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(e){return r.apply(this,arguments)})},{key:"client",get:function(){return this._client}},{key:"endpointApi",get:function(){return new ae(this._client)}},{key:"logout",value:function(){this.loggedUser=null,this._client.resetSession(),this._client._logger.info("UserApi: User logged out")}}],[{key:"userLogin",value:(n=y(S().mark((function t(n,r,o){var i;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.userApi(o),t.next=3,e.userApiLogin(i,n,r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"userApi",value:function(e){try{return new _e(e)}catch(e){throw console.error("[Api.userApi] Erreur lors de la création d'un objet utilisateur :",e.message),e}}},{key:"userApiLogin",value:(t=y(S().mark((function t(n,r,o){var i,a,s;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,n){t.next=3;break}throw new R("userApi is not defined");case 3:if(n.client){t.next=5;break}throw new R("userApi.client is not defined");case 5:if(!n.client.isConnected){t.next=12;break}return t.next=8,n.meIsconnected();case 8:return i=t.sent,t.abrupt("return",new e(i,n.client));case 12:if(r&&o){t.next=14;break}throw new R("email and password are required");case 14:return t.next=16,n.login(r,o);case 16:return a=t.sent,t.abrupt("return",new e(a,n.client));case 18:t.next=26;break;case 20:if(t.prev=20,t.t0=t.catch(0),!(t.t0 instanceof B)){t.next=25;break}if(null===t.t0||void 0===t.t0||null===(s=t.t0.details)||void 0===s||!s.error){t.next=25;break}throw new $(t.t0.details.error,t.t0.status,t.t0.details);case 25:throw t.t0;case 26:case"end":return t.stop()}}),t,null,[[0,20]])}))),function(e,n,r){return t.apply(this,arguments)})}]);var t,n,r,o,i,a}();function Ee(){return Ee=y(S().mark((function e(){var t,n,r,o,i,a=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("memory"!==(t=a.length>0&&void 0!==a[0]?a[0]:"auto")){e.next=3;break}return e.abrupt("return",new ke);case 3:if("localStorage"!==t){e.next=9;break}if("undefined"==typeof window||!window.localStorage){e.next=8;break}return e.abrupt("return",new be);case 8:throw new Error("localStorage n’est pas disponible dans cet environnement.");case 9:if("file"!==t){e.next=17;break}if("undefined"==typeof window||!window.localStorage){e.next=12;break}throw new Error("Le stockage fichier n’est pas disponible côté navigateur.");case 12:return e.next=14,Promise.resolve().then((function(){return Re}));case 14:return n=e.sent,r=n.MultiServerFileStorageStrategy,e.abrupt("return",new r);case 17:if("undefined"==typeof window||!window.localStorage){e.next=21;break}return e.abrupt("return",new be);case 21:return e.next=23,Promise.resolve().then((function(){return Re}));case 23:return o=e.sent,i=o.MultiServerFileStorageStrategy,e.abrupt("return",new i);case 26:case"end":return e.stop()}}),e)}))),Ee.apply(this,arguments)}function Ae(){return Ae=y(S().mark((function e(){var t,n,r,o,i,a=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("memory"!==(t=a.length>0&&void 0!==a[0]?a[0]:"auto")){e.next=3;break}return e.abrupt("return",new ve);case 3:if("localStorage"!==t){e.next=9;break}if("undefined"==typeof window||!window.localStorage){e.next=8;break}return e.abrupt("return",new we);case 8:throw new Error("localStorage is not available in this environment.");case 9:if("file"!==t){e.next=17;break}if("undefined"==typeof window||!window.localStorage){e.next=12;break}throw new Error("file storage is not available in this environment.");case 12:return e.next=14,Promise.resolve().then((function(){return ze}));case 14:return n=e.sent,r=n.FileStorageStrategy,e.abrupt("return",new r);case 17:if("auto"!==t){e.next=27;break}if("undefined"==typeof window||!window.localStorage){e.next=22;break}return e.abrupt("return",new we);case 22:return e.next=24,Promise.resolve().then((function(){return ze}));case 24:return o=e.sent,i=o.FileStorageStrategy,e.abrupt("return",new i);case 27:case"end":return e.stop()}}),e)}))),Ae.apply(this,arguments)}var Pe=function(){return k((function e(){w(this,e)}),[{key:"loadQueue",value:(t=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("loadQueue() doit être implémenté");case 1:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"saveQueue",value:(e=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("saveQueue(queue) doit être implémenté");case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t}(),Oe=function(){function e(){var t;return w(this,e),(t=v(this,e))._queue=[],t}return E(e,Pe),k(e,[{key:"loadQueue",value:(n=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._queue);case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"saveQueue",value:(t=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._queue=D(t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]);var t,n}(),Se=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cocolight-api-offline-queue";return w(this,e),(t=v(this,e)).key=n,t}return E(e,Pe),k(e,[{key:"loadQueue",value:(n=y(S().mark((function e(){var t;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=localStorage.getItem(this.key),e.abrupt("return",t?JSON.parse(t):[]);case 5:return e.prev=5,e.t0=e.catch(0),e.abrupt("return",[]);case 8:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(){return n.apply(this,arguments)})},{key:"saveQueue",value:(t=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{localStorage.setItem(this.key,JSON.stringify(t))}catch(e){console.warn("[Offline] Échec du stockage localStorage",e)}case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]);var t,n}();function Ie(){return je.apply(this,arguments)}function je(){return je=y(S().mark((function e(){var t,n,r,o,i,a=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("memory"!==(t=a.length>0&&void 0!==a[0]?a[0]:"auto")){e.next=3;break}return e.abrupt("return",new Oe);case 3:if("localStorage"!==t){e.next=9;break}if("undefined"==typeof window||!window.localStorage){e.next=8;break}return e.abrupt("return",new Se);case 8:throw new Error("localStorage is not available in this environment.");case 9:if("file"!==t){e.next=17;break}if("undefined"==typeof window||!window.localStorage){e.next=12;break}throw new Error("file storage is not available in this environment.");case 12:return e.next=14,Promise.resolve().then((function(){return Ue}));case 14:return n=e.sent,r=n.FileOfflineStorage,e.abrupt("return",new r);case 17:if("auto"!==t){e.next=27;break}if("undefined"==typeof window||!window.localStorage){e.next=22;break}return e.abrupt("return",new Se);case 22:return e.next=24,Promise.resolve().then((function(){return Ue}));case 24:return o=e.sent,i=o.FileOfflineStorage,e.abrupt("return",new i);case 27:case"end":return e.stop()}}),e)}))),je.apply(this,arguments)}var Ce=function(){function e(t){if(w(this,e),!(t&&t instanceof xe))throw new Error("[OfflineClientManager] apiClient doit être une instance de ApiClient");this._clients=new Map,this._client=t}return k(e,[{key:"getClient",value:(a=y(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n="".concat(t.baseURL,"|").concat(t.accessToken),!this._clients.has(n)){e.next=3;break}return e.abrupt("return",this._clients.get(n));case 3:return r=new xe({baseURL:t.baseURL,accessToken:t.accessToken,refreshToken:t.refreshToken,debug:this._client._debug}),this._clients.set(n,r),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"replayAction",value:(i=y(S().mark((function e(t){var n,r,o,i,a,s;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getClient(t.meta);case 2:return n=e.sent,e.prev=3,e.next=6,n.callEndpoint(t.constant,t.data,null===(r=null===(o=t.options)||void 0===o?void 0:o.transformResponseData)||void 0===r||r,null===(i=null===(a=t.options)||void 0===a?void 0:a.validateResponseSchema)||void 0===i||i);case 6:return s=e.sent,this._client._logger.info("[OfflineReplay] Succès ".concat(t.constant," sur ").concat(t.meta.baseURL)),e.abrupt("return",s);case 11:throw e.prev=11,e.t0=e.catch(3),this._client._logger.error("[OfflineReplay] Échec ".concat(t.constant),e.t0.message),e.t0;case 15:case"end":return e.stop()}}),e,this,[[3,11]])}))),function(e){return i.apply(this,arguments)})},{key:"startOfflineMonitoring",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.interval,r=void 0===n?3e4:n,o=t.disableOfflineMonitoring;void 0!==o&&o||this._monitoringStarted||(this._monitoringStarted=!0,this._offlineMode="undefined"!=typeof window&&"undefined"!=typeof navigator&&!navigator.onLine,"undefined"!=typeof window&&(window.addEventListener("online",(function(){return e.setOfflineMode(!1)})),window.addEventListener("offline",(function(){return e.setOfflineMode(!0)}))),this._pingInterval=setInterval(y(S().mark((function t(){var n;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e._offlineMode,t.prev=1,t.next=4,e._client._client.head("/api/cocolight/infoserver",{timeout:5e3});case 4:n&&e.setOfflineMode(!1),t.next=11;break;case 7:t.prev=7,t.t0=t.catch(1),e._client._logger.error("[OfflineMonitor] ping() échoué → passage en offline"),e.setOfflineMode(!0);case 11:case"end":return t.stop()}}),t,null,[[1,7]])}))),r))}},{key:"setOfflineMode",value:function(e){this._offlineMode!==e&&(this._offlineMode=e,"function"==typeof this._emit&&this._client.emit("offlineModeChanged",e),this._client._logger.info("[ApiClient] Mode offline : ".concat(e," (set depuis monitoring)")),e||"function"!=typeof this._replayOfflineQueue||this._replayOfflineQueue())}},{key:"isOffline",value:function(){return!!this._offlineMode}},{key:"_enqueueOfflineAction",value:(o=y(S().mark((function e(t){var n,r,o,i,a,s,c;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.constant,r=t.data,o=t.options,i=void 0===o?{}:o,a=this._client.getToken()||this._client.getRefreshToken(),"required"!==((null==(s=this._client._endpoints.find((function(e){return e.constant===n})))?void 0:s.authPolicy)||("none"===(null==s?void 0:s.auth)?"none":"required"))||a){e.next=7;break}return this._client._logger.warn("[Offline] Action ignorée : token requis mais absent (".concat(n,")")),e.abrupt("return");case 7:return c={constant:n,data:r,options:i,meta:{baseURL:this._client._baseURL,accessToken:this._client.getToken(),refreshToken:this._client.getRefreshToken(),timestamp:Date.now()}},this._offlineQueue.push(c),e.next=11,this._offlineQueueStorage.saveQueue(this._offlineQueue);case 11:this._client._logger.info("[Offline] Action mise en file : ".concat(n));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_replayOfflineQueue",value:(r=y(S().mark((function e(){var t,n,r,o,i=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=D(this._offlineQueue),this._offlineQueue=[],e.next=4,this._offlineQueueStorage.saveQueue([]);case 4:n=b(t),e.prev=5,o=S().mark((function e(){var t,n,o,a;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.value,n=i._client._endpoints.find((function(e){return e.constant===t.constant})),o=(null==n?void 0:n.authPolicy)||("none"===(null==n?void 0:n.auth)?"none":"required"),a=t.meta.accessToken||t.meta.refreshToken,"required"!==o||a){e.next=7;break}return i._client._logger.warn("[Offline] Rejetée : token requis manquant (".concat(t.constant,")")),e.abrupt("return",1);case 7:return e.prev=7,e.next=10,i.replayAction(t);case 10:e.next=16;break;case 12:e.prev=12,e.t0=e.catch(7),i._client._logger.error("[Offline] Relecture échouée :",e.t0.message),i._offlineQueue.push(t);case 16:case"end":return e.stop()}}),e,null,[[7,12]])})),n.s();case 8:if((r=n.n()).done){e.next=14;break}return e.delegateYield(o(),"t0",10);case 10:if(!e.t0){e.next=12;break}return e.abrupt("continue",12);case 12:e.next=8;break;case 14:e.next=19;break;case 16:e.prev=16,e.t1=e.catch(5),n.e(e.t1);case 19:return e.prev=19,n.f(),e.finish(19);case 22:return e.next=24,this._offlineQueueStorage.saveQueue(this._offlineQueue);case 24:case"end":return e.stop()}}),e,this,[[5,16,19,22]])}))),function(){return r.apply(this,arguments)})},{key:"_initOfflineQueue",value:(n=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._offlineQueueStorage=t,e.next=3,t.loadQueue();case 3:this._offlineQueue=e.sent;case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})}],[{key:"attachTo",value:(t=y(S().mark((function t(n){var r,o,i=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:{},n._offlineClientManager=new e(n),t.next=4,Ie((null==r?void 0:r.offlineStorageStrategy)||"auto");case 4:return o=t.sent,t.next=7,n._offlineClientManager._initOfflineQueue(o);case 7:null!=r&&r.disableOfflineMonitoring||n._offlineClientManager.startOfflineMonitoring(r);case 8:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}]);var t,n,r,o,i,a}(),De=O(O({ApiClient:xe,Api:Te,error:G,reactive:ne},ne),{},{tokenStorageStrategy:{createDefaultTokenStorageStrategy:function(){return Ae.apply(this,arguments)},TokenStorageStrategy:ye,createDefaultMultiServerTokenStorageStrategy:function(){return Ee.apply(this,arguments)},MultiServerTokenStorageStrategy:ge},OfflineClientManager:Ce});function Le(){return(Le=y(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,import("stream");case 2:return n=e.sent,r=n.Readable,e.abrupt("return",r.from(t));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ne(){return(Ne=y(S().mark((function e(){var t,n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,import("stream");case 2:return t=e.sent,n=t.PassThrough,e.abrupt("return",new n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Me=Object.freeze({__proto__:null,bufferToReadable:function(e){return Le.apply(this,arguments)},createPassThrough:function(){return Ne.apply(this,arguments)}}),qe=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"tokens.json",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f.join(d.homedir(),".config","cocolight");return w(this,e),(t=v(this,e)).filePath=f.join(r,n),l.existsSync(r)||l.mkdirSync(r,{recursive:!0}),t}return E(e,ge),k(e,[{key:"_readFile",value:function(){if(!l.existsSync(this.filePath))return{};try{return JSON.parse(l.readFileSync(this.filePath,"utf8"))}catch(e){return{}}}},{key:"_writeFile",value:function(e){l.writeFileSync(this.filePath,JSON.stringify(e,null,2),"utf8")}},{key:"getAccessToken",value:function(){var e;return this._ensureContext(),(null===(e=this._readFile()[this._currentBaseURL])||void 0===e?void 0:e.accessToken)||null}},{key:"setAccessToken",value:function(e){this._ensureContext();var t=this._readFile();t[this._currentBaseURL]=O(O({},t[this._currentBaseURL]||{}),{},{accessToken:e}),this._writeFile(t)}},{key:"getRefreshToken",value:function(){var e;return this._ensureContext(),(null===(e=this._readFile()[this._currentBaseURL])||void 0===e?void 0:e.refreshToken)||null}},{key:"setRefreshToken",value:function(e){this._ensureContext();var t=this._readFile();t[this._currentBaseURL]=O(O({},t[this._currentBaseURL]||{}),{},{refreshToken:e}),this._writeFile(t)}},{key:"clear",value:function(){this._ensureContext();var e=this._readFile();delete e[this._currentBaseURL],this._writeFile(e)}},{key:"getServers",value:function(){return Object.keys(this._readFile())}},{key:"exportAll",value:function(){return this._readFile()}}])}(),Re=Object.freeze({__proto__:null,MultiServerFileStorageStrategy:qe}),Be=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"tokens.json",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f.join(d.homedir(),".config","cocolight");return w(this,e),(t=v(this,e)).dir=r,t.filePath=f.join(r,n),t._ensureDirectoryExists(),t}return E(e,ye),k(e,[{key:"_ensureDirectoryExists",value:function(){l.existsSync(this.dir)||l.mkdirSync(this.dir,{recursive:!0})}},{key:"_readFile",value:function(){if(!l.existsSync(this.filePath))return{};try{return JSON.parse(l.readFileSync(this.filePath,"utf8"))}catch(e){return console.error("Error reading token file:",e),{}}}},{key:"_writeFile",value:function(e){l.writeFileSync(this.filePath,JSON.stringify(e,null,2),"utf8")}},{key:"getAccessToken",value:function(){return this._readFile().accessToken||null}},{key:"setAccessToken",value:function(e){var t=this._readFile();t.accessToken=e,this._writeFile(t)}},{key:"getRefreshToken",value:function(){return this._readFile().refreshToken||null}},{key:"setRefreshToken",value:function(e){var t=this._readFile();t.refreshToken=e,this._writeFile(t)}},{key:"clear",value:function(){this._writeFile({})}}])}(),ze=Object.freeze({__proto__:null,FileStorageStrategy:Be}),Fe=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"offline-queue.json",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f.join(d.homedir(),".config","cocolight");return w(this,e),(t=v(this,e)).dir=r,t.filePath=f.join(r,n),t._ensureDirectoryExists(),t}return E(e,Pe),k(e,[{key:"_ensureDirectoryExists",value:function(){l.existsSync(this.dir)||l.mkdirSync(this.dir,{recursive:!0})}},{key:"_readFile",value:function(){if(!l.existsSync(this.filePath))return[];try{return JSON.parse(l.readFileSync(this.filePath,"utf8"))}catch(e){return console.error("Erreur lecture offline queue :",e),[]}}},{key:"_writeFile",value:function(e){try{l.writeFileSync(this.filePath,JSON.stringify(e,null,2),"utf8")}catch(e){console.warn("[OfflineQueue] Erreur d'écriture:",e)}}},{key:"loadQueue",value:(n=y(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._readFile());case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"saveQueue",value:(t=y(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._writeFile(t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]);var t,n}(),Ue=Object.freeze({__proto__:null,FileOfflineStorage:Fe});export{De as default};
1
+ import e from"bson-objectid";import t from"file-type";import{EventEmitter as r}from"events";import{AggregateAjvError as o}from"@segment/ajv-human-errors";import n from"ajv";import i from"ajv-formats";import s from"axios";import a from"axios-retry";import c from"ejson";import{jwtDecode as p}from"jwt-decode";import l from"pino";import d from"fs";import m from"os";import u from"path";class ApiError extends Error{constructor(e,t,r){super(e),this.name="ApiError",this.status=t,this.details=r}}class ApiClientError extends ApiError{constructor(e,t,r){super(e,t,r),this.name="ApiClientError"}}class ApiValidationError extends Error{constructor(e,t,r,o=null){super(e),this.name="ApiValidationError",this.status=t,this.messages=r,this.details=o}}class CircuitBreakerError extends ApiError{constructor(e){super(e,503),this.name="CircuitBreakerError"}}class ApiResponseError extends Error{constructor(e,t,r,o=null){super(e),this.name="ApiResponseError",this.status=t,this.responseData=r,this.details=o}}class ApiAuthenticationError extends ApiError{constructor(e,t,r){super(e,t,r),this.name="ApiAuthenticationError"}}var h=Object.freeze({__proto__:null,ApiAuthenticationError:ApiAuthenticationError,ApiClientError:ApiClientError,ApiError:ApiError,ApiResponseError:ApiResponseError,ApiValidationError:ApiValidationError,CircuitBreakerError:CircuitBreakerError});const y=[],f=new WeakMap,g=new WeakMap;function w(e){const t=()=>{try{y.push(t),e()}finally{y.pop()}};return t(),t}function _(e){let t=e;const r=new Set;return{get value(){const e=y[y.length-1];return e&&r.add(e),t},set value(e){t!==e&&(t=e,r.forEach((e=>e())))},subscribe:e=>(r.add(e),()=>r.delete(e)),__isSignal:!0}}function T(e,t=[]){if("object"!=typeof e||null===e)return e;if(Array.isArray(e))return function(e,t){return new Proxy(e,{get(e,r){if("string"==typeof r&&!isNaN(r)){const o=e[r];return A(o)?o:E(o,t.concat(r))}return Reflect.get(e,r)},set(e,r,o){const n=E(o,t.concat(r));return e[r]=n,!0}})}(e,t);if(e.__isReactive)return e;const r=new Map,o=new Proxy(e,{get(e,o,n){if("__raw"===o)return e;if("__isReactive"===o)return!0;if(!r.has(o)){const n=_(T(e[o],t.concat(o)));r.set(o,n)}return r.get(o).value},set(e,o,n){const i=T(n,t.concat(o));if(!r.has(o)){const e=_(i);r.set(o,e)}return r.get(o).value=i,e[o]=function(e){return function(e){return e&&!0===e.__isSignal}(e)?e.value:e}(i),!0},deleteProperty:(e,t)=>(r.delete(t),Reflect.deleteProperty(e,t))});return g.set(o,r),o}function E(e){return"object"!=typeof e||null===e||e.__isReactive?e:T(e)}function A(e){return!!e?.__isReactive}function b(e,t){return t.split(".").reduce(((e,t)=>e?e[t]:void 0),e)}function S(e,t,r){const o=t.split("."),n=o.pop();o.reduce(((e,t)=>(null==e[t]&&(e[t]={}),e[t])),e)[n]=r}function P(e,t){const r=t.split("."),o=r.pop(),n=r.reduce(((e,t)=>e?.[t]),e);n&&o in n&&delete n[o]}function v(e,t,r){const o=e.split(".")[0],n=r.transforms?.[o];return"function"==typeof n?n(t,r.serverData):t}function O(e,t=[],{cleanIfEqual:r=!0}={}){for(const o of t)w((()=>{const t=b(e.serverData,o),n=v(o,t,e),i=b(e.draftData,o),s=b(e.initialDraftData,o);JSON.stringify(i)!==JSON.stringify(s)||(r&&JSON.stringify(i)===JSON.stringify(n)?P(e.draftData,o):S(e.draftData,o,n))}))}function I(e){const t=Array.isArray(e.constructor.SCHEMA_CONSTANTS)?e.constructor.SCHEMA_CONSTANTS:[e.constructor.SCHEMA_CONSTANTS],r={allOf:[],$defs:{}};for(const o of t){const t=e.apiClient.getRequestSchema(o);if(!t)throw new ApiError(`Unable to find schema for ${o}.`);if(t.$defs)for(const[e,o]of Object.entries(t.$defs))r.$defs[e]||(r.$defs[e]=o);r.allOf.push(t)}const o={...e.serverData,...e.defaultFields};let n=e._extractWritableFields?.(r,o)||[];n=n.filter((t=>!e.removeFields.includes(t))),n=n.filter((e=>!["id"].includes(e))),O(e,n)}var j=Object.freeze({__proto__:null,autoSyncDraftFromSchema:I,computed:function(e){if(f.has(e))return f.get(e);const t=_();return w((()=>t.value=e())),f.set(e,t),t},effect:w,getSignals:function(e){return A(e)?g.get(e):null},isReactive:A,reactive:E,syncDraftOnServerChange:O,watch:function(e,t){let r;w((()=>{const o=e();o!==r&&(t(o,r),r=o)}))}});const{fromBuffer:k}=t;class BaseEntity{_draftData={};_initialDraftData={};_serverData=null;_calledFromSave=!1;_syncReactiveDraft=!1;constructor(e,t={},r={},o={}){if(this.__entityTag=o.entityTag||this.getEntityTag(this.constructor.name)||"BaseEntity",this.deps=r,"ApiClient"===this.getEntityTag(e?.__entityTag))this.apiClient=e,this.parent=null,this.userContext=null;else{if(!e?.apiClient)throw new ApiError("Parent invalide ou ApiClient manquant.");this.apiClient=e.apiClient,this.parent=e,"User"===this.getEntityTag(e?.__entityTag)?this.userContext=e:e?.userContext&&(this.userContext=e.userContext)}if("function"==typeof r.EndpointApi)this.endpointApi=new r.EndpointApi(this.apiClient);else{if("object"!=typeof r.EndpointApi)throw new ApiError("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=r.EndpointApi}this._serverData=null;const{draft:n,proxy:i}=this._buildDraftAndProxy({data:{...t,...this.defaultFields},serverData:this._serverData,constant:this.constructor.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this._initialDraftData=JSON.parse(JSON.stringify(n)),this._draftData=n,this.data=i}getEntityTag=e=>e?.replace(/^_/,"");get id(){return this._draftData.id||null}get slug(){return this._draftData.slug||null}_id(e){this._draftData.id=e}get isConnected(){return this.apiClient.isConnected}get userId(){return this.apiClient.userId}get draftData(){return this._draftData}get initialDraftData(){return this._initialDraftData}get serverData(){return this._serverData}get isMe(){return this.isConnected&&this.userId===this.userContext?.id}getEntityType(){return this.constructor.entityType}hasChanges(){return JSON.stringify(this._draftData)!==JSON.stringify(this._initialDraftData)}async refresh(){if(!this.id)throw new ApiError("Impossible de rafraîchir sans ID.");return this.get()}async save(){if(!this.isConnected)throw new ApiError("Non connecté.");this._calledFromSave=!0;try{const e={...this._draftData};if(!this.id&&"function"==typeof this._add)return await this._add(e),this.userContext&&await this.userContext.refresh(),await this.refresh();if("function"==typeof this._update){if(await this._update(e))return await this.refresh()}return this._serverData}finally{this._calledFromSave=!1}}static fromServerData(e,t,r){const o=new this(t,{},r);return o._setData(e),o}_setData(e){this.userContext&&this.userContext!==this&&this.apiClient._logger?.info?.(`[${this.__entityTag}] Mise à jour liée à userContext : ${this.userContext.id}`),this._serverData=E({...e});const{draft:t,proxy:r}=this._buildDraftAndProxy({data:{...e,...this.defaultFields},serverData:this._serverData,constant:this.constructor.SCHEMA_CONSTANTS,apiClient:this.apiClient,transforms:this.transforms,removeFields:this.removeFields});this._initialDraftData=JSON.parse(JSON.stringify(t)),this._draftData=t,this.data=r,this._syncReactiveDraft&&this.setupReactiveSync()}defaultFields={};removeFields=[];transforms={};async call(e,t={}){return this.apiClient.safeCall((async()=>{const r=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(r),r.data}))}async callNoConnected(e,t={}){if(this.isConnected)throw new ApiAuthenticationError("Vous devez ne devez pas être connecté pour faire cette action.");return this.call(e,t)}async callIsConnected(e,t={}){if(!this.isConnected)throw new ApiAuthenticationError("Vous devez être connecté pour faire cette action.");return"function"==typeof e?await e():this.call(e,t)}async callIsMe(e,t={}){if(!this.isMe)throw new ApiAuthenticationError("Vous devez être vous-même pour faire cette action.");return"function"==typeof e?await e():await this.callIsConnected(e,t)}async _validateImage(e){return await this._validateUploadInput(e,{allowedMimeTypes:["image/jpeg","image/png","image/jpg"],expectedType:"image"})}async _validateFile(e){return await this._validateUploadInput(e,{allowedMimeTypes:["application/pdf","text/plain","text/csv"],expectedType:"file"})}async _validateUploadInput(e,{allowedMimeTypes:t=[],expectedType:r="any"}){if(!e)throw new ApiValidationError("Le fichier est requis.");const o="undefined"==typeof window&&"undefined"!=typeof process;let n="",i=e;if("undefined"!=typeof File&&e instanceof File){if(n=e.type,!t.includes(n))throw new ApiValidationError("Le type du fichier est invalide.")}else if("undefined"!=typeof Blob&&e instanceof Blob){if(n=e.type,!t.includes(n))throw new ApiValidationError("Le type du fichier est invalide.");const r=n.split("/")[1]||"bin",o=`${Date.now()}.${r}`;i=new File([e],o,{type:n})}else if(o&&Buffer.isBuffer(e)){const o=await k(e);if(n=o?.mime,!o||!t.includes(n))throw new ApiValidationError("Le type du fichier est invalide.");if("image"===r){const t=o.ext,r=`${Date.now()}.${t}`;i=await this._createReadStreamFromBuffer(e,r,n)}}else{if(!o||!e?.readable||"function"!=typeof e._read)throw new ApiValidationError("Type de fichier non reconnu.");{const r=[],o=await this._passThrough(),s=await this._passThrough(),a=4100;let c=0;e.on("data",(e=>{c<a&&(r.push(e),c+=e.length)})),e.pipe(o).pipe(s),await new Promise((e=>setTimeout(e,10)));const p=Buffer.concat(r),l=await k(p);if(n=l?.mime,!l||!t.includes(n))throw new ApiValidationError("Le type du fichier est invalide.");s.path=`${Date.now()}.${l.ext}`,s.mimeType=n,i=s}}return i}async _createReadStreamFromBuffer(e,t="file.bin",r="application/octet-stream"){const o=await this._bufferToReadable(e);return o.path=t,o.mimeType=r,o}async _bufferToReadable(e){if("undefined"==typeof window){const{bufferToReadable:t}=await Promise.resolve().then((function(){return N}));return t(e)}throw new Error("bufferToReadable ne doit pas être appelé dans le navigateur")}async _passThrough(){if("undefined"==typeof window){const{createPassThrough:e}=await Promise.resolve().then((function(){return N}));return e()}throw new Error("passThrough ne doit pas être appelé dans le navigateur")}_omitProps(e,t){if(!e||"object"!=typeof e)return{};const r={...e};for(const e of t)delete r[e];return r}_pickProps(e,t,r={}){if(!e||"object"!=typeof e)return{};const o={};for(const n of t)if(n in e){const t=e[n];"function"==typeof r[n]?o[n]=r[n](t,e):o[n]=t}return o}_hasAtLeastOne(e,t=[]){return t.some((t=>t in e&&null!=e[t]))}_createFilteredProxy(e){return new Proxy(e,{get(e,t,r){if("string"==typeof t&&!isNaN(t)){return e.filter((e=>!e._isDeleted))[t]}return"length"===t?e.filter((e=>!e._isDeleted)).length:"function"==typeof e[t]?(...r)=>e.filter((e=>!e._isDeleted))[t](...r):Reflect.get(e,t,r)}})}_newId(){return(new e).toString()}_createDraftProxy(e,t={},r={},o=[],n={},i={}){return new Proxy({},{get:(e,o)=>{const i=o in r?r[o]:t[o],s=n[o];return"function"==typeof s?s(i):i},set:(t,n,s)=>{if(!o.includes(n)){const t=`[DraftProxy] Le champ "${n}" n'est pas autorisé.`;if(i.throwOnError)throw new ApiValidationError(t,400,null,{field:n,value:s,allowedFields:o});return e._logger.warn(t),!1}return r[n]=s,!0},deleteProperty:(e,t)=>!!o.includes(t)&&(delete r[t],!0),has:(e,o)=>o in r||o in t,ownKeys:()=>[...new Set([...Object.keys(t),...Object.keys(r)])],getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})})}_extractWritableFields(e={},t={},r={defs:{},visited:new Set}){if(!e||"object"!=typeof e)return[];if(e.$id&&r.visited.has(e.$id))return[];e.$id&&r.visited.add(e.$id),r.defs=e.$defs||e.definitions||r.defs;const o=[];if(e.$ref){const n=e.$ref.replace(/^#\/?(\$defs|definitions)\//,""),i=r.defs?.[n];i&&o.push(...this._extractWritableFields(i,t,r))}if(e.allOf&&e.allOf.forEach((e=>o.push(...this._extractWritableFields(e,t,r)))),e.if&&e.then){const n=e.if?.properties;let i=!0;if(n)for(const e in n){const r=n[e]?.const;if(t[e]!==r){i=!1;break}}i&&e.then?o.push(...this._extractWritableFields(e.then,t,r)):!i&&e.else&&o.push(...this._extractWritableFields(e.else,t,r))}return e.properties&&o.push(...Object.entries(e.properties).filter((([e,t])=>!0!==t.readOnly&&void 0===t.const)).map((([e])=>e))),[...new Set(o)]}_buildDraftAndProxy({data:e={},serverData:t=null,constant:r,apiClient:o,transforms:n={},throwOnError:i=!0,removeFields:s=[]}){const a=Array.isArray(r)?r:[r],c={allOf:[],$defs:{}};for(const e of a){const t=o.getRequestSchema(e);if(!t)throw new ApiError(`Unable to find schema for ${e}.`);if(t.$defs)for(const[r,n]of Object.entries(t.$defs))c.$defs[r]?o._logger.warn(`Duplicate $defs key '${r}' from schema '${e}'`):c.$defs[r]=n;c.allOf.push(t)}const p={};let l=this._extractWritableFields(c,e);e.id&&-1===l.indexOf("id")&&l.push("id"),e.slug&&-1===l.indexOf("slug")&&l.push("slug"),l=l.filter((e=>!s.includes(e)));for(const t of l){const r=e[t],o="function"==typeof n[t]?n[t](r,e):r;void 0!==o&&(p[t]=o)}return{draft:p,proxy:this._createDraftProxy(o,t,p,l,n,{throwOnError:i})}}_extractChangedFieldsFromSchema(e,t,r={},o,n=[]){const i=e.getRequestSchema(t);let s=this._extractWritableFields(i,r);const a={},c=o?.()||{};s=s.filter((e=>!n.includes(e)));for(const e of s){if(void 0===r[e])continue;const t=r[e],o=c[e];JSON.stringify(t)!==JSON.stringify(o)&&(a[e]=t)}return Object.keys(a).length>0?a:null}setupReactiveSync(){this._syncReactiveDraft||(this._syncReactiveDraft=!0),I(this)}async _resolveId(e){if(!this.id&&this.slug)try{const t=await this.endpointApi.getElementsKey({pathParams:{slug:this.slug}});if(!t?.contextId||t?.contextType!==e)throw new ApiResponseError(`Le slug ${this.slug} ne correspond pas à un ${e}`,200,t);this._id(t.contextId)}catch(t){throw t instanceof ApiResponseError?t?.responseData?.contextType!==e?t:new ApiResponseError(`Impossible de récupérer l'identifiant pour le slug ${this.slug}`,t.status,t.responseData):t}return this.id}async _getPublicProfile(){return await this._resolveId(this.getEntityType()),this.endpointApi.getElementsAbout({pathParams:{id:this.id,type:this.getEntityType()}})}_getEntityMeta(e){const t=this.constructor,r=this.__entityTag,o={EndpointApi:this.deps.EndpointApi,User:"User"===r?t:this.deps.User,Organization:"Organization"===r?t:this.deps.Organization,Project:"Project"===r?t:this.deps.Project,Event:"Event"===r?t:this.deps.Event,Poi:"Poi"===r?t:this.deps.Poi,Badge:"Badge"===r?t:this.deps.Badge,News:"News"===r?t:this.deps.News};return{citoyens:{entityClass:o.User,deps:o},organizations:{entityClass:o.Organization,deps:o},projects:{entityClass:o.Project,deps:o},events:{entityClass:o.Event,deps:{...o,Badge:void 0}},poi:{entityClass:o.Poi,deps:{...o,Badge:void 0,News:void 0}},news:{entityClass:o.News,deps:{...o}},badges:{entityClass:o.Badge,deps:{EndpointApi:o.EndpointApi,User:o.User,Organization:o.Organization,Project:o.Project}}}[e]||null}_linkEntity(e,t){const r=this._getEntityMeta(e);return r?r.entityClass.fromServerData(t,this,r.deps):t}async _linkEntityById(e,t,r={}){const o=this._getEntityMeta(e);if(!o)return null;const n=new o.entityClass(this,{id:t},o.deps);return r?.skipGet||await n.get(),n}_linkEntities(e){return e.map((e=>this._linkEntity?.(e.collection,e)??e))}async linkEntitiesFromServerData(e,t={},r={}){const o=r.key||e,n="function"==typeof r.mapFn?r.mapFn:null,i=e=>!0===e||"true"===e,s=e=>!1===e||"false"===e,a=this.serverData?.[o],c=[];if(a&&"object"==typeof a&&Object.keys(a).length>0)for(const r of Object.keys(a)){const o=a[r],p=Object.entries(t).every((([e,t])=>{const r=o[e];if("function"==typeof t)try{return t(r)}catch(t){return console.warn(`Erreur dans le filtre personnalisé pour ${e}`,t),!1}return t instanceof RegExp?"string"==typeof r&&t.test(r):"string"==typeof t&&"string"==typeof r?r.toLowerCase().includes(t.toLowerCase()):i(t)?i(r):s(t)?s(r):"string"!=typeof r||"string"!=typeof t||isNaN(Date.parse(r))||isNaN(Date.parse(t))?r===t:new Date(r).getTime()===new Date(t).getTime()}));if(p)try{const t=await this._linkEntityById(e,r);t&&(t.meta=o,c.push(n?n(t):t))}catch(t){this._logger?.error?.(`Erreur lors de la récupération de l'entité ${e} (${r}) :`,t)}}return c}_entityInstanceData(e,t){const r=this._getEntityMeta(e),o=this.__entityTag,n=this.constructor;return new r.entityClass(this,t,{[o]:n,...r.deps})}async entity(e,t={}){try{const r=this._entityInstanceData(e,t),o={citoyens:["id","slug"],organizations:["id","slug"],projects:["id","slug"],events:["id","slug"],poi:["id","slug"],news:["id"],badges:["id"]}[e];return o&&this._hasAtLeastOne(t,o)&&await r.get(),r}catch(t){throw this.apiClient._logger.error(`[Api.${this.__entityTag}.${e}] Erreur lors de la création d'une instance ${e} :`,t.message),t}}_buildLinkFilters(e,{linkType:t,isAdmin:r,isAdminPending:o,isInviting:n,toBeValidated:i=!1,roles:s=[]}={}){if("string"!=typeof e)throw new TypeError("id doit être une chaîne.");if("string"!=typeof t)throw new TypeError("linkType doit être une chaîne.");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError("isAdmin doit être un booléen.");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("isAdminPending doit être un booléen.");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("isInviting doit être un booléen.");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("toBeValidated doit être un booléen.");if(!Array.isArray(s))throw new TypeError("roles doit être un tableau de chaînes.");const a=`links.${t}.${e}`,c={[`${a}`]:{$exists:!0}};return"boolean"==typeof i&&(c[`${a}.toBeValidated`]={$exists:i}),"boolean"==typeof n&&(c[`${a}.isInviting`]={$exists:n}),!0===r&&(c[`${a}.isAdmin`]={$exists:!0}),!0===o&&(c[`${a}.isAdminPending`]={$exists:!0}),s.length>0&&(c[`${a}.roles`]={$in:s}),c}_getLinkMeta(){const e=this.getEntityType(),t={organizations:{linkType:"memberOf",connectTypeConnect:"member",connectTypeDisconnect:"members"},projects:{linkType:"projects",connectTypeConnect:"contributor",connectTypeDisconnect:"contributors"},events:{linkType:"events",connectTypeConnect:"attendee",connectTypeDisconnect:"attendees"},citoyens:{linkType:"friends",connectTypeConnect:"friend",connectTypeDisconnect:"friends"}}[e];if(!t)throw new ApiError(`Aucune correspondance de lien définie pour le type d'entité "${e}"`);return t}_checkLinkableEntity(){try{this._getLinkMeta()}catch(e){if(e instanceof ApiError)throw new ApiError(`L'entité "${this.getEntityType()}" ne prend pas en charge les actions de lien.`);throw e}}_getLinkFromConnectedUser(){const{linkType:e}=this._getLinkMeta();return this?.userContext?.serverData?.links?.[e]?.[this.id]||null}async _submitLinkRequest(){if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);const{connectTypeConnect:e}=this._getLinkMeta(),t=this._getLinkFromConnectedUser();if(!t){const t={parentType:this.getEntityType(),parentId:this.id,connectType:e},r=await this.callIsMe((()=>this.endpointApi.connect(t)));return await this.userContext.refresh(),r}if(t.isInviting)return this._acceptLinkRequest();if(t.toBeValidated)throw new ApiError("Vous êtes déjà en attente de validation.");throw new ApiError("Vous êtes déjà connecté à cette entité.")}async _submitLinkRequestAdmin(){if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);const e=this._getLinkFromConnectedUser();if(!e){const e={parentType:this.getEntityType(),parentId:this.id,connectType:"admin"},t=await this.callIsMe((()=>this.endpointApi.connect(e)));return await this.userContext.refresh(),t}if(e.isInviting)return this._acceptLinkRequest();if(e.toBeValidated&&e.isAdminPending)throw new ApiError("Vous êtes déjà en attente de validation pour devenir admin.");if(e.toBeValidated)throw new ApiError("Vous êtes déjà en attente de validation pour rejoindre cette entité.");throw new ApiError("Vous êtes déjà connecté à cette entité.")}async _acceptLinkRequest(){if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);if(this._getLinkFromConnectedUser().isInviting){const e={parentType:this.getEntityType(),parentId:this.id,linkOption:"isInviting"},t=await this.callIsMe((()=>this.endpointApi.linkValidate(e)));return await this.userContext.refresh(),t}throw new ApiError("Vous n'avez pas d'invitation à valider.")}async _leaveLinkRequest(){if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);const{connectTypeDisconnect:e}=this._getLinkMeta();if(!this._getLinkFromConnectedUser())throw new ApiError("Vous n'êtes pas connecté à cette entité.");const t={parentType:this.getEntityType(),parentId:this.id,connectType:e},r=await this.callIsMe((()=>this.endpointApi.disconnect(t)));return await this.userContext.refresh(),r}async get(){return this.apiClient.safeCall((async()=>{const e=await this._getPublicProfile();return this._setData(e),e}))}async updateSettings(e={}){return e.idEntity=this.id,e.typeEntity=this.getEntityType(),this.callIsConnected((()=>this.endpointApi.updateSettings(e)))}async updateDescription(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockDescription(e)))}async updateInfo(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockInfo(e)))}async updateSocial(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockSocial(e)))}async updateLocality(e={}){return e.typeElement=this.getEntityType(),e.id=this.id,this.callIsConnected((()=>this.endpointApi.updateBlockLocality(e)))}async updateSlug({slug:e}){try{await this.endpointApi.check({type:this.getEntityType(),id:this.id,slug:e})}catch(e){if(e instanceof ApiResponseError)throw new ApiResponseError("Erreur lors de la vérification du slug.",e.status,e.data);throw e}return this.callIsConnected((()=>this.endpointApi.updateBlockSlug({typeElement:this.getEntityType(),id:this.id,slug:e})))}async updateImageProfil({profil_avatar:e}){e=await this._validateImage(e);const t={pathParams:{folder:this.getEntityType(),ownerId:this.id},profil_avatar:e};return this.callIsConnected((()=>this.endpointApi.profilImage(t)))}async organization(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer une organisation.");return this.entity("organizations",e)}async project(e={}){if(!this.isConnected)throw new ApiError("Vous devez être connecté pour créer un projet.");return this.entity("projects",e)}async poi(e={}){if(!this.isConnected)throw new ApiError("Vous devez être connecté pour créer un POI.");return this.entity("poi",e)}async event(e={}){if(!this.isConnected)throw new ApiError("Vous devez être connecté pour créer un événement.");return this.entity("events",e)}async badge(e={}){if(!this.isConnected)throw new ApiError("Vous devez être connecté pour créer un badge.");return this.entity("badges",e)}async news(e={}){if(!this.isConnected)throw new ApiError("Vous devez être connecté.");return this.entity("news",e)}async getOrganizations(e={}){this.isMe?e.pathParams={type:this.getEntityType(),id:this.id}:(delete e?.pathParams,e.filters={[`links.members.${this.id}`]:{$exists:!0},[`links.members.${this.id}.toBeValidated`]:{$exists:!1},[`links.members.${this.id}.isInviting`]:{$exists:!1}});const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getOrganizationsAdmin(e))):()=>this.endpointApi.getOrganizationsNoAdmin(e),r=await t();if(!Array.isArray(r.results))throw new ApiResponseError("Erreur lors de la récupération des organisations.",500,r.results);delete r?.count?.spam;const o=Object.values(r.count||{}).reduce(((e,t)=>e+t),0);r.count.total=o;const n=this._linkEntities(r.results);return{count:r.count,results:n}}async getProjects(e={}){this.isMe?e.pathParams={type:this.getEntityType(),id:this.id}:(delete e?.pathParams,e.filters={$or:{[`links.contributors.${this.id}`]:{$exists:!0},[`parent.${this.id}`]:{$exists:!0}},[`links.contributors.${this.id}`]:{$exists:!0}});const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getProjectsAdmin(e))):()=>this.endpointApi.getProjectsNoAdmin(e),r=await t();if(!Array.isArray(r.results))throw new ApiResponseError("Erreur lors de la récupération des projets.",500,r.results);const o=this._linkEntities(r.results);return{count:r?.count?.projects??0,results:o}}async getPois(e={}){this.isMe?e.pathParams={type:this.getEntityType(),id:this.id}:(delete e?.pathParams,e.filters={[`parent.${this.id}`]:{$exists:!0}});const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getPoisAdmin(e))):()=>this.endpointApi.getPoisNoAdmin(e),r=await t();if(!Array.isArray(r.results))throw new ApiResponseError("Erreur lors de la récupération des POIs.",500,r.results);const o=this._linkEntities(r.results);return{count:r.count?.poi??0,results:o}}async getSubscribers(e={}){delete e?.pathParams,e.filters={[`links.follows.${this.id}`]:{$exists:!0},[`links.follows.${this.id}.toBeValidated`]:{$exists:!1},[`links.follows.${this.id}.isInviting`]:{$exists:!1}};const t=await this.endpointApi.getSubscribers(e);if(!Array.isArray(t.results))throw new ApiResponseError("Erreur lors de la récupération des abonnés.",500,t.results);const r=this._linkEntities(t.results);return{count:t.count,results:r}}async getBadgesIssuer(e={}){delete e?.pathParams,e.filters=e.filters||{},e.filters.$or={},e.filters.$or[`issuer.${this.id}`]={$exists:!0};const t=await this.endpointApi.getBadges(e);if(!Array.isArray(t.results))throw new ApiResponseError("Erreur lors de la récupération des badges.",500,t.results);const r=this._linkEntities(t.results);return{count:t.count?.badges??0,results:r}}async getNews(e={}){e.pathParams={type:this.getEntityType(),id:this.id};const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new ApiResponseError("Erreur lors de la récupération des actualités.",500,t);const r=this._linkEntities(t);return this._createFilteredProxy(r)}async requestToJoin(){if(!this.isMe)throw new ApiError("Vous devez être connecté pour envoyer une demande de participation.");return this._checkLinkableEntity(),this._submitLinkRequest()}async requestToJoinAdmin(){if(!this.isMe)throw new ApiError("Vous devez être connecté pour envoyer une demande de participation.");return this._checkLinkableEntity(),this._submitLinkRequestAdmin()}async acceptInvitation(){if(!this.isMe)throw new ApiError("Vous devez être connecté pour envoyer une demande de participation.");return this._checkLinkableEntity(),this._acceptLinkRequest()}async leave(){if(!this.isMe)throw new ApiError("Vous devez être connecté pour envoyer une demande de participation.");return this._checkLinkableEntity(),this._leaveLinkRequest()}async follow(){if(!this.isMe)throw new ApiError("Vous devez être connecté pour suivre cette entité.");if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);if(!(this.userContext?.serverData?.links?.follows?.[this.id]||null)){const e={parentType:this.getEntityType(),parentId:this.id},t=await this.callIsMe((()=>this.endpointApi.follow(e)));return await this.userContext.refresh(),t}throw new ApiError("Vous êtes déjà abonné à cette entité.")}async unfollow(){if(!this.isMe)throw new ApiError("Vous devez être connecté pour vous désabonner.");if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);if(this.userContext?.serverData?.links?.follows?.[this.id]||null){const e={parentType:this.getEntityType(),parentId:this.id,connectType:"followers"},t=await this.callIsMe((()=>this.endpointApi.disconnect(e)));return await this.userContext.refresh(),t}throw new ApiError("Vous n'êtes pas abonné à cette entité.")}_checkAccess(e="effectuer cette action"){if(!this.isMe)throw new ApiError(`Vous devez être connecté pour ${e}`);if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`)}_validateUserLink(e){if(!e)return!1;const{toBeValidated:t,isInviting:r}=e;return!t&&!r}_assertEntityType(...e){const t=Array.isArray(e[0])?e[0]:e;if(!t.includes(this.getEntityType()))throw new ApiError(`L'entité doit être de type : ${t.join(", ")}, reçu : ${this.getEntityType()}`)}_isLinked(e){return!!this.userContext?.serverData?.links?.[e]?.[this.id]}isAuthor(){if(this._checkAccess("vérifier l'auteur"),!this.serverData)throw new ApiError("Aucune donnée serveur disponible.");return this.userId&&this.serverData?.creator===this.userId}isAdmin(){this._checkAccess("vérifier l'administrateur."),this._assertEntityType("organizations","projects","events");const e=this._getLinkFromConnectedUser();return this._validateUserLink(e)&&!0===e?.isAdmin&&!e?.isAdminPending}isAuthorOrAdmin(){return this._checkAccess("vérifier l'auteur ou l'administrateur."),this.isAuthor()||this.isAdmin()}isMember(){this._checkAccess("vérifier le membre."),this._assertEntityType("organizations");const e=this._getLinkFromConnectedUser();return this._validateUserLink(e)}isContributor(){this._checkAccess("vérifier le contributeur."),this._assertEntityType("projects");const e=this._getLinkFromConnectedUser();return this._validateUserLink(e)}isAttendee(){this._checkAccess("vérifier si vous êtes un participant."),this._assertEntityType("events");const e=this._getLinkFromConnectedUser();return this._validateUserLink(e)}isFollower(){return this._checkAccess("vérifier si il vous suit."),this._assertEntityType("citoyens","organizations","projects","events","poi"),this._isLinked("followers")}isFollowing(){return this._checkAccess("vérifier si vous le suivez."),this._assertEntityType("citoyens","organizations","projects","events","poi"),this._isLinked("follows")}}class Badge extends BaseEntity{static entityType="badges";static SCHEMA_CONSTANTS=["ADD_BADGES"];static ADD_BLOCKS=new Map([["ADD_BADGES","addBadges"]]);static UPDATE_BLOCKS=new Map([]);defaultFields={};removeFields=[];transforms={};async _add(e){if(!this._calledFromSave)throw new ApiError("utilisation invalide de _add, utilisez save");e.id=this._newId?.(),e.slug&&delete e.slug;for(const[t,r]of Badge.ADD_BLOCKS){const o=this._extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(o&&Object.keys(o).length>0){const e=await this[r](o);!this.id&&e?.map?.id&&(this._draftData.id=e.map.id,this._draftData.slug=e.map.slug)}}}async _update(e){if(!this._calledFromSave)throw new ApiError("utilisation invalide de _update, utilisez save");e.id&&delete e.id;let t=!1;for(const[r,o]of Badge.UPDATE_BLOCKS){const n=this._extractChangedFieldsFromSchema(this.apiClient,r,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);n&&Object.keys(n).length>0&&(await this[o](n),t=!0)}return t}async getOrganizations(){throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`)}async getProjects(){throw new ApiError(`getProjects n'existe pas dans ${this.constructor.name}`)}async getEvents(){throw new ApiError(`getEvents n'existe pas dans ${this.constructor.name}`)}async getPois(){throw new ApiError(`getPois n'existe pas dans ${this.constructor.name}`)}async getBadgesIssuer(){throw new ApiError(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`)}async getNews(){throw new ApiError(`getNews n'existe pas dans ${this.constructor.name}`)}async getSubscribers(){throw new ApiError(`getSubscribers n'existe pas dans ${this.constructor.name}`)}async project(){throw new ApiError(`project n'existe pas dans ${this.constructor.name}`)}async poi(){throw new ApiError(`poi n'existe pas dans ${this.constructor.name}`)}async event(){throw new ApiError(`event n'existe pas dans ${this.constructor.name}`)}async badge(){throw new ApiError(`badge n'existe pas dans ${this.constructor.name}`)}async news(){throw new ApiError(`news n'existe pas dans ${this.constructor.name}`)}}class EndpointApi{constructor(e){this.apiClient=e}get isConnected(){return this.apiClient.isConnected}get userId(){return this.apiClient.userId}async call(e,t={}){return this.apiClient.safeCall((async()=>{const r=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(r),r.data}))}async callNoConnected(e,t={}){if(this.isConnected)throw new ApiAuthenticationError("Vous ne devez pas être connecté pour faire cette action.");return this.call(e,t)}async callIsConnected(e,t={}){if(!this.isConnected)throw new ApiAuthenticationError("Vous devez être connecté pour effectuer cette action.");return this.call(e,t)}async personRegister(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callNoConnected("PERSON_REGISTER",e)}async authenticateUrl(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callNoConnected("AUTHENTICATE_URL",e)}async refreshTokenUrl(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("REFRESH_TOKEN_URL",e)}async meInfoUrl(){return this.callIsConnected("ME_INFO_URL")}async passwordRecovery(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callNoConnected("PASSWORD_RECOVERY",e)}async serverExchangeToken(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("SERVER_EXCHANGE_TOKEN",e)}async changePassword(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("CHANGE_PASSWORD",e)}async deleteAccount(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("DELETE_ACCOUNT",e)}async updateSettings(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("UPDATE_SETTINGS",e)}async updateBlockDescription(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("UPDATE_BLOCK_DESCRIPTION",e)}async updateBlockInfo(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("UPDATE_BLOCK_INFO",e)}async updateBlockSocial(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("UPDATE_BLOCK_SOCIAL",e)}async updateBlockLocality(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("UPDATE_BLOCK_LOCALITY",e)}async updateBlockSlug(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("UPDATE_BLOCK_SLUG",e)}async check(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("CHECK",e)}async profilImage(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("PROFIL_IMAGE",e)}async getElementsAbout(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_ELEMENTS_ABOUT",e)}async multiconnect(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("MULTICONNECT",e)}async getNews(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_NEWS",e)}async getNewsById(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_NEWS_BY_ID",e)}async addNews(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_NEWS",e)}async addImageNews(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_IMAGE_NEWS",e)}async addFileNews(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_FILE_NEWS",e)}async deleteNews(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("DELETE_NEWS",e)}async updateNews(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("UPDATE_NEWS",e)}async shareNews(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("SHARE_NEWS",e)}async getComments(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_COMMENTS",e)}async addComments(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_COMMENTS",e)}async deleteComments(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("DELETE_COMMENTS",e)}async updateComments(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("UPDATE_COMMENTS",e)}async searchTags(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("SEARCH_TAGS",e)}async showVote(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("SHOW_VOTE",e)}async globalAutocomplete(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GLOBAL_AUTOCOMPLETE",e)}async cityAutocomplete(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("CITY_AUTOCOMPLETE",e)}async suggestionInput(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("SUGGESTION_INPUT",e)}async getProjectsNoAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_PROJECTS_NO_ADMIN",e)}async getProjectsAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_PROJECTS_ADMIN",e)}async getPoisNoAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_POIS_NO_ADMIN",e)}async getPoisAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_POIS_ADMIN",e)}async getOrganizationsNoAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_ORGANIZATIONS_NO_ADMIN",e)}async getOrganizationsAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_ORGANIZATIONS_ADMIN",e)}async getMembersNoAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_MEMBERS_NO_ADMIN",e)}async getMembersAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_MEMBERS_ADMIN",e)}async getFriendsAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_FRIENDS_ADMIN",e)}async getSubscriptions(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_SUBSCRIPTIONS",e)}async getSubscriptionsAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_SUBSCRIPTIONS_ADMIN",e)}async getSubscribers(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_SUBSCRIBERS",e)}async getSubscribersAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_SUBSCRIBERS_ADMIN",e)}async getContributorsNoAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_CONTRIBUTORS_NO_ADMIN",e)}async getContributorsAdmin(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_CONTRIBUTORS_ADMIN",e)}async getBadges(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_BADGES",e)}async getBadgesFilters(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_BADGES_FILTERS",e)}async connect(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("CONNECT",e)}async disconnect(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("DISCONNECT",e)}async getElementsKey(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_ELEMENTS_KEY",e)}async getFavoris(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_FAVORIS",e)}async deleteFavoris(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("DELETE_FAVORIS",e)}async addFavoris(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_FAVORIS",e)}async addOrganization(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_ORGANIZATION",e)}async addProject(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_PROJECT",e)}async addPoi(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_POI",e)}async addEvent(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_EVENT",e)}async deletePoi(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("DELETE_POI",e)}async deleteEvent(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("DELETE_EVENT",e)}async deleteElement(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("DELETE_ELEMENT",e)}async addImageElement(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_IMAGE_ELEMENT",e)}async linkValidate(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("LINK_VALIDATE",e)}async searchMemberAutocomplete(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("SEARCH_MEMBER_AUTOCOMPLETE",e)}async getNotifications(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_NOTIFICATIONS",e)}async getNotificationsCount(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("GET_NOTIFICATIONS_COUNT",e)}async notificationUpdate(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("NOTIFICATION_UPDATE",e)}async removeAllNotifications(){return this.callIsConnected("REMOVE_ALL_NOTIFICATIONS")}async markNotificationAsRead(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("MARK_NOTIFICATION_AS_READ",e)}async activitypubSearch(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("ACTIVITYPUB_SEARCH",e)}async activitypubLink(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ACTIVITYPUB_LINK",e)}async activitypubGetCommunity(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("ACTIVITYPUB_GET_COMMUNITY",e)}async getBadge(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_BADGE",e)}async getEmetteurBadges(){return this.call("GET_EMETTEUR_BADGES")}async addBadges(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ADD_BADGES",e)}async assignBadges(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("ASSIGN_BADGES",e)}async getEvents(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_EVENTS",e)}async shareEvents(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("SHARE_EVENTS",e)}async inviteEvent(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("INVITE_EVENT",e)}async follow(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.callIsConnected("FOLLOW",e)}async getCostumJson(e){if(!e||"object"!=typeof e)throw new TypeError("Le paramètre data doit être un objet.");return this.call("GET_COSTUM_JSON",e)}}class Event extends BaseEntity{static entityType="events";static SCHEMA_CONSTANTS=["ADD_EVENT"];static ADD_BLOCKS=new Map([["ADD_EVENT","addEvent"]]);static UPDATE_BLOCKS=new Map([]);defaultFields={};removeFields=["typeElement"];transforms={};async _add(e){if(!this._calledFromSave)throw new ApiError("utilisation invalide de _add, utilisez save");e.id=this._newId?.(),e.slug&&delete e.slug;for(const[t,r]of Event.ADD_BLOCKS){const o=this._extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(o&&Object.keys(o).length>0){const e=await this[r](o);!this.id&&e?.map?.id&&(this._draftData.id=e.map.id,this._draftData.slug=e.map.slug)}}}async _update(e){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour modifier cet événement",403);if(!this._calledFromSave)throw new ApiError("utilisation invalide de _update, utilisez save");e.id&&delete e.id;let t=!1;for(const[r,o]of Event.UPDATE_BLOCKS){const n=this._extractChangedFieldsFromSchema(this.apiClient,r,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);n&&Object.keys(n).length>0&&(await this[o](n),t=!0)}return t}async getOrganizations(){throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`)}async getProjects(){throw new ApiError(`getProjects n'existe pas dans ${this.constructor.name}`)}async getEvents(){throw new ApiError(`getEvents - les sous-events ne sont pas encore implémentés dans ${this.constructor.name}`)}async getPois(){throw new ApiError(`getPois n'existe pas dans ${this.constructor.name}`)}async getBadgesIssuer(){throw new ApiError(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`)}async getNews(e={}){return super.getNews(e)}async getSubscribers(e={}){return super.getSubscribers(e)}async project(){throw new ApiError(`project n'existe pas dans ${this.constructor.name}`)}async poi(){throw new ApiError(`poi n'existe pas dans ${this.constructor.name}`)}async event(){throw new ApiError(`les sous-events ne sont pas encore implémentés dans ${this.constructor.name}`)}async badge(){throw new ApiError(`badge n'existe pas dans ${this.constructor.name}`)}async news(e={}){return super.news(e)}async follow(){return super.follow()}async unfollow(){return super.unfollow()}}class News extends BaseEntity{static entityType="news";static SCHEMA_CONSTANTS=["ADD_NEWS"];static ADD_BLOCKS=new Map([["ADD_NEWS","addNews"]]);static UPDATE_BLOCKS=new Map([["ADD_NEWS","updateNews"]]);defaultFields={};removeFields=[];transforms={scope:e=>e?.type,mentions:e=>Array.isArray(e)?e.map((e=>({...e,count:parseInt(e.count)}))):[],mediaImg:e=>{const t=e?.images?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countImages:t.length,images:t}:void 0},mediaFile:e=>{const t=e?.files?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countFiles:t.length,files:t}:void 0}};async get(){if(!this.id)throw new ApiError("Impossible de rafraîchir sans ID.");const e=await this.callIsConnected((()=>this.endpointApi.getNewsById({ids:[this.id]})));if(e&&Array.isArray(e)&&1===e.length){const t=e[0];return this._setData(t),this.serverData}throw new ApiError(`Aucune actualité trouvée pour l'ID ${this.id}`)}async _add(e){if(!this._calledFromSave)throw new Error("utilisation invalide de _add, utilisez save");""===e.text&&(e.text=" "),e.parentId=this.parent.id,e.parentType=this.parent.getEntityType();for(const[t,r]of News.ADD_BLOCKS){const o=this._extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(o&&Object.keys(o).length>0){const e=await this[r](o);!this.id&&e?.object?.id&&(this._draftData.id=e.object.id)}}}async _update(e){if(!this._calledFromSave)throw new Error("utilisation invalide de _update, utilisez save");e.id&&delete e.id,""===e?.text&&(e.text=" "),e.parentId=this.parent.id,e.parentType=this.parent.getEntityType(),e.idNews=this.id;let t=!1;const r=await this.callIsConnected((()=>this.endpointApi.updateNews(e)));return r?.object&&(this._serverData={...r.object}),t=!0,true}async addNews(e={}){return this.callIsConnected((()=>this.endpointApi.addNews(e)))}async updateNews(e={}){return this.callIsConnected((()=>this.endpointApi.updateNews(e)))}async addMention({slug:e,id:t}){try{if(!e&&!t)throw new ApiError("Vous devez fournir un slug ou un id pour ajouter une mention.");const r=await this.entity("citoyens",{id:t,slug:e}),o=r.serverData;if(this._draftData.mentions||(this._draftData.mentions=[]),this._draftData.mentions.find((e=>e.id===o.id)))return this._draftData.mentions=this._draftData.mentions.map((e=>(e.id===o.id&&(e.count+=1),e))),this._draftData.mentions;const n={id:o.id,slug:o.slug,type:r.getEntityType(),name:o.name,value:o.name,count:1};return this._draftData.mentions.push(n),this._draftData.mentions}catch(e){throw this.apiClient._logger.error("Erreur lors de l'ajout de la mention :",e),e}}async addImage(e){e=await this._validateImage(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsImage:e},r=await this.callIsConnected((()=>this.endpointApi.addImageNews(t)));return this._draftData.mediaImg?(this._draftData.mediaImg.countImages=this._draftData.mediaImg.countImages+1,this._draftData.mediaImg.images.push(r.id)):this._draftData.mediaImg={countImages:1,images:[r.id]},r}async addFile(e){e=await this._validateFile(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsFile:e},r=await this.callIsConnected((()=>this.endpointApi.addFileNews(t)));return this._draftData.mediaFile?(this._draftData.mediaFile.countFiles=this._draftData.mediaFile.countFiles+1,this._draftData.mediaFile.files.push(r)):this._draftData.mediaFile={countFiles:1,files:[r]},r}async delete(){if(!this.id)throw new ApiError("Vous devez fournir un id pour supprimer une news.");const e={pathParams:{id:this.id}};await this.callIsConnected((()=>this.endpointApi.deleteNews(e))),this._draftData={},this._serverData=null,this._draftData.id=null,this._isDeleted=!0}}class Organization extends BaseEntity{static entityType="organizations";static SCHEMA_CONSTANTS=["ADD_ORGANIZATION","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static ADD_BLOCKS=new Map([["ADD_ORGANIZATION","addOrganization"],["PROFIL_IMAGE","updateImageProfil"]]);static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal};async _add(e){if(!this._calledFromSave)throw new ApiError("utilisation invalide de _add, utilisez save");e.id=this._newId?.(),e.slug&&delete e.slug;for(const[t,r]of Organization.ADD_BLOCKS){const o=this._extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(o&&Object.keys(o).length>0){const e=await this[r](o);!this.id&&e?.map?.id&&(this._draftData.id=e.map.id,this._draftData.slug=e.map.slug)}}}async _update(e){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour modifier cette organisation",403);if(!this._calledFromSave)throw new ApiError("utilisation invalide de _update, utilisez save");e.id&&delete e.id;let t=!1;for(const[r,o]of Organization.UPDATE_BLOCKS){const n=this._extractChangedFieldsFromSchema(this.apiClient,r,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);n&&Object.keys(n).length>0&&(await this[o](n),t=!0)}return t}async addOrganization(e={}){return this.callIsConnected((()=>this.endpointApi.addOrganization(e)))}async getOrganizations(){throw new ApiError("getOrganizations n'existe pas dans Organization")}async getProjects(e={}){return super.getProjects(e)}async getEvents(){throw new ApiError("getEvents pas encore implémenté dans Organization")}async getPois(e={}){return super.getPois(e)}async getBadgesIssuer(e={}){return super.getBadgesIssuer(e)}async getNews(e={}){return super.getNews(e)}async getSubscribers(e={}){return super.getSubscribers(e)}async getMembers(e={},t={}){const{toBeValidated:r,isAdmin:o,isAdminPending:n,isInviting:i,roles:s=[]}=t;this.isMe?(e.pathParams={type:this.getEntityType(),id:this.id},e.filters=this._buildLinkFilters(this.id,{linkType:"memberOf",toBeValidated:r,isAdmin:o,isAdminPending:n,isInviting:i,roles:s})):(delete e?.pathParams,e.filters=this._buildLinkFilters(this.id,{linkType:"memberOf",toBeValidated:"false",isAdmin:o,isInviting:i,roles:s}));const a=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getMembersAdmin(e))):()=>this.endpointApi.getMembersNoAdmin(e),c=await a();if(!Array.isArray(c.results))throw new ApiResponseError("Erreur lors de la récupération des membres",500,c.results);const p=this._linkEntities(c.results);return{count:c.count,results:p}}async project(e={}){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour créer un projet dans cette organisation",403);return super.project(e)}async poi(e={}){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour créer un projet dans cette organisation",403);return super.poi(e)}async event(e={}){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour créer un projet dans cette organisation",403);return super.event(e)}async badge(e={}){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour créer un projet dans cette organisation",403);return super.badge(e)}async news(e={}){return super.news(e)}async requestToJoin(){return super.requestToJoin()}async requestToJoinAdmin(){return super.requestToJoinAdmin()}async acceptInvitation(){return super.acceptInvitation()}async leave(){return super.leave()}async follow(){return super.follow()}async unfollow(){return super.unfollow()}}class Poi extends BaseEntity{static entityType="poi";static SCHEMA_CONSTANTS=["ADD_POI","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static ADD_BLOCKS=new Map([["ADD_POI","addPoi"],["PROFIL_IMAGE","updateImageProfil"]]);static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={};async _add(e){if(!this._calledFromSave)throw new ApiError("utilisation invalide de _add, utilisez save");e.id=this._newId?.(),e.slug&&delete e.slug;for(const[t,r]of Poi.ADD_BLOCKS){const o=this._extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(o&&Object.keys(o).length>0){const e=await this[r](o);!this.id&&e?.map?.id&&(this._draftData.id=e.map.id,this._draftData.slug=e.map.slug)}}}async _update(e){if(!this.isAuthor())throw new ApiError("Vous n'avez pas les droits pour modifier ce POI",403);if(!this._calledFromSave)throw new ApiError("utilisation invalide de _update, utilisez save");e.id&&delete e.id;let t=!1;for(const[r,o]of Poi.UPDATE_BLOCKS){const n=this._extractChangedFieldsFromSchema(this.apiClient,r,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);n&&Object.keys(n).length>0&&(await this[o](n),t=!0)}return t}async addPoi(e={}){return this.isMe||(e.parent={},e.parent[`${this.parent.id}`]={type:this.parent.getEntityType(),name:this.parent.name}),this.callIsConnected((()=>this.endpointApi.addPoi(e)))}async getOrganizations(){throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`)}async getProjects(){throw new ApiError(`getProjects n'existe pas dans ${this.constructor.name}`)}async getEvents(){throw new ApiError(`getEvents n'existe pas dans${this.constructor.name}`)}async getPois(){throw new ApiError(`getPois n'existe pas dans ${this.constructor.name}`)}async getBadgesIssuer(){throw new ApiError(`getBadgesIssuer n'existe pas dans ${this.constructor.name}`)}async getNews(e={}){return super.getNews(e)}async getSubscribers(e={}){return super.getSubscribers(e)}async project(){throw new ApiError(`project n'existe pas dans ${this.constructor.name}`)}async poi(){throw new ApiError(`poi n'existe pas dans ${this.constructor.name}`)}async event(){throw new ApiError(`event n'existe pas dans ${this.constructor.name}`)}async badge(){throw new ApiError(`badge n'existe pas dans ${this.constructor.name}`)}async news(e={}){return super.news(e)}async follow(){return super.follow()}async unfollow(){return super.unfollow()}}class Project extends BaseEntity{static entityType="projects";static SCHEMA_CONSTANTS=["ADD_PROJECT","UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static ADD_BLOCKS=new Map([["ADD_PROJECT","addProject"],["PROFIL_IMAGE","updateImageProfil"]]);static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal,parent:e=>e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,t])=>[e,{type:t?.type??null,name:t?.name??null}]))):null};async _add(e){if(!this._calledFromSave)throw new ApiError("utilisation invalide de _add, utilisez save");e.id=this._newId?.(),e.slug&&delete e.slug;for(const[t,r]of Project.ADD_BLOCKS){const o=this._extractChangedFieldsFromSchema(this.apiClient,t,{...e,...this.defaultFields},(()=>{}));if(o&&Object.keys(o).length>0){const e=await this[r](o);!this.id&&e?.map?.id&&(this._draftData.id=e.map.id,this._draftData.slug=e.map.slug)}}}async _update(e){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour modifier ce projet",403);if(!this._calledFromSave)throw new ApiError("utilisation invalide de _update, utilisez save");e.id&&delete e.id;let t=!1;for(const[r,o]of Project.UPDATE_BLOCKS){const n=this._extractChangedFieldsFromSchema(this.apiClient,r,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);n&&Object.keys(n).length>0&&(await this[o](n),t=!0)}return t}async addProject(e={}){return this.isMe||(e.parent={},e.parent[`${this.parent.id}`]={type:this.parent.getEntityType(),name:this.parent.name}),this.callIsConnected((()=>this.endpointApi.addProject(e)))}async getOrganizations(){throw new ApiError(`getOrganizations n'existe pas dans ${this.constructor.name}`)}async getProjects(e={}){return super.getProjects(e)}async getEvents(){throw new ApiError(`getEvents pas encore implémenté dans ${this.constructor.name}`)}async getPois(e={}){return super.getPois(e)}async getBadgesIssuer(e={}){return super.getBadgesIssuer(e)}async getNews(e={}){return super.getNews(e)}async getSubscribers(e={}){return super.getSubscribers(e)}async getContributors(e={},t={}){const{toBeValidated:r,isAdmin:o,isInviting:n,isAdminPending:i,roles:s=[]}=t;this.isMe?(e.pathParams={type:this.getEntityType(),id:this.id},e.filters=this._buildLinkFilters(this.id,{linkType:"projects",toBeValidated:r,isAdmin:o,isAdminPending:i,isInviting:n,roles:s})):(delete e?.pathParams,e.filters=this._buildLinkFilters(this.id,{linkType:"projects",toBeValidated:"false",isAdmin:o,isInviting:n,roles:s}));const a=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getContributorsAdmin(e))):()=>this.endpointApi.getContributorsNoAdmin(e),c=await a();if(!Array.isArray(c.results))throw new ApiResponseError("Erreur lors de la récupération des contributeurs",500,c.results);const p=this._linkEntities(c.results);return{count:c.count,results:p}}async project(e={}){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour créer un projet dans ce projet",403);return super.project(e)}async poi(e={}){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour créer un POI dans ce projet",403);return super.poi(e)}async event(e={}){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour créer un événement dans ce projet",403);return super.event(e)}async badge(e={}){if(!this.isAdmin())throw new ApiError("Vous n'avez pas les droits pour créer un badge dans ce projet",403);return super.badge(e)}async news(e={}){return super.news(e)}async requestToJoin(){return super.requestToJoin()}async requestToJoinAdmin(){return super.requestToJoinAdmin()}async acceptInvitation(){return super.acceptInvitation()}async leave(){return super.leave()}async follow(){return super.follow()}async unfollow(){return super.unfollow()}}class User extends BaseEntity{static entityType="citoyens";static SCHEMA_CONSTANTS=["UPDATE_BLOCK_DESCRIPTION","UPDATE_BLOCK_INFO","UPDATE_BLOCK_SOCIAL","UPDATE_BLOCK_LOCALITY","UPDATE_BLOCK_SLUG","PROFIL_IMAGE"];static UPDATE_BLOCKS=new Map([["UPDATE_BLOCK_DESCRIPTION","updateDescription"],["UPDATE_BLOCK_SOCIAL","updateSocial"],["UPDATE_BLOCK_LOCALITY","updateLocality"],["UPDATE_BLOCK_INFO","updateInfo"],["UPDATE_BLOCK_SLUG","updateSlug"],["PROFIL_IMAGE","updateImageProfil"]]);defaultFields={typeElement:this.getEntityType()};removeFields=["typeElement"];transforms={github:(e,t)=>t?.socialNetwork?.github,gitlab:(e,t)=>t?.socialNetwork?.gitlab,facebook:(e,t)=>t?.socialNetwork?.facebook,twitter:(e,t)=>t?.socialNetwork?.twitter,instagram:(e,t)=>t?.socialNetwork?.instagram,diaspora:(e,t)=>t?.socialNetwork?.diaspora,mastodon:(e,t)=>t?.socialNetwork?.mastodon,telegram:(e,t)=>t?.socialNetwork?.telegram,signal:(e,t)=>t?.socialNetwork?.signal};constructor(e,t={},r={}){if(!r.EndpointApi)throw new ApiError("EndpointApi class must be injected to avoid circular dependency.");if(!t?.id&&!t?.slug)throw new ApiError("Vous devez fournir un id ou un slug pour créer un User.");if(!r.Organization)throw new ApiError("Organization class must be injected.");if(!r.Project)throw new ApiError("Project class must be injected.");if(!r.Event)throw new ApiError("Event class must be injected.");if(!r.Poi)throw new ApiError("Poi class must be injected.");if(!r.Badge)throw new ApiError("Badge class must be injected.");if(!r.News)throw new ApiError("News class must be injected.");super(e,t,r)}get slug(){return this._draftData.slug||null}get isMe(){return this.isConnected&&this.userId===this.id}get parentIsMe(){return super.isMe}get isActingUser(){return this.parentIsMe&&!this.isMe}async get(){return this.apiClient.safeCall((async()=>{if(this.isMe){const e=await this.endpointApi.meInfoUrl();return this._setData(e),e}{const e=await this._getPublicProfile();return this._setData(e),e}}))}async changePassword(e={}){return this.callIsMe((()=>this.endpointApi.changePassword(e)))}async delete(e={}){return this.callIsMe((()=>this.endpointApi.deleteAccount(e)))}async save(){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour sauvegarder.");await super.save()}async _add(){throw new ApiError("Vous ne pouvez pas ajouter un utilisateur par ce moyen.")}async _update(e){if(!this._calledFromSave)throw new Error("utilisation invalide de _update, utilisez save");e.id&&delete e.id;let t=!1;for(const[r,o]of User.UPDATE_BLOCKS){const n=this._extractChangedFieldsFromSchema(this.apiClient,r,{...e,...this.defaultFields},(()=>this.initialDraftData),this.removeFields);n&&Object.keys(n).length>0&&(await this[o](n),t=!0)}return t}static fromServerData(e,t,r){return new User(t.apiClient,e,r)}async updateSettings(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour mettre à jour les paramètres.");await super.updateSettings(e),await this.refresh()}async updateDescription(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour mettre à jour la description.");return super.updateDescription(e)}async updateInfo(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour mettre à jour les informations.");return super.updateInfo(e)}async updateSocial(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour mettre à jour les réseaux sociaux.");return super.updateSocial(e)}async updateLocality(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour mettre à jour la localité.");return super.updateLocality(e)}async updateSlug({slug:e}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour mettre à jour le slug.");return super.updateSlug({slug:e})}async updateImageProfil({profil_avatar:e}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour mettre à jour l'image de profil.");return super.updateImageProfil({profil_avatar:e})}async getOrganizations(e={}){delete e?.pathParams;const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getOrganizationsAdmin(e))):()=>this.endpointApi.getOrganizationsNoAdmin(e);this.isMe||e.filters||(e.filters={[`links.members.${this.id}`]:{$exists:!0},[`links.members.${this.id}.toBeValidated`]:{$exists:!1},[`links.members.${this.id}.isInviting`]:{$exists:!1}});const r=await t();if(!Array.isArray(r.results))throw new ApiResponseError("Erreur lors de la récupération des organisations.",500,r.results);delete r?.count?.spam;const o=Object.values(r.count||{}).reduce(((e,t)=>e+t),0);r.count.total=o;const n=this._linkEntities(r.results);return{count:r.count,results:n}}async getProjects(e={}){return super.getProjects(e)}async getPois(e={}){return super.getPois(e)}async getNews(e={}){return super.getNews(e)}async getFriends(e={}){delete e?.pathParams,this.isMe||(e.pathParams={id:this.id});const t=await this.endpointApi.getFriendsAdmin(e);if(!Array.isArray(t.results))throw new ApiResponseError("Erreur lors de la récupération des amis administrables.",500,t);const r=this._linkEntities(t.results);return{count:t?.count?.citoyens??0,results:r}}async getSubscriptions(e={}){delete e?.pathParams;const t=this.isMe?()=>this.callIsMe((()=>this.endpointApi.getSubscriptionsAdmin(e))):()=>this.endpointApi.getSubscriptions(e);this.isMe||e.filters||(e.filters={[`links.followers.${this.id}`]:{$exists:!0}});const r=await t();if(!Array.isArray(r.results))throw new ApiResponseError("Erreur lors de la récupération des abonnements.",500,r.results);const o=this._linkEntities(r.results);return{count:r.count,results:o}}async getSubscribers(e={}){return super.getSubscribers(e)}async getBadgesIssuer(e={}){return super.getBadgesIssuer(e)}async getBadges(e={}){return await this.linkEntitiesFromServerData("badges",e)}async user(e){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur");if(!e.id&&!e.slug)throw new ApiError("Vous devez fournir un id ou un slug pour créer un User.");const t=new User(this,e,this.deps);return await t.get(),t}async organization(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer une organisation.");return super.organization(e)}async project(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer un projet.");return super.project(e)}async news(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer une actualité.");return super.news(e)}async poi(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer un POI.");return super.poi(e)}async event(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer un événement.");return super.event(e)}async badge(e={}){if(!this.isMe)throw new ApiError("Vous devez être connecté et être l'utilisateur pour créer un badge.");return super.badge(e)}async sendFriendRequest(){if(!this.isActingUser)throw new ApiError("Vous devez être connecté pour envoyer une demande d'amis.");if(this._checkLinkableEntity(),!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);const{connectTypeConnect:e}=this._getLinkMeta(),t=this._getLinkFromConnectedUser();if(!t){const t={parentType:this.getEntityType(),parentId:this.id,connectType:e},r=await this.endpointApi.connect(t);return await this.userContext.refresh(),r}if(t.isInviting&&t.invitorId===this.id)return this.acceptFriendRequest();if(t.isInviting&&t.invitorId===this.userId)throw new ApiError("Vous avez déjà envoyé une demande d'amis à cet utilisateur.");throw new ApiError("Vous êtes déjà connecté à cette entité.")}async acceptFriendRequest(){if(!this.isActingUser)throw new ApiError("Vous devez être connecté pour accepter une demande d'amitié.");if(this._checkLinkableEntity(),!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);const e=this._getLinkFromConnectedUser();if(e?.isInviting&&e.invitorId===this.id){const e={parentType:this.getEntityType(),parentId:this.id,linkOption:"isInviting"},t=await this.endpointApi.linkValidate(e);return await this.userContext.refresh(),t}throw new ApiError("Vous n'avez pas d'invitation à valider.")}async removeFriend(){if(!this.isActingUser)throw new ApiError("Vous devez être connecté pour supprimer un ami.");if(this._checkLinkableEntity(),!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);const{connectTypeDisconnect:e}=this._getLinkMeta();if(!this._getLinkFromConnectedUser())throw new ApiError("Vous n'êtes pas connecté à cette entité.");const t={parentType:this.getEntityType(),parentId:this.id,connectType:e},r=await this.endpointApi.disconnect(t);return await this.userContext.refresh(),r}requestToJoin(){throw new ApiError("l'utilisation de requestToJoin n'est pas autorisée sur un utilisateur.")}requestToJoinAdmin(){throw new ApiError("l'utilisation de requestToJoinAdmin n'est pas autorisée sur un utilisateur.")}acceptInvitation(){throw new ApiError("l'utilisation de acceptInvitation n'est pas autorisée sur un utilisateur.")}leave(){throw new ApiError("l'utilisation de leave n'est pas autorisée sur un utilisateur.")}async follow(){if(!this.isActingUser)throw new ApiError("Vous devez être connecté pour suivre un utilisateur.");if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);if(!(this.userContext?.serverData?.links?.follows?.[this.id]||null)){const e={parentType:this.getEntityType(),parentId:this.id},t=await this.endpointApi.follow(e);return await this.userContext.refresh(),t}throw new ApiError("Vous êtes déjà abonné à cet utilisateur.")}async unfollow(){if(!this.isActingUser)throw new ApiError("Vous devez être connecté pour vous désabonner d'un utilisateur.");if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);if(this.userContext?.serverData?.links?.follows?.[this.id]||null){const e={parentType:this.getEntityType(),parentId:this.id,connectType:"followers"},t=await this.endpointApi.disconnect(e);return await this.userContext.refresh(),t}throw new ApiError("Vous n'êtes pas abonné à cet utilisateur.")}isFriend(){if(!this.isActingUser)throw new ApiError("Vous devez être connecté pour vérifier si vous êtes ami.");this._assertEntityType("citoyens");const e=this._getLinkFromConnectedUser();return this._validateUserLink(e)}isFollower(){if(!this.isActingUser)throw new ApiError("Vous devez être connecté pour vérifier si il vous suit.");if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);return this._assertEntityType("citoyens"),this._isLinked("followers")}isFollowing(){if(!this.isActingUser)throw new ApiError("Vous devez être connecté pour vérifier si vous le suivez.");if(!this.id)throw new ApiError(`${this.constructor.name} non enregistrée.`);return this._assertEntityType("citoyens"),this._isLinked("follows")}}Object.assign(User.prototype,{});const C={_looksLikeObjectID:e=>24===e.length&&/^[0-9a-f]*$/.test(e),ObjectID:class ObjectID{constructor(e){if(e){if(e=e.toLowerCase(),!C._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=e}}equals(e){return e instanceof C.ObjectID&&this.valueOf()===e.valueOf()}toString(){return`ObjectID("${this._str}")`}clone(){return new C.ObjectID(this._str)}typeName(){return"oid"}getTimestamp(){return Number.parseInt(this._str.substr(0,8),16)}valueOf(){return this._str}toJSONValue(){return this.valueOf()}toHexString(){return this.valueOf()}}},D={common1:{type:"string"},common2:{format:"email",type:"string"},common3:{type:"boolean"},common4:{format:"uri",type:"string"},common5:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common6:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},required:["id"],type:"object"},common8:{additionalProperties:!1,properties:{reason:{default:"",type:"string"}},required:["reason"],type:"object"},common10:{default:"",type:"string"},common11:{pattern:"^[a-f0-9]{24}$",type:"string"},common12:{const:"citoyens"},common13:{properties:{value:{type:"boolean"}}},common15:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},common16:{},common17:{else:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},if:{properties:{typeElement:{const:"citoyens"}}},then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}}},common20:{properties:{typeElement:{const:"citoyens"}}},common23:{not:{type:"null"}},common25:{default:"citoyens",enum:["citoyens","projects","organizations","poi"],type:"string"},common26:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common27:{items:{type:"string"},type:"array"},common28:{enum:[""],type:"string"},common29:{properties:{name:{not:{type:"null"}}},required:["name"]},common31:{properties:{url:{not:{type:"null"}}},required:["url"]},common33:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common35:{properties:{email:{not:{type:"null"}}},required:["email"]},common37:{const:"info",default:"info",type:"string"},common38:{$ref:"#/$defs/sharedFields/email"},common39:{$ref:"#/$defs/sharedFields/name"},common40:{$ref:"#/$defs/sharedFields/tags"},common41:{default:"citoyens",enum:["citoyens"],type:"string"},common42:{$ref:"#/$defs/sharedFields/url"},common43:{const:"projects"},common44:{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type","name"],type:"object"},common45:{name:{type:"string"},type:{type:"string"}},common46:{const:"organizations"},common47:{properties:{type:{not:{type:"null"}}},required:["type"]},common49:{enum:["link","tool","machine","software","rh","Resource material","Financial Ressource","ficheBlanche","geoJson","compostPickup","video","sharedLibrary","recoveryCenter","trash","history","something2See","funPlace","place","artPiece","streetArts","openScene","stand","parking","other"],type:"string"},common50:{enum:["poi"],type:"string"},common51:{$ref:"#/$defs/socialField"},common52:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},common55:{additionalProperties:!1,properties:{"@type":{const:"PostalAddress",type:"string"},addressCountry:{type:"string"},addressLocality:{type:"string"},codeInsee:{type:"string"},level1:{type:"string"},level1Name:{type:"string"},level3:{minLength:0,type:"string"},level3Name:{minLength:0,type:"string"},level4:{minLength:0,type:"string"},level4Name:{minLength:0,type:"string"},localityId:{type:"string"},postalCode:{type:"string"},streetAddress:{type:"string"}},required:["@type","addressCountry","codeInsee","addressLocality","localityId","level1","level1Name"],type:"object"},common59:{additionalProperties:!1,properties:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},required:["latitude","longitude"],type:"object"},common63:{additionalProperties:!0,properties:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},required:["type","coordinates","float"],type:"object"},common66:{type:"number"},common67:{const:!0,default:!0,type:"boolean"},common69:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common72:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common73:{properties:{type:{const:"citoyens"}}},common75:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},common77:{properties:{folder:{const:"citoyens"}}},common79:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common81:{properties:{parentId:{pattern:"^[a-f0-9]{24}$"}}},common83:{properties:{parentType:{const:"citoyens"}}},common85:{properties:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common87:{default:!0,type:"boolean"},common88:{default:0,type:"integer"},common89:{required:["text"]},common90:{required:["mediaImg"]},common91:{required:["mediaFile"]},common92:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common94:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common96:{items:{properties:{count:{minimum:1,type:"integer"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common100:{default:"public",enum:["public","private","restricted"],type:"string"},common101:{const:"news",default:"news",type:"string"},common102:{additionalProperties:!1,else:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{folder:{const:"citoyens"}}},properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},required:["folder","ownerId"],then:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common104:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common105:{default:!1,type:"boolean"},common106:{properties:{childId:{pattern:"^[a-f0-9]{24}$"}}},common108:{properties:{childType:{const:"citoyens"}}},common110:{const:"share",default:"share",type:"string"},common111:{properties:{childId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common113:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common115:{default:"news",enum:["news"],type:"string"},common116:{items:{additionalProperties:!1,properties:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},type:"array"},common119:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common120:{const:!1,default:!1,type:"boolean"},common121:{const:"",default:"",type:"string"},common122:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common124:{default:0,minimum:0,type:"integer"},common125:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common127:{$exists:!0},common128:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common131:{default:30,type:"integer"},common132:{additionalProperties:!1,else:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},if:{properties:{type:{const:"citoyens"}}},properties:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},required:["type","id"],then:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},type:"object"},common134:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common135:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common137:{$exists:!1},common138:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common140:{const:!1},common141:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common143:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common145:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common148:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common150:{const:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],default:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],items:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},type:"array"},common152:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common155:{"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},"^links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"}},common156:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common159:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common161:{const:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],default:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],items:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},type:"array"},common163:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common165:{const:!0,type:"boolean"},common166:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common169:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"}},common170:{indexMax:30,indexMin:0},common171:{properties:{parentType:{const:"organizations"}}},common173:{properties:{parentType:{const:"projects"}}},common175:{properties:{parentType:{const:"events"}}},common178:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common179:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common180:{enum:["citoyens","organizations","projects","events"],type:"string"},common181:{const:"citoyens",default:"citoyens",type:"string"},common182:{const:"@userId",default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common183:{default:{isOpenData:!0,isOpenEdition:!0},properties:{isOpenData:{default:!0,type:"boolean"},isOpenEdition:{default:!0,type:"boolean"}},required:["isOpenData","isOpenEdition"],type:"object"},common186:{additionalProperties:!1,default:{"@userId":{type:"citoyens"}},patternProperties:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},type:"object"},common189:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},common191:{const:"poi",default:"poi",type:"string"},common192:{const:"events",default:"events",type:"string"},common193:{format:"date-time",type:"string"},common194:{pattern:"^([01]\\d|2[0-3]):[0-5]\\d$",type:"string"},common195:{enum:["workshop","competition","concert","contest","conference","debate","exhibition","festival","crowdfunding","fair","course","protest","market","film","getTogether","meeting","spectacle","internship","stand","others"],type:"string"},common196:{type:"integer"},common197:{additionalProperties:!1,properties:{id:{default:"@userId",pattern:"^[a-f0-9]{24}$",type:"string"},type:{const:"citoyens",default:"citoyens",type:"string"}},required:["type","id"],type:"object"},common200:{const:"badges",default:"badges",type:"string"},common201:{const:"badge",default:"badge",type:"string"},common202:{patternProperties:{"^[0-9a-f]{24}$":{additionalProperties:!1,properties:{isAdmin:{default:"",enum:["","admin"],type:"string"},name:{type:"string"},roles:{items:{type:"string"},type:"array"}},required:["name"],type:"object"}},type:"object"},common206:{default:"",enum:["","admin"],type:"string"}};var L=[{auth:"none",constant:"PERSON_REGISTER",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/register",request:{additionalProperties:!1,properties:{app:D.common1,email:D.common2,isInvitation:D.common3,mode:D.common1,name:D.common1,pendingUserId:D.common1,pwd:D.common1,username:D.common1},required:["name","username","email","pwd"],type:"object"}},{auth:"none",constant:"AUTHENTICATE_URL",contentType:"application/json",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/api/cocolight/authenticate",postActions:[{path:"accessToken",type:"setToken"},{path:"refreshToken",type:"setRefreshToken"},{event:"userLoggedIn",path:"user",type:"emitEvent"}],request:{additionalProperties:!1,properties:{email:D.common2,password:D.common1},required:["email","password"],type:"object"}},{auth:"none",constant:"REFRESH_TOKEN_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/refreshtoken",request:{additionalProperties:!1,properties:{refreshToken:D.common1},required:["refreshToken"],type:"object"}},{auth:"bearer",constant:"ME_INFO_URL",contentType:"application/json",method:"POST",path:"/api/cocolight/me"},{auth:"none",constant:"PASSWORD_RECOVERY",contentType:"application/x-www-form-urlencoded",generateModule:"UserNoAuth",method:"POST",onlyAuthNone:!0,path:"/co2/person/sendemail",request:{additionalProperties:!1,properties:{email:D.common2,type:{const:"password",default:"password",type:"string"}},required:["email","type"],type:"object"}},{auth:"bearer",constant:"SERVER_EXCHANGE_TOKEN",contentType:"application/json",method:"POST",path:"/api/cocolight/exchangetoken",request:{additionalProperties:!1,properties:{serverUrl:D.common4},required:["serverUrl"],type:"object"}},{auth:"bearer",constant:"CHANGE_PASSWORD",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/person/changepassword",request:{additionalProperties:!1,properties:{mode:{const:"changePassword",default:"changePassword",type:"string"},newPassword:D.common1,newPassword2:D.common1,oldPassword:D.common1,scope:{default:"",type:["string"]},userId:D.common5},required:["mode","userId","oldPassword","newPassword","newPassword2"],type:"object"}},{auth:"bearer",constant:"DELETE_ACCOUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/id/{id}/type/citoyens",pathParams:D.common6,postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:D.common8},{auth:"bearer",constant:"UPDATE_SETTINGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatesettings",request:{additionalProperties:!1,allOf:[{else:{properties:{idEntity:D.common11}},if:{properties:{typeEntity:D.common12}},then:{properties:{idEntity:D.common5}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:D.common12}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:D.common12}},then:D.common13},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:D.common12}}},then:D.common13}],properties:{idEntity:D.common1,type:D.common1,typeEntity:D.common15,value:D.common16},required:["type","value","typeEntity","idEntity"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_DESCRIPTION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{additionalProperties:!1,allOf:[D.common17,{anyOf:[{properties:{description:D.common23},required:["description"]},{properties:{shortDescription:D.common23},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:D.common10,description:D.common1,id:D.common1,scope:{default:"",type:["string","null"]},shortDescription:D.common1,typeElement:D.common25},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_INFO",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{sharedFields:{email:D.common2,name:D.common1,tags:D.common26,url:D.common4}},allOf:[{if:D.common20,then:{additionalProperties:!1,anyOf:[D.common29,{properties:{birthDate:D.common23},required:["birthDate"]},{properties:{fixe:D.common23},required:["fixe"]},{properties:{mobile:D.common23},required:["mobile"]},D.common31,D.common33,D.common35],properties:{birthDate:{format:"date",type:"string"},block:D.common37,email:D.common38,fixe:D.common1,id:D.common5,mobile:D.common1,name:D.common39,scope:D.common10,tags:D.common40,typeElement:D.common41,url:D.common42}}},{if:{properties:{typeElement:D.common43}},then:{additionalProperties:!1,anyOf:[D.common29,D.common31,D.common33,D.common35,{properties:{avancement:D.common23},required:["avancement"]},{properties:{parent:D.common23},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:D.common37,email:D.common38,id:D.common1,name:D.common39,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":D.common44},type:"object"},scope:D.common10,tags:D.common40,typeElement:{default:"citoyens",enum:["projects"],type:"string"},url:D.common42}}},{if:{properties:{typeElement:D.common46}},then:{additionalProperties:!1,anyOf:[D.common29,D.common31,D.common33,D.common35,D.common47],properties:{block:D.common37,email:D.common38,id:D.common1,name:D.common39,scope:D.common10,tags:D.common40,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:{enum:["organizations"],type:"string"},url:D.common42}}},{if:{properties:{typeElement:{const:"poi"}}},then:{additionalProperties:!1,anyOf:[D.common29,D.common31,D.common33,D.common35,D.common47,{properties:{urls:D.common23},required:["urls"]}],properties:{block:D.common37,email:D.common38,id:D.common1,name:D.common39,scope:D.common10,tags:D.common40,type:D.common49,typeElement:D.common50,url:D.common42,urls:D.common27}}}],properties:{block:D.common37,id:D.common1,scope:D.common10,typeElement:D.common25},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SOCIAL",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{$defs:{socialField:{anyOf:[D.common28,D.common4]}},allOf:[D.common17,{anyOf:[{properties:{gitlab:D.common23},required:["gitlab"]},{properties:{github:D.common23},required:["github"]},{properties:{twitter:D.common23},required:["twitter"]},{properties:{facebook:D.common23},required:["facebook"]},{properties:{instagram:D.common23},required:["instagram"]},{properties:{diaspora:D.common23},required:["diaspora"]},{properties:{mastodon:D.common23},required:["mastodon"]},{properties:{telegram:D.common23},required:["telegram"]},{properties:{signal:D.common23},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:D.common51,facebook:D.common51,github:D.common51,gitlab:D.common51,id:D.common1,instagram:D.common51,mastodon:D.common51,scope:D.common10,signal:D.common51,telegram:D.common51,twitter:D.common51,typeElement:D.common15},required:["block","typeElement","id"],type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_LOCALITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:D.common52,if:D.common20,properties:{address:D.common55,block:{const:"localities",default:"localities",type:"string"},geo:D.common59,geoPosition:D.common63,id:D.common1,scope:D.common10,typeElement:D.common25},required:["block","typeElement","id","address"],then:D.common69,type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:D.common52,if:D.common20,properties:{block:D.common37,id:D.common1,scope:D.common10,slug:D.common72,typeElement:D.common25},required:["block","typeElement","id","slug"],then:D.common69,type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,else:D.common52,if:D.common73,properties:{block:D.common37,id:D.common1,slug:D.common72,type:D.common15},required:["block","type","id","slug"],then:D.common69,type:"object"}},{auth:"bearer",constant:"PROFIL_IMAGE",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/profil_avatar/contentKey/profil/docType/image",pathParams:{additionalProperties:!1,else:D.common75,if:D.common77,properties:{folder:{default:"citoyens",enum:["citoyens","projects","organizations","events","poi"],type:"string"},ownerId:D.common1},required:["folder","ownerId"],then:D.common79,type:"object"},request:{additionalProperties:!1,properties:{profil_avatar:D.common16},required:["profil_avatar"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_ABOUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/about/type/{type}/id/{id}/json/true",pathParams:{additionalProperties:!1,else:D.common52,if:D.common73,properties:{id:D.common1,type:{default:"citoyens",enum:["citoyens","projects","organizations","events","poi","badges"],type:"string"}},required:["type","id"],then:D.common69,type:"object"},request:{additionalProperties:!1,properties:{tpl:{const:"ficheInfoElement",default:"ficheInfoElement",type:"string"}},required:["tpl"],type:"object"}},{auth:"bearer",constant:"MULTICONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:D.common81,if:D.common83,properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:D.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:D.common1,parentType:D.common15},required:["parentId","parentType","listInvite"],then:D.common85,type:"object"}},{auth:"none",constant:"GET_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/get/type/{type}/id/{id}/isLive/{isLive}/json/true",pathParams:{additionalProperties:!1,else:D.common52,if:D.common73,properties:{id:D.common1,isLive:D.common87,type:D.common15},required:["isLive","type","id"],then:D.common69,type:"object"},request:{additionalProperties:!1,properties:{dateLimit:D.common88,indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:D.common10},required:["name"],type:"object"}},required:["dateLimit","indexStep"],type:"object"}},{auth:"none",constant:"GET_NEWS_BY_ID",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/getbyids",request:{additionalProperties:!1,properties:{ids:{items:D.common11,type:"array"}},required:["ids"],type:"object"}},{auth:"bearer",constant:"ADD_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/save",request:{additionalProperties:!1,anyOf:[D.common89,D.common90,D.common91],else:D.common81,if:D.common83,properties:{json:D.common67,markdownActive:D.common87,mediaFile:D.common92,mediaImg:D.common94,mentions:D.common96,parentId:D.common1,parentType:D.common15,scope:D.common100,tags:D.common26,text:D.common1,type:D.common101},required:["scope","markdownActive","parentId","parentType","type","json"],then:D.common85,type:"object"}},{auth:"bearer",constant:"ADD_IMAGE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/newsImage/docType/image/contentKey/slider",pathParams:D.common102,request:{additionalProperties:!1,properties:{newsImage:D.common16},required:["newsImage"],type:"object"}},{auth:"bearer",constant:"ADD_FILE_NEWS",contentType:"multipart/form-data",method:"POST",path:"/co2/document/uploadSave/dir/communecter/folder/{folder}/ownerId/{ownerId}}/input/newsFile/docType/file",pathParams:D.common102,request:{additionalProperties:!1,properties:{newsFile:D.common16},required:["newsFile"],type:"object"}},{auth:"bearer",constant:"DELETE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/delete/id/{id}",pathParams:D.common104,request:{additionalProperties:!1,properties:{isLive:D.common105},required:["isLive"],type:"object"}},{auth:"bearer",constant:"UPDATE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/update",request:{additionalProperties:!1,anyOf:[D.common89,D.common90,D.common91],else:D.common81,if:D.common83,properties:{idNews:D.common11,markdownActive:D.common87,mediaFile:D.common92,mediaImg:D.common94,mentions:D.common96,parentId:D.common1,parentType:D.common15,scope:D.common100,tags:D.common26,text:D.common1,type:D.common101},required:["idNews","scope","markdownActive","parentId","parentType","type"],then:D.common85,type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:D.common106,if:D.common108,properties:{childId:D.common11,childType:D.common15,comment:D.common1,connectType:D.common110,parentId:D.common11,parentType:D.common101},required:["parentId","parentType","childId","childType","connectType"],then:D.common111,type:"object"}},{auth:"none",constant:"GET_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/index/type/{type}/id/{id}/json/true",pathParams:D.common113},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:D.common10,contextId:D.common11,contextType:D.common115,mentions:D.common116,parentCommentId:D.common11,path:D.common10,text:D.common1},required:["text","contextId","contextType"],type:"object"}},{auth:"bearer",constant:"DELETE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/delete/id/{id}",pathParams:D.common104},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:D.common11,params:{properties:{mentions:D.common116,text:D.common1},required:["text"],type:"object"}},required:["id","params"],type:"object"}},{auth:"none",constant:"SEARCH_TAGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/tags/search?q={q}",pathParams:{additionalProperties:!1,properties:{q:D.common1},required:["q"],type:"object"}},{auth:"none",constant:"SHOW_VOTE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/action/list/type/{type}/id/{id}/actionType/vote/json/true",pathParams:D.common113},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:D.common119,type:"array"},fediverse:D.common120,filters:D.common121,indexMin:{const:0,default:0,type:"number"},indexStep:D.common66,initType:D.common121,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:D.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:D.common1,notSourceKey:D.common67,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":D.common122},type:"object"},searchTags:D.common27,searchType:{items:D.common119,type:"array"}},required:["name","searchType","countType","indexMin","indexStep","initType","count","notSourceKey","filters","fediverse"],type:"object"}},{auth:"none",constant:"CITY_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{minimum:5,type:"integer"},indexMin:{minimum:0,type:"integer"},locality:D.common121,name:D.common1,searchBy:{const:"ALL",default:"ALL",type:"string"},searchType:{const:["cities"],default:["cities"],items:{enum:["cities"],type:"string"},type:"array"}},required:["name","locality","searchType"],type:"object"}},{auth:"none",constant:"SUGGESTION_INPUT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{indexMax:{default:20,minimum:20,type:"integer"},indexMin:D.common124,name:D.common1,searchType:{items:{enum:["organizations","projects","poi"],type:"string"},type:"array"}},required:["name","searchType","indexMin","indexMax"],type:"object"}},{auth:"none",constant:"GET_PROJECTS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common125,fediverse:D.common120,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":D.common127,"parent.@userId":D.common127},"links.contributors.@userId":D.common127},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":D.common128},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":D.common128,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":D.common128},type:"object"}},required:["$or"],type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common125},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_PROJECTS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:D.common132,request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common125,fediverse:D.common120,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":D.common127,"parent.@{pathParams.id}":D.common127},"links.contributors.@{pathParams.id}":D.common127},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128},type:"object"}},required:["$or"],type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common125},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_POIS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common134,fediverse:D.common120,filters:{additionalProperties:!1,default:{"parent.@userId":D.common127},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":D.common128},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_POIS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:D.common132,request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common134,fediverse:D.common120,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":D.common127},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_ORGANIZATIONS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common135,fediverse:D.common120,filters:{additionalProperties:!1,default:{"links.members.@userId":D.common127,"links.members.@userId.isInviting":D.common137,"links.members.@userId.toBeValidated":D.common137},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":D.common128,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":D.common138,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":D.common138},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common135},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_ORGANIZATIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,else:D.common52,if:D.common73,properties:{id:D.common1,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],then:D.common69,type:"object"},request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common135,fediverse:D.common120,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":D.common127,"links.members.@{pathParams.id}.isInviting":D.common137,"links.members.@{pathParams.id}.toBeValidated":D.common137},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":D.common138,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":D.common138},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common135},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_MEMBERS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common141,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)$":D.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":D.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdminPending$":D.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":D.common143,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":D.common145,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":D.common138},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common141},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_MEMBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/organizations/id/{id}/canSee/true",pathParams:D.common104,request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common141,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.memberOf.@{pathParams.id}":D.common127,"links.memberOf.@{pathParams.id}.isInviting":D.common137,"links.memberOf.@{pathParams.id}.toBeValidated":D.common137},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":D.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdminPending$":D.common128,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":D.common143,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":D.common145,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":D.common143},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common141},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_FRIENDS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:D.common6,request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common148,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.friends.@{pathParams.id}":D.common127,"links.friends.@{pathParams.id}.isInviting":D.common137,"links.friends.@{pathParams.id}.toBeValidated":D.common137},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":D.common143,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":D.common143},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common148},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIPTIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common150,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[D.common152],default:{"links.followers.@userId":D.common127,"links.followers.@{userId}.isInviting":D.common137,"links.followers.@{userId}.toBeValidated":D.common137},patternProperties:D.common155,type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common150},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIPTIONS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/citoyens/id/{id}/canSee/true",pathParams:D.common6,request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common150,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[D.common152],default:{"links.followers.@{pathParams.id}":D.common127,"links.followers.@{pathParams.id}.isInviting":D.common137,"links.followers.@{pathParams.id}.toBeValidated":D.common137},patternProperties:D.common155,type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common150},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_SUBSCRIBERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common148,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[D.common156],default:{"links.follows.@userId":D.common127,"links.follows.@{userId}.isInviting":D.common137,"links.follows.@{userId}.toBeValidated":D.common137},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":D.common138,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":D.common138},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common148},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_SUBSCRIBERS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/{type}/id/{id}/canSee/true",pathParams:{additionalProperties:!1,allOf:[{else:D.common52,if:D.common73,then:D.common69}],properties:{id:D.common1,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common148,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[D.common156],default:{"links.follows.@{pathParams.id}":D.common127},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common148},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_CONTRIBUTORS_NO_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common141,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$)"}}},{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$)"}}}],patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)$":D.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":D.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdminPending$":D.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":D.common143,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":D.common145,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":D.common138},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common141},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"GET_CONTRIBUTORS_ADMIN",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocompleteadmin/type/projects/id/{id}/canSee/true",pathParams:D.common104,request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common141,fediverse:D.common120,filters:{additionalProperties:!1,allOf:[{not:{propertyNames:{pattern:"^(?!links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}}],default:{"links.projects.@{pathParams.id}":D.common127,"links.projects.@{pathParams.id}.isInviting":D.common137,"links.projects.@{pathParams.id}.toBeValidated":D.common137},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":D.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":D.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdminPending$":D.common128,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":D.common143,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":D.common145,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":D.common143},type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common141},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common159,fediverse:D.common120,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":D.common128},type:"object"},isParcours:D.common3,"preferences.private":D.common120},required:["preferences.private"],type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,searchType:D.common159},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_BADGES_FILTERS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:D.common67,countType:D.common161,fediverse:D.common120,fields:D.common159,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":D.common163}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":D.common163,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":D.common166,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":D.common166}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:D.common169},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:D.common169,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":D.common165}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":D.common163}}],type:"object"},indexMin:D.common124,indexStep:D.common131,initType:D.common121,locality:D.common121,name:D.common1,notSourceKey:D.common67,ranges:{additionalProperties:!1,default:{Cooperative:D.common170,GovernmentOrganization:D.common170,Group:D.common170,LocalBusiness:D.common170,NGO:D.common170,citoyens:D.common170,projects:D.common170},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":D.common122},type:"object"},searchType:D.common161},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","locality","fediverse"],type:"object"}},{auth:"bearer",constant:"CONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/connect",request:{additionalProperties:!1,allOf:[{if:D.common83,then:{properties:{connectType:{const:"friend",default:"friend"}}}},{if:D.common171,then:{properties:{connectType:{enum:["admin","member"]}}}},{if:D.common173,then:{properties:{connectType:{enum:["admin","contributor"]}}}},{if:D.common175,then:{properties:{connectType:{default:"attendee",enum:["attendee","connect"]}}}}],properties:{childId:D.common178,childType:D.common179,connectType:{enum:["admin","member","contributor","attendee","friend","connect"],type:"string"},parentId:D.common11,parentType:D.common180},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"bearer",constant:"DISCONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/disconnect",request:{additionalProperties:!1,allOf:[{if:D.common83,then:{properties:{connectType:{default:"friends",enum:["friends","followers"]}}}},{if:D.common171,then:{properties:{connectType:{default:"members",enum:["members","followers"]}}}},{if:D.common173,then:{properties:{connectType:{default:"contributors",enum:["contributors","followers"]}}}},{if:D.common175,then:{properties:{connectType:{default:"attendees",enum:["attendees","followers"]}}}}],properties:{childId:D.common178,childType:D.common179,connectType:{enum:["members","contributors","attendees","friends","followers"],type:"string"},parentId:D.common11,parentType:D.common180},required:["childId","childType","parentType","parentId","connectType"],type:"object"}},{auth:"none",constant:"GET_ELEMENTS_KEY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/getinfo/key/{slug}",pathParams:{additionalProperties:!1,properties:{slug:{pattern:"^([a-zA-Z0-9-_]+)$",type:"string"}},required:["slug"],type:"object"}},{auth:"bearer",constant:"GET_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/config/type/citoyens/id/{id}/json/true",pathParams:D.common6},{auth:"bearer",constant:"DELETE_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue?index={index}",pathParams:{properties:{index:D.common66},type:"object"},request:{additionalProperties:!1,properties:{collection:D.common181,id:D.common182,path:{const:"preferences.search.@{pathParams.index}",default:"preferences.search.@{pathParams.index}",type:"string"},pull:{const:"preferences.search",type:"string"},value:D.common121},required:["id","collection","path","pull","value"],type:"object"}},{auth:"bearer",constant:"ADD_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue",request:{additionalProperties:!1,properties:{arrayForm:D.common165,collection:D.common181,id:D.common182,path:{const:"preferences.search",default:"preferences.search",type:"string"},value:{additionalProperties:!1,properties:{description:D.common1,locality:{patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:D.common45,required:["name","type"]}},type:"object"},name:D.common1,tags:D.common27,url:D.common1},required:["url","name"],type:"object"}},required:["id","collection","path","arrayForm","value"],type:"object"}},{auth:"bearer",constant:"ADD_ORGANIZATION",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:D.common55,collection:{const:"organizations",default:"organizations",type:"string"},email:D.common2,geo:D.common59,geoPosition:D.common63,id:D.common11,key:{const:"organization",default:"organization",type:"string"},name:{minLength:3,type:"string"},preferences:D.common183,role:{enum:["admin","member"],type:"string"},scope:D.common121,shortDescription:D.common1,tags:D.common27,type:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},url:D.common4},required:["id","collection","key","name","type","role","scope"],type:"object"}},{auth:"bearer",constant:"ADD_PROJECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:D.common55,collection:{const:"projects",default:"projects",type:"string"},geo:D.common59,geoPosition:D.common63,id:D.common11,key:{const:"project",default:"project",type:"string"},name:D.common1,parent:D.common186,preferences:{default:{crowdfunding:!0,isOpenData:!1,isOpenEdition:!1},properties:{crowdfunding:D.common87,isOpenData:D.common105,isOpenEdition:D.common105},required:["isOpenData","isOpenEdition"],type:"object"},public:D.common87,scope:D.common121,shortDescription:D.common1,tags:D.common27,url:D.common4},required:["id","collection","key","parent","name","public","scope"],type:"object"}},{auth:"bearer",constant:"ADD_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{address:D.common55,collection:D.common191,description:D.common1,geo:D.common59,geoPosition:D.common63,id:D.common11,key:D.common191,name:D.common1,parent:D.common186,scope:D.common121,tags:D.common27,type:D.common49,urls:D.common27},required:["id","collection","key","parent","type","name"],type:"object"}},{auth:"bearer",constant:"ADD_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,else:{required:["openingHours"]},if:{properties:{recurrency:D.common140}},properties:{address:D.common55,collection:D.common192,email:D.common2,endDate:D.common193,geo:D.common59,geoPosition:D.common63,id:D.common11,key:{const:"event",default:"event",type:"string"},name:D.common1,openingHours:{default:["","","","","","",""],items:{anyOf:[{const:"",type:"string"},{additionalProperties:!1,properties:{dayOfWeek:{enum:["Mo","Tu","We","Th","Fr","Sa","Su"],type:"string"},hours:{default:[],items:{additionalProperties:!1,properties:{closes:D.common194,opens:D.common194},required:["opens","closes"],type:"object"},type:"array"}},required:["dayOfWeek","hours"],type:"object"}]},maxItems:7,minItems:7,type:"array"},organizer:D.common186,parent:{additionalProperties:!1,patternProperties:D.common189,type:"object"},preferences:{default:{isOpenData:!1,isOpenEdition:!1},properties:{isOpenData:D.common105,isOpenEdition:D.common105},required:["isOpenData","isOpenEdition"],type:"object"},public:D.common87,recurrency:D.common105,scope:D.common121,shortDescription:D.common1,startDate:D.common193,tags:D.common27,timeZone:D.common1,type:D.common195,url:D.common4},required:["id","collection","key","organizer","type","name","scope"],startBeforeEnd:!0,then:{required:["startDate","endDate"]},type:"object"}},{auth:"bearer",constant:"DELETE_POI",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/poi/id/{id}",pathParams:D.common104,request:D.common8},{auth:"bearer",constant:"DELETE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/events/id/{id}/",pathParams:D.common104,request:D.common8},{auth:"bearer",constant:"DELETE_ELEMENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/{type}/id/{id}",pathParams:{additionalProperties:!1,properties:{id:D.common11,type:D.common1},required:["type","id"],type:"object"},request:D.common8},{auth:"bearer",constant:"ADD_IMAGE_ELEMENT",contentType:"multipart/form-data",method:"POST",path:"/co2/document/upload-save/dir/communecter/folder/{folder}/ownerId/{ownerId}/input/qqfile/docType/image/contentKey/profil",pathParams:{additionalProperties:!1,properties:{folder:{enum:["badges","events"],type:"string"},ownerId:D.common11},required:["folder","ownerId"],type:"object"},request:{additionalProperties:!1,properties:{qqfile:D.common16,qqfilename:D.common1,qqtotalfilesize:D.common196,qquuid:D.common11},required:["qquuid","qqfilename","qqtotalfilesize","qqfile"],type:"object"}},{auth:"bearer",constant:"LINK_VALIDATE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/validate",request:{additionalProperties:!1,properties:{childId:D.common5,childType:D.common41,linkOption:{enum:["isInviting","toBeValidated","isAdminPending"],type:"string"},parentId:D.common11,parentType:D.common180},required:["childId","childType","parentType","parentId"],type:"object"}},{auth:"none",constant:"SEARCH_MEMBER_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/searchmemberautocomplete",request:{additionalProperties:!1,properties:{search:D.common1,searchMode:{default:"personOnly",enum:["personOnly","organizationOnly","mixte"],type:"string"}},required:["search","searchMode"],type:"object"}},{auth:"bearer",constant:"GET_NOTIFICATIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/getnotifications/type/{type}/id/{id}",pathParams:D.common197,request:{additionalProperties:!1,properties:{indexMin:D.common88},type:"object"}},{auth:"bearer",constant:"GET_NOTIFICATIONS_COUNT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/getnotifications/type/{type}/id/{id}",pathParams:D.common197,request:{additionalProperties:!1,properties:{refreshTimestamp:D.common196},type:"object"}},{auth:"bearer",constant:"NOTIFICATION_UPDATE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/update",request:{additionalProperties:!1,properties:{action:{enum:["seen","read"],type:"string"},all:D.common67},required:["action","all"],type:"object"}},{auth:"bearer",constant:"REMOVE_ALL_NOTIFICATIONS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/removeall"},{auth:"bearer",constant:"MARK_NOTIFICATION_AS_READ",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/notification/marknotificationasread",request:D.common104},{auth:"none",constant:"ACTIVITYPUB_SEARCH",contentType:"application/x-www-form-urlencoded",method:"GET",params:[D.common16],path:"/api/activitypub/search?address={address}",pathParams:{additionalProperties:!1,properties:{address:D.common1},required:["address"],type:"object"}},{auth:"bearer",constant:"ACTIVITYPUB_LINK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/activitypub/link",request:{additionalProperties:!1,properties:{action:{enum:["undo_follow","accept_invitation","reject_invitation","undo_accept","undo_request_follow","follow","remove_follow","accept_follower","reject_follower","remove_follower","remove_invitation"],type:"string"},actor:{additionalProperties:!1,properties:{id:D.common1,name:D.common1,type:{enum:["person"],type:"string"}},required:["id","type","name"],type:"object"},payload:D.common4},required:["action","payload","actor"],type:"object"}},{auth:"none",constant:"ACTIVITYPUB_GET_COMMUNITY",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/api/activitypub/getcommunity/userId/${userId}/type/${type}/actor/person",pathParams:{additionalProperties:!1,properties:{type:{enum:["follows","followers"],type:"string"},userId:D.common11},required:["userId","type"],type:"object"}},{auth:"none",constant:"GET_BADGE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/page/type/badges/id/{id}/json/true",pathParams:D.common104},{auth:"none",constant:"GET_EMETTEUR_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/app/badge/json/true"},{auth:"bearer",constant:"ADD_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/save",request:{additionalProperties:!1,properties:{collection:D.common200,criteria:{additionalProperties:!1,properties:{narrative:D.common1},required:["narrative"],type:"object"},description:D.common1,id:D.common11,isParcours:D.common105,issuer:{additionalProperties:!1,patternProperties:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:D.common1,type:{enum:["citoyens","organizations","projects"],type:"string"}},required:["type"],type:"object"}},type:"object"},key:D.common201,name:D.common1,parent:{additionalProperties:!1,patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:{name:D.common1,type:D.common200},required:["type"],type:"object"}},type:"object"},preferences:D.common183,public:D.common87,scope:D.common121,tags:D.common27},required:["id","collection","key","name","public","scope","issuer","criteria"],type:"object"}},{auth:"bearer",constant:"ASSIGN_BADGES",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/badges/assign",request:{additionalProperties:!1,properties:{award:{patternProperties:{"^[0-9a-f]{24}$":D.common44},type:"object"},badgeId:D.common11,collection:D.common200,evidences:{items:{additionalProperties:!1,properties:{narative:D.common1,url:D.common4},required:["narative"],type:"object"},type:"array"},key:D.common201,narative:D.common1,scope:D.common121},required:["key","collection","badgeId","award"],type:"object"}},{auth:"none",constant:"GET_EVENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/agenda",request:{additionalProperties:!1,properties:{count:D.common105,countType:{const:["events"],default:["events"],type:"array"},endDateUTC:D.common193,fediverse:D.common105,indexMin:D.common88,indexStep:{default:100,type:"integer"},locality:{patternProperties:{"^[^\\s]+$":{type:"object"}},type:"object"},name:D.common1,searchType:{const:["events"],default:["events"],items:D.common1,type:"array"},startDate:D.common66,startDateUTC:D.common193,type:D.common195},required:["searchType","indexMin","indexStep","startDate","startDateUTC","fediverse"],type:"object"}},{auth:"bearer",constant:"SHARE_EVENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:D.common106,if:D.common108,properties:{childId:D.common11,childType:D.common15,comment:D.common1,connectType:D.common110,parentId:D.common11,parentType:D.common192},required:["parentId","childId","childType","connectType","parentType"],then:D.common111,type:"object"}},{auth:"bearer",constant:"INVITE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/multiconnect",request:{additionalProperties:!1,else:D.common81,if:D.common83,properties:{listInvite:{additionalProperties:!1,minProperties:1,properties:{citoyens:D.common202,invites:{patternProperties:{"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$":{additionalProperties:!1,properties:{email:D.common2,isAdmin:D.common206,msg:D.common1,name:D.common1,roles:D.common27},required:["name","email"],type:"object"}},type:"object"},organizations:D.common202,projects:D.common202},type:"object"},parentId:D.common1,parentType:D.common15},required:["parentId","parentType","listInvite"],then:D.common85,type:"object"}},{auth:"bearer",constant:"FOLLOW",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/follow",request:{additionalProperties:!1,properties:{childId:D.common178,childType:D.common179,parentId:D.common11,parentType:D.common180},required:["childId","childType","parentType","parentId"],type:"object"}},{auth:"none",constant:"GET_COSTUM_JSON",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/cms/getcostumjson?slug={slug}",pathParams:{slug:D.common1}}];class TokenStorageStrategy{getAccessToken(){throw new Error("getAccessToken() doit être implémenté")}setAccessToken(e){throw new Error("setAccessToken() doit être implémenté")}getRefreshToken(){throw new Error("getRefreshToken() doit être implémenté")}setRefreshToken(e){throw new Error("setRefreshToken() doit être implémenté")}clear(){throw new Error("clear() doit être implémenté")}}class MemoryStorageStrategy extends TokenStorageStrategy{constructor(){super(),this._accessToken=null,this._refreshToken=null}getAccessToken(){return this._accessToken}setAccessToken(e){this._accessToken=e}getRefreshToken(){return this._refreshToken}setRefreshToken(e){this._refreshToken=e}clear(){this._accessToken=null,this._refreshToken=null}}class LocalStorageStrategy extends TokenStorageStrategy{constructor(e="cocolight"){super(),this.prefix=e}getAccessToken(){return"undefined"!=typeof localStorage?localStorage.getItem(`${this.prefix}_accessToken`):null}setAccessToken(e){"undefined"!=typeof localStorage&&localStorage.setItem(`${this.prefix}_accessToken`,e)}getRefreshToken(){return"undefined"!=typeof localStorage?localStorage.getItem(`${this.prefix}_refreshToken`):null}setRefreshToken(e){"undefined"!=typeof localStorage&&localStorage.setItem(`${this.prefix}_refreshToken`,e)}clear(){"undefined"!=typeof localStorage&&(localStorage.removeItem(`${this.prefix}_accessToken`),localStorage.removeItem(`${this.prefix}_refreshToken`))}}class MultiServerTokenStorageStrategy extends TokenStorageStrategy{constructor(){super(),this._currentBaseURL=null}use(e){if(!e)throw new Error("baseURL est requis");this._currentBaseURL=e.replace(/\/+$/,"")}_ensureContext(){if(!this._currentBaseURL)throw new Error("baseURL non défini. Appelez use(baseURL)")}getServers(){throw new Error("getServers() doit être implémenté")}exportAll(){throw new Error("exportAll() doit être implémenté")}}class MultiServerMemoryStorageStrategy extends MultiServerTokenStorageStrategy{constructor(){super(),this._storage=new Map}getAccessToken(){return this._ensureContext(),this._storage.get(this._currentBaseURL)?.accessToken||null}setAccessToken(e){this._ensureContext();const t=this._storage.get(this._currentBaseURL)||{};this._storage.set(this._currentBaseURL,{...t,accessToken:e})}getRefreshToken(){return this._ensureContext(),this._storage.get(this._currentBaseURL)?.refreshToken||null}setRefreshToken(e){this._ensureContext();const t=this._storage.get(this._currentBaseURL)||{};this._storage.set(this._currentBaseURL,{...t,refreshToken:e})}clear(){this._ensureContext(),this._storage.delete(this._currentBaseURL)}getServers(){return[...this._storage.keys()]}exportAll(){return Object.fromEntries(this._storage.entries())}}class MultiServerLocalStorageStrategy extends MultiServerTokenStorageStrategy{constructor(e="cocolight"){super(),this.prefix=e}_key(e){return`${this.prefix}_tokens_${e}`}_getData(){this._ensureContext();const e=localStorage.getItem(this._key(this._currentBaseURL));return e?JSON.parse(e):{}}_setData(e){localStorage.setItem(this._key(this._currentBaseURL),JSON.stringify(e))}getAccessToken(){return this._getData().accessToken||null}setAccessToken(e){const t=this._getData();t.accessToken=e,this._setData(t)}getRefreshToken(){return this._getData().refreshToken||null}setRefreshToken(e){const t=this._getData();t.refreshToken=e,this._setData(t)}clear(){localStorage.removeItem(this._key(this._currentBaseURL))}getServers(){return Object.keys(localStorage).filter((e=>e.startsWith(`${this.prefix}_tokens_`))).map((e=>e.replace(`${this.prefix}_tokens_`,"")))}exportAll(){const e={};for(const t of this.getServers()){const r=localStorage.getItem(this._key(t));r&&(e[t]=JSON.parse(r))}return e}}c.addType("oid",(e=>new C.ObjectID(e)));class ApiClient extends r{constructor({baseURL:e,accessToken:t,refreshToken:r,refreshUrl:o="/api/cocolight/refreshtoken",endpoints:c=L,timeout:p=3e4,debug:d=!1,maxRetries:m=0,circuitBreakerThreshold:u=5,circuitBreakerResetTime:h=6e4,fromJSONValue:y=!0,tokenStorageStrategy:f=null}={}){if(super(),!e)throw new ApiClientError('Le paramètre "baseURL" est obligatoire.',500);this.__entityTag="ApiClient",this._baseURL=e,this._refreshUrl=o,this._endpoints=c,this._debug=d;let g=null;if(this._offlineClientManager=null,this._fromJSONValue=y,Object.defineProperty(this,"userId",{get:()=>g,set:()=>{throw new Error("Modification directe de userId non autorisée.")},enumerable:!0}),this._setUserId=e=>{g=e,this._logger.debug(`[ApiClient] userId set: ${e}`)},this._ajv=new n({strict:!1,useDefaults:!0,allErrors:!0,verbose:!0}),i(this._ajv),this._ajv.addKeyword({keyword:"startBeforeEnd",type:"object",errors:!0,validate:this._startBeforeEndValidate}),this._logger=l({transport:{target:"pino-pretty",options:{colorize:!0}},level:d?"debug":"info"}),this._client=s.create({baseURL:e,timeout:p}),m>0&&(a(this._client,{retries:m,retryDelay:a.exponentialDelay,retryCondition:e=>a.isNetworkError(e)||a.isRetryableError(e),onRetry:(e,t,r)=>{this._logger.warn(`[Retry] Tentative #${e} pour ${r?.url}`),this.emit("retryAttempt",{retryCount:e,url:r?.url})}}),this._logger.info(`[ApiClient] Retry activé : ${m} max`)),this._breakerThreshold=u,this._breakerResetTime=h,this._breakerErrorCount=0,this._breakerOpen=!1,this._lastBreakerOpenTime=null,this._accessToken=null,this._refreshToken=null,f instanceof MultiServerTokenStorageStrategy&&f.use(this._baseURL),this._tokenStorage=f||new MemoryStorageStrategy,"function"!=typeof this._tokenStorage?.getAccessToken||"function"!=typeof this._tokenStorage?.setAccessToken||"function"!=typeof this._tokenStorage?.getRefreshToken||"function"!=typeof this._tokenStorage?.setRefreshToken||"function"!=typeof this._tokenStorage?.clear)throw new Error("[ApiClient] La stratégie de stockage des tokens n’est pas valide. Elle doit implémenter les méthodes requises.");r&&this.setRefreshToken(r),t&&this.setToken(t);const w=this._tokenStorage.getAccessToken();w&&this.setToken(w);const _=this._tokenStorage.getRefreshToken();_&&this.setRefreshToken(_),this._client.interceptors.response.use((e=>e),(async e=>{const t=e.config;if(t._retry)throw this._logger.error("[ApiClient] Requête déjà retentée, échec définitif."),e;if(e.response&&401===e.response.status&&this._refreshToken){t._retry=!0;try{this._logger.info("[ApiClient] Tentative de refresh du token...");if(await this._refreshAccessToken())return this._logger.info("[ApiClient] Token rafraîchi avec succès."),t.headers.Authorization="Bearer "+this.getToken(),this._logger.info("[ApiClient] Retente la requête originale avec le nouveau token."),this._client.request(t);throw this.resetSession(),new ApiClientError("Impossible de rafraîchir le token.",401)}catch(e){throw this.resetSession(),new ApiClientError("Erreur lors du rafraîchissement du token.",401,e)}}throw e}))}setToken(e){this._accessToken=e,this._tokenStorage.setAccessToken(e),this._client.defaults.headers.common.Authorization="Bearer "+e;const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait et défini : ${t}`)),this._logger.debug(`[ApiClient] setToken: ${e}`)}getToken(){return this._accessToken}setRefreshToken(e){if(this._refreshToken=e,this._tokenStorage.setRefreshToken(e),null===this.userId){const t=this._getIdFromToken(e);t&&(this._setUserId(t),this._logger.debug(`[ApiClient] userId extrait depuis refreshToken : ${t}`))}this._logger.debug(`[ApiClient] setRefreshToken: ${e}`)}getRefreshToken(){return this._refreshToken}get isConnected(){return!!this._accessToken}_getIdFromToken(e){if(!e)return null;try{const t=p(e);return this._logger.debug("[ApiClient] Payload décodé :",t),t.id||t.userId||null}catch(e){return this._logger.error("[ApiClient] Erreur lors du décodage du token :",e),null}}async _refreshAccessToken(){if(!this._refreshToken)return!1;const e=s.create({baseURL:this._baseURL,timeout:1e4,headers:{"Content-Type":"application/json"}});try{const t=await e.post(this._refreshUrl,{refreshToken:this._refreshToken});return!(!t.data||!t.data.token)&&(this.setToken(t.data.token),t.data.refreshToken&&this.setRefreshToken(t.data.refreshToken),this.emit("refreshSuccess",t.data),!0)}catch(e){return this.emit("refreshFailed",{error:e.message}),this.resetSession(),this._logger.error(`[ApiClient] Refresh Error : ${e.message}`),!1}}_checkCircuitBreaker(){if(!this._breakerOpen)return!0;return Date.now()-this._lastBreakerOpenTime>this._breakerResetTime&&(this._breakerOpen=!1,this._breakerErrorCount=0,this._logger.warn("[ApiClient] Circuit breaker réinitialisé"),this.emit("circuitBreakerReset"),!0)}_updateCircuitBreakerError(){this._breakerErrorCount+=1,this._logger.warn(`[ApiClient] Erreur #${this._breakerErrorCount} sur ${this._breakerThreshold}`),this._breakerErrorCount>=this._breakerThreshold&&(this._breakerOpen=!0,this._lastBreakerOpenTime=Date.now(),this._logger.error("[ApiClient] Circuit breaker ACTIVÉ - L'API est considérée indisponible"),this.emit("circuitBreakerOpen",{timestamp:this._lastBreakerOpenTime}))}_resetCircuitBreakerSuccess(){this._breakerErrorCount=0,this._breakerOpen&&(this._breakerOpen=!1,this._logger.warn("[ApiClient] Circuit breaker refermé suite à un succès"))}static stripNullsInPlace(e){if(e&&"object"==typeof e&&e.value&&"function"==typeof e.value.pipe)return e;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)null===e[t]||void 0===e[t]?e.splice(t,1):"object"==typeof e[t]&&ApiClient.stripNullsInPlace(e[t]);else if(e&&"object"==typeof e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(null===e[t]||void 0===e[t]?delete e[t]:"object"==typeof e[t]&&ApiClient.stripNullsInPlace(e[t]));return e}_resolveSpecialValuesInPlace(e,t={}){const r={userId:()=>this.userId,accessToken:()=>this._accessToken,refreshToken:()=>this._refreshToken,baseURL:()=>this._baseURL,pathParams:e=>{const r=this._getValueByPath(t,e);return null!=r?r:void 0}},o=/@(?:\{([^}]+)\}|([\w.]+))/g,n=e=>"string"!=typeof e?e:e.replace(o,((t,o,n)=>{if(o){if(o.startsWith("pathParams.")){const e=o.substring(11),t=r.pathParams(e);return null!=t?t:`@{${o}}`}{const e=r[o];if("function"==typeof e){const t=e();return null!=t?t:`@{${o}}`}return`@{${o}}`}}if(n){if(n.startsWith("pathParams.")){const e=n.match(/^pathParams\.([^.]+)(.*)$/);if(e){const t=e[1],o=e[2],i=r.pathParams(t);return null!=i?i+o:`@${n}`}return`@${n}`}{const e=r[n];if("function"==typeof e){const t=e();return null!=t?t:`@${n}`}return`@${n}`}}return e})),i=e=>{if((e=>e&&"object"==typeof e&&("function"==typeof e.pipe||"undefined"!=typeof Buffer&&e instanceof Buffer))(e))return e;if(Array.isArray(e))return e.map(i);if((e=>"[object Object]"===Object.prototype.toString.call(e))(e)){const t={};for(const[r,o]of Object.entries(e)){t[n(r)]=i(o)}return t}return"string"==typeof e?n(e):e};return i(e)}_cleanSchemaLeftoverAlias(e){const t=/@\w+/;if(Array.isArray(e))return e.map((e=>this._cleanSchemaLeftoverAlias(e)));if(e&&"object"==typeof e){const r={};for(const o of Object.keys(e)){const n=e[o];if(!t.test(o)){if("default"===o){if("string"==typeof n&&t.test(n))continue;if(n&&"object"==typeof n){const e=this._cleanSchemaLeftoverAlias(n);Object.keys(e).length>0&&(r[o]=e);continue}}"string"==typeof n&&t.test(n)||(r[o]=this._cleanSchemaLeftoverAlias(n))}}return r}return e}async safeCall(e,...t){try{return await e(...t)}catch(e){throw this._logger.error(`[ApiClient.safeCall] Erreur: ${e.message}`),e}}async callEndpoint(e,t={},r=!0,o=!0){const n=this._endpoints.find((t=>t.constant===e));if(!n)throw new ApiClientError(`Endpoint introuvable : ${e}`,404);const{path:i,method:s,contentType:a,auth:c,pathParams:p,request:l,responses:d}=n,m=(s||"GET").toLowerCase(),u=a||"application/json",h={"Content-Type":u};if(this._accessToken)"bearer"===c?h.Authorization=`Bearer ${this._accessToken}`:c&&"none"!==c||h.Authorization||(h.Authorization=`Bearer ${this._accessToken}`);else if("bearer"===c)throw new ApiClientError(`Token requis pour l'endpoint sécurisé : ${e}`,401);let y,f=i,g={};if(p){let r=p;"none"===c&&null===this.userId&&(r=this._cleanSchemaLeftoverAlias(p));const o=t.pathParams||{},n=this._ajv.compile(r);if(!n(o)){const t=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"pathParams",errors:n.errors}),new ApiValidationError(`callEndpoint: ${e} - Path parameter validation failed.`,400,t,n.errors)}g=this._resolveSpecialValuesInPlace(o),f=f.replace(/\{(\w+)\}/g,((e,t)=>{const r=g[t];if(void 0!==r)return encodeURIComponent(r);throw new ApiClientError(`Path param manquant ou non résolu : {${t}}`,400)}))}if(l){let r=l;"none"===c&&null===this.userId&&(r=this._cleanSchemaLeftoverAlias(l));const o={...t};delete o.pathParams;const n=ApiClient.stripNullsInPlace(o),i=this._ajv.compile(r);if(!i(n)){const t=i.errors?this._ajvErrorHuman(i.errors):[];throw this.emit("validationError",{stage:"request",errors:i.errors}),new ApiValidationError(`callEndpoint: ${e} - Request validation failed.`,400,t,i.errors)}t=this._resolveSpecialValuesInPlace(n,g)}if(this._offlineClientManager?.isOffline()){if("function"==typeof this._offlineClientManager._enqueueOfflineAction)return this._logger.warn(`[ApiClient] Mode dégradé : mise en file de ${e}`),await this._offlineClientManager._enqueueOfflineAction({constant:e,data:t,options:{transformResponseData:r,validateResponseSchema:o}}),this._logger.info(`[ApiClient] Requête ${e} mise en file (offline mode)`),this.emit("queuedOffline",{constant:e,reason:"offlineMode",data:t}),{data:null,offline:!0};throw this._logger.warn("[ApiClient] Mode dégradé actif mais offlineManager non initialisé correctement"),new ApiClientError("Mode hors-ligne actif, mais gestionnaire offline non disponible.",503)}if(!this._checkCircuitBreaker()){if(!1===this._offlineClientManager?.isOffline?.()&&"function"==typeof this._offlineClientManager._enqueueOfflineAction)return this._logger.warn(`[ApiClient] Circuit breaker actif → mise en file de ${e}`),await this._offlineClientManager._enqueueOfflineAction({constant:e,data:t,options:{transformResponseData:r,validateResponseSchema:o}}),this._logger.info(`[ApiClient] Requête ${e} mise en file (circuit breaker)`),this.emit("queuedOffline",{constant:e,reason:"circuitBreaker",data:t}),{data:null,breaker:!0};throw new CircuitBreakerError("Le circuit breaker est activé, impossible d'appeler l'API")}"application/json"===u||"multipart/form-data"===u?y=t:"application/x-www-form-urlencoded"===u&&(y=ApiClient.toURLSearchParams(t)),this._logger.debug(`[ApiClient] callEndpoint: ${e} -> ${f}, method=${m}`);try{const e=await this._client.request({url:f,method:m,headers:h,["get"===m?"params":"data"]:y});if(o){const t=e.status.toString(),r=d?.[t];if(r){const o=this._ajv.compile(r);if(!o(e.data)){const e=this._ajvErrorHuman(o.errors);throw this.emit("validationError",{stage:"response",errors:o.errors}),new ApiValidationError("Response validation failed.",t,e,o.errors)}}}return this._resetCircuitBreakerSuccess(),"function"==typeof r?e.data=r(e.data):!0===r&&(e.data=this._transformData(e.data)),Array.isArray(n.postActions)&&n.postActions.forEach((t=>{const r=t.path?this._getValueByPath(e.data,t.path):null;switch(t.type){case"setToken":this.setToken(r);break;case"setRefreshToken":this.setRefreshToken(r);break;case"resetSession":this.resetSession();break;case"emitEvent":t.event&&(this.emit(t.event,r),this._logger.debug(`[ApiClient] Event émis : ${t.event}`,r));break;case"callMethod":"function"==typeof this[t.method]?(this[t.method](),this._logger.debug(`[ApiClient] Méthode appelée : ${t.method}`)):this._logger.warn(`[ApiClient] Méthode inconnue : ${t.method}`);break;default:this._logger.warn(`[ApiClient] Action inconnue : ${t.type}`)}})),e}catch(t){throw this._updateCircuitBreakerError(),this._logger.error(`[ApiClient] Erreur lors de l'appel de ${e}: ${t.message}`),t instanceof ApiValidationError?t:new ApiClientError(`Erreur lors de l'appel de l'API : ${t.message}`,t.response?t.response.status:500,t.response?t.response.data:null)}}_ajvErrorHuman(e){try{const t=new o(e);return t.errors.map((({message:e})=>e))}catch(t){return this._logger.error("[ApiClient] _ajvErrorHuman",t),e.map((({message:e})=>e))}}checkAndThrowApiResponseError(e){const t=e.data;if(!t||"object"!=typeof t)return e;if("boolean"==typeof t.result&&!1===t.result)throw new ApiResponseError(t.msg||"Erreur inconnue",e.status,t);if(t.resultErrors&&"object"==typeof t.resultErrors&&"boolean"==typeof t.resultErrors.result&&!1===t.resultErrors.result)throw new ApiResponseError(t.resultErrors.msg||"Erreur inconnue",e.status,t);return e}resetSession(){this.setToken(null),this.setRefreshToken(null),this._setUserId(null),this._tokenStorage.clear(),delete this._client.defaults.headers.common.Authorization,this._logger.info("[ApiClient] Session utilisateur réinitialisée."),this.emit("sessionReset")}_getValueByPath(e,t){if(!t)return;return t.split(".").reduce(((e,t)=>e&&e[t]),e)}static toURLSearchParams(e,t={}){return this._buildParams(e,new URLSearchParams,t)}static _buildParams(e,t,r={}){if("object"!=typeof e||null===e)throw new TypeError("La donnée doit être un objet non nul.");const{dots:o=!1,indexes:n=!1,metaTokens:i=!0}=r,s=[];function a(e){return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)}function c(e){return e.endsWith("[]")?e.slice(0,-2):e}function p(e,t,r=!1){return e?e.concat(t).map(((e,t)=>(e=c(e),!r&&t?`[${e}]`:e))).join(r?".":""):t}function l(e){return null==e?"":e instanceof Date?e.toISOString():(e instanceof Blob||e instanceof File||e instanceof ArrayBuffer||ArrayBuffer.isView(e),e)}return function e(r,d=[]){null==r||s.includes(r)||(s.push(r),Object.entries(r).forEach((([r,s])=>{void 0!==s&&function(e,r,s){if(e&&"object"==typeof e){if(r.endsWith("{}"))return r=i?r:r.slice(0,-2),t.append(p(s,r,o),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(a)||r.endsWith("[]"))return r=c(r),e.forEach(((e,i)=>{if(null!=e){const a=n?p(s.concat(r),i,o):`${p(s,r,o)}[]`;t.append(a,l(e))}})),!1}return!!a(e)||(t.append(p(s,r,o),l(e)),!1)}(s,r.trim(),d)&&e(s,d.concat(c(r)))})),s.pop())}(e),t}_transformData(e){if(e&&"object"==typeof e)if(e.resultGoods?.msg)e=this._normalizeJsonData({msg:e.resultGoods.msg,...e});else if(e.resultErrors?.msg)e=this._normalizeJsonData({msg:e.resultErrors.msg,...e});else if(e.results&&"object"==typeof e.results&&!Array.isArray(e.results))e.results=Object.keys(e.results).map((t=>this._normalizeJsonData({id:t,...e.results[t]})));else if(Array.isArray(e.results))e.results=e.results.map((e=>this._normalizeJsonData(e)));else if(e.news&&Array.isArray(e.news)&&0===e.news.length)e=e.news;else if(e.news&&"object"==typeof e.news&&!Array.isArray(e.news))e=Object.keys(e.news).map((t=>this._normalizeJsonData({id:t,...e.news[t]})));else if(e.notif&&"object"==typeof e.notif&&!Array.isArray(e.notif))e.notif=Object.keys(e.notif).map((t=>this._normalizeJsonData({id:t,...e.notif[t]})));else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens)&&e.organizations&&"object"==typeof e.organizations&&!Array.isArray(e.organizations))e=[...Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]}))),...Object.keys(e.organizations).map((t=>this._normalizeJsonData({id:t,...e.organizations[t]})))];else if(e.citoyens&&"object"==typeof e.citoyens&&!Array.isArray(e.citoyens))e=Object.keys(e.citoyens).map((t=>this._normalizeJsonData({id:t,...e.citoyens[t]})));else if(e.cities&&"object"==typeof e.cities&&!Array.isArray(e.cities))e=Object.keys(e.cities).map((t=>this._normalizeJsonData({id:t,...e.cities[t]})));else if(e.cities&&Array.isArray(e.cities)&&0===e.cities.length)e=e.cities;else if(e.newComment&&"object"==typeof e.newComment)e.newComment=this._normalizeJsonData({...e.newComment});else if(Array.isArray(e))e=e.map((e=>this._normalizeJsonData(e)));else if(e.map&&"object"==typeof e.map)e.map=this._normalizeJsonData(e.map);else if(e.object&&"object"==typeof e.object)e.object=this._normalizeJsonData(e.object);else if("object"==typeof e&&Object.keys(e).length>0){const t=Object.keys(e).every((e=>/^[0-9a-fA-F]{24}$/.test(e)));e=t?Object.keys(e).map((t=>({id:t,...this._normalizeJsonData(e[t])}))):this._normalizeJsonData(e)}return e}_normalizeJsonData(e){if(!e||"object"!=typeof e)return e;if(e=this._normalizeRecursively(e),e?.mediaImg?.images&&Array.isArray(e.mediaImg.images)&&e.mediaImg.images.length>0&&(e.mediaImg.countImages=e.mediaImg.images.length),e?.mediaFile?.files&&Array.isArray(e.mediaFile.files)&&e.mediaFile.files.length>0&&(e.mediaFile.countFiles=e.mediaFile.files.length),e?.src?.changes&&"object"==typeof e.src.changes&&Object.keys(e.src.changes).length>0&&Object.keys(e.src.changes).forEach((t=>{e.src.changes[t]&&(e.src.changes[t]=this._ensureFullURL(e.src.changes[t]))})),e?.openingHours&&Array.isArray(e.openingHours)&&e.openingHours.length>0&&(e.openingHours=e.openingHours.filter((e=>e.dayOfWeek&&e.hours&&e.hours[0]&&e.hours[0].opens))),e.replies&&"object"==typeof e.replies&&Object.keys(e.replies).length>0&&(e.replies=Object.keys(e.replies).map((t=>this._normalizeJsonData({id:t,...e.replies[t]})))),e?.author&&"object"==typeof e.author&&Object.keys(e.author).length>0&&!("profilThumbImageUrl"in e.author)){const t=Object.keys(e.author)[0];e.author={...e.author[t]}}return e?.timeAgo&&delete e.timeAgo,this._fromJSONValue?c.fromJSONValue(e):e}_ensureFullURL(e){if(!e)return e;if(!(e=e.trim())||/^https?:\/\//i.test(e))return e;let t="/";return t=this._baseURL.endsWith("/")&&e.startsWith("/")||this._baseURL.endsWith("/")||e.startsWith("/")?"":"/",`${this._baseURL}${t}${e}`}_normalizeString(e){return"true"===e||"false"!==e&&e}_normalizeId(e){return e._id&&e._id.$id&&/^[0-9a-fA-F]{24}$/.test(e._id.$id)&&(e.id=e._id.$id,e._id={$type:"oid",$value:e._id.$id}),e.id&&e.id.$id&&/^[0-9a-fA-F]{24}$/.test(e.id.$id)&&(e._id={$type:"oid",$value:e.id.$id},e.id=e.id.$id),e}_normalizeDate(e){return e&&"object"==typeof e&&"number"==typeof e.sec?{$date:1e3*e.sec}:"number"==typeof e?{$date:1e3*e}:e}_normalizeImage(e){return"string"==typeof e&&""!==e.trim()?this._ensureFullURL(e):e}_imageFields=["profilImageUrl","profilThumbImageUrl","profilMediumImageUrl","profilMarkerImageUrl","profilBannerUrl","profilRealBannerUrl","imagePath","imageThumbPath","docPath"];_dateFields=["modified","created","updated","birthDate","lastLoginDate","startDate","endDate","date","issuedOn"];_normalizeRecursively(e){if("string"==typeof e)return this._normalizeString(e);if(Array.isArray(e))return e.map((e=>this._normalizeRecursively(e)));if(null!==e&&"object"==typeof e){const t={};return Object.keys(e).forEach((r=>{let o=this._normalizeRecursively(e[r]);this._dateFields.includes(r)&&(o=this._normalizeDate(o)),this._imageFields.includes(r)&&(o=this._normalizeImage(o)),"content"===r&&o&&"object"==typeof o&&o.image&&(o.image=this._normalizeImage(o.image)),t[r]=o})),this._normalizeId(t)}return e}_startBeforeEndValidate=(e,t)=>{if(!t.startDate||!t.endDate)return!0;const r=new Date(t.startDate)<new Date(t.endDate);return r||(this._startBeforeEndValidate.errors=[{instancePath:"",schemaPath:"#/startBeforeEnd",keyword:"startBeforeEnd",params:{},message:"startDate must be before endDate"}]),r};getRequestSchema(e){const t=this._endpoints.find((t=>t.constant===e));return t?.request||null}getPathSchema(e){return this._endpoints.find((t=>t.constant===e))?.pathParams||null}onEvent(e={}){const t=["retryAttempt","queuedOffline","circuitBreakerOpen","circuitBreakerReset","refreshSuccess","refreshFailed","sessionReset","validationError","offlineModeChanged","userLoggedIn"];for(const r of t)"function"==typeof e[r]&&this.on(r,e[r])}getDeclaredEvents(){const e=new Set;for(const t of this._endpoints)if(Array.isArray(t.postActions))for(const r of t.postActions)"emitEvent"===r.type&&r.event&&e.add(r.event);return Array.from(e)}}class UserApi{constructor(e){this.client=e instanceof ApiClient?e:new ApiClient(e),this.loggedUser=null}get isConnected(){return this.client.isConnected}get userId(){return this.client.userId}async login(e,t){return this.client.safeCall((async()=>{const r=await this.client.callEndpoint("AUTHENTICATE_URL",{email:e,password:t});return this.loggedUser=new User(this.client,r.data.user,{EndpointApi:EndpointApi,Organization:Organization,Project:Project,Event:Event,Poi:Poi,Badge:Badge,News:News}),this.loggedUser}))}async meIsconnected(){if(!this.client.isConnected||!this.client.userId)throw new ApiError("User not connected",401);return this.client._logger.info("UserApi","meIsconnected",this.client.userId),this.loggedUser=new User(this.client,{id:this.client.userId},{EndpointApi:EndpointApi,Organization:Organization,Project:Project,Event:Event,Poi:Poi,Badge:Badge,News:News}),this.loggedUser}async register({name:e,username:t,email:r,pwd:o}={}){return this.client.safeCall((async()=>{const n=await this.client.callEndpoint("PERSON_REGISTER",{name:e,username:t,email:r,pwd:o});if(!1===n?.data?.result)throw new ApiResponseError(n.data.msg,n.status,n.data);return n.data}))}async recoverPassword(e){return this.client.safeCall((async()=>{const t=await this.client.callEndpoint("PASSWORD_RECOVERY",{email:e});if(!1===t?.data?.result)throw new ApiResponseError(t.data.msg,t.status,t.data);return t.data}))}}class Api{static async userLogin(e,t,r){const o=Api.userApi(r);return await Api.userApiLogin(o,e,t)}static userApi(e){try{return new UserApi(e)}catch(e){throw console.error("[Api.userApi] Erreur lors de la création d'un objet utilisateur :",e.message),e}}static async userApiLogin(e,t,r){try{if(!e)throw new ApiError("userApi is not defined");if(!e.client)throw new ApiError("userApi.client is not defined");if(e.client.isConnected){const t=await e.meIsconnected();return new Api(t,e.client)}{if(!t||!r)throw new ApiError("email and password are required");const o=await e.login(t,r);return new Api(o,e.client)}}catch(e){if(e instanceof ApiClientError&&e?.details?.error)throw new ApiAuthenticationError(e.details.error,e.status,e.details);throw e}}constructor(e,t){this._loggedUser=e,this._client=t}async me(){if(!this._loggedUser)throw new ApiAuthenticationError("Accès refusé : utilisateur non authentifié.");return await this._loggedUser.get(),this._loggedUser}async user(e){try{if(e.id||e.slug){const t=new User(this._client,e,{EndpointApi:EndpointApi,Organization:Organization,Project:Project,Event:Event,Poi:Poi,Badge:Badge,News:News});return await t.get(),t}return new User(this._client,e,{EndpointApi:EndpointApi,Organization:Organization,Project:Project,Event:Event,Poi:Poi,Badge:Badge,News:News})}catch(e){throw console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :",e.message),e}}async organization(e){try{const t=new Organization(this._client,e,{EndpointApi:EndpointApi,User:User,Project:Project,Event:Event,Poi:Poi,Badge:Badge,News:News});if(!e.id&&!e.slug)throw new Error("Vous devez fournir un id ou un slug pour créer une instance Organization.");return await t.get(),t}catch(e){throw console.error("[Api.organization] Erreur lors de la création d'un objet organisation :",e.message),e}}async project(e){try{const t=new Project(this._client,e,{EndpointApi:EndpointApi,User:User,Event:Event,Poi:Poi,Badge:Badge,News:News});if(!e.id&&!e.slug)throw new Error("Vous devez fournir un id ou un slug pour créer une instance Project.");return await t.get(),t}catch(e){throw console.error("[Api.project] Erreur lors de la création d'un objet projet :",e.message),e}}get client(){return this._client}get endpointApi(){return new EndpointApi(this._client)}logout(){this.loggedUser=null,this._client.resetSession(),this._client._logger.info("UserApi: User logged out")}}class OfflineQueueStorageStrategy{async loadQueue(){throw new Error("loadQueue() doit être implémenté")}async saveQueue(e){throw new Error("saveQueue(queue) doit être implémenté")}}class MemoryOfflineStorage extends OfflineQueueStorageStrategy{constructor(){super(),this._queue=[]}async loadQueue(){return this._queue}async saveQueue(e){this._queue=[...e]}}class LocalStorageOfflineStorage extends OfflineQueueStorageStrategy{constructor(e="cocolight-api-offline-queue"){super(),this.key=e}async loadQueue(){try{const e=localStorage.getItem(this.key);return e?JSON.parse(e):[]}catch{return[]}}async saveQueue(e){try{localStorage.setItem(this.key,JSON.stringify(e))}catch(e){console.warn("[Offline] Échec du stockage localStorage",e)}}}class OfflineClientManager{constructor(e){if(!(e&&e instanceof ApiClient))throw new Error("[OfflineClientManager] apiClient doit être une instance de ApiClient");this._clients=new Map,this._client=e}static async attachTo(e,t={}){e._offlineClientManager=new OfflineClientManager(e);const r=await async function(e="auto"){if("memory"===e)return new MemoryOfflineStorage;if("localStorage"===e){if("undefined"!=typeof window&&window.localStorage)return new LocalStorageOfflineStorage;throw new Error("localStorage is not available in this environment.")}if("file"===e){if("undefined"!=typeof window&&window.localStorage)throw new Error("file storage is not available in this environment.");const{FileOfflineStorage:e}=await Promise.resolve().then((function(){return q}));return new e}if("auto"===e){if("undefined"!=typeof window&&window.localStorage)return new LocalStorageOfflineStorage;{const{FileOfflineStorage:e}=await Promise.resolve().then((function(){return q}));return new e}}}(t?.offlineStorageStrategy||"auto");await e._offlineClientManager._initOfflineQueue(r),t?.disableOfflineMonitoring||e._offlineClientManager.startOfflineMonitoring(t)}async getClient(e){const t=`${e.baseURL}|${e.accessToken}`;if(this._clients.has(t))return this._clients.get(t);const r=new ApiClient({baseURL:e.baseURL,accessToken:e.accessToken,refreshToken:e.refreshToken,debug:this._client._debug});return this._clients.set(t,r),r}async replayAction(e){const t=await this.getClient(e.meta);try{const r=await t.callEndpoint(e.constant,e.data,e.options?.transformResponseData??!0,e.options?.validateResponseSchema??!0);return this._client._logger.info(`[OfflineReplay] Succès ${e.constant} sur ${e.meta.baseURL}`),r}catch(t){throw this._client._logger.error(`[OfflineReplay] Échec ${e.constant}`,t.message),t}}startOfflineMonitoring({interval:e=3e4,disableOfflineMonitoring:t=!1}={}){t||this._monitoringStarted||(this._monitoringStarted=!0,this._offlineMode="undefined"!=typeof window&&"undefined"!=typeof navigator&&!navigator.onLine,"undefined"!=typeof window&&(window.addEventListener("online",(()=>this.setOfflineMode(!1))),window.addEventListener("offline",(()=>this.setOfflineMode(!0)))),this._pingInterval=setInterval((async()=>{const e=this._offlineMode;try{await this._client._client.head("/api/cocolight/infoserver",{timeout:5e3}),e&&this.setOfflineMode(!1)}catch(e){this._client._logger.error("[OfflineMonitor] ping() échoué → passage en offline"),this.setOfflineMode(!0)}}),e))}setOfflineMode(e){this._offlineMode!==e&&(this._offlineMode=e,"function"==typeof this._emit&&this._client.emit("offlineModeChanged",e),this._client._logger.info(`[ApiClient] Mode offline : ${e} (set depuis monitoring)`),e||"function"!=typeof this._replayOfflineQueue||this._replayOfflineQueue())}isOffline(){return!!this._offlineMode}async _enqueueOfflineAction({constant:e,data:t,options:r={}}){const o=this._client.getToken()||this._client.getRefreshToken(),n=this._client._endpoints.find((t=>t.constant===e));if("required"===(n?.authPolicy||("none"===n?.auth?"none":"required"))&&!o)return void this._client._logger.warn(`[Offline] Action ignorée : token requis mais absent (${e})`);const i={constant:e,data:t,options:r,meta:{baseURL:this._client._baseURL,accessToken:this._client.getToken(),refreshToken:this._client.getRefreshToken(),timestamp:Date.now()}};this._offlineQueue.push(i),await this._offlineQueueStorage.saveQueue(this._offlineQueue),this._client._logger.info(`[Offline] Action mise en file : ${e}`)}async _replayOfflineQueue(){const e=[...this._offlineQueue];this._offlineQueue=[],await this._offlineQueueStorage.saveQueue([]);for(const t of e){const e=this._client._endpoints.find((e=>e.constant===t.constant)),r=e?.authPolicy||("none"===e?.auth?"none":"required"),o=t.meta.accessToken||t.meta.refreshToken;if("required"!==r||o)try{await this.replayAction(t)}catch(e){this._client._logger.error("[Offline] Relecture échouée :",e.message),this._offlineQueue.push(t)}else this._client._logger.warn(`[Offline] Rejetée : token requis manquant (${t.constant})`)}await this._offlineQueueStorage.saveQueue(this._offlineQueue)}async _initOfflineQueue(e){this._offlineQueueStorage=e,this._offlineQueue=await e.loadQueue()}}var x={ApiClient:ApiClient,Api:Api,error:h,reactive:j,...j,tokenStorageStrategy:{createDefaultTokenStorageStrategy:async function(e="auto"){if("memory"===e)return new MemoryStorageStrategy;if("localStorage"===e){if("undefined"!=typeof window&&window.localStorage)return new LocalStorageStrategy;throw new Error("localStorage is not available in this environment.")}if("file"===e){if("undefined"!=typeof window&&window.localStorage)throw new Error("file storage is not available in this environment.");const{FileStorageStrategy:e}=await Promise.resolve().then((function(){return M}));return new e}if("auto"===e){if("undefined"!=typeof window&&window.localStorage)return new LocalStorageStrategy;{const{FileStorageStrategy:e}=await Promise.resolve().then((function(){return M}));return new e}}},TokenStorageStrategy:TokenStorageStrategy,createDefaultMultiServerTokenStorageStrategy:async function(e="auto"){if("memory"===e)return new MultiServerMemoryStorageStrategy;if("localStorage"===e){if("undefined"!=typeof window&&window.localStorage)return new MultiServerLocalStorageStrategy;throw new Error("localStorage n’est pas disponible dans cet environnement.")}if("file"===e){if("undefined"!=typeof window&&window.localStorage)throw new Error("Le stockage fichier n’est pas disponible côté navigateur.");const{MultiServerFileStorageStrategy:e}=await Promise.resolve().then((function(){return $}));return new e}if("undefined"!=typeof window&&window.localStorage)return new MultiServerLocalStorageStrategy;{const{MultiServerFileStorageStrategy:e}=await Promise.resolve().then((function(){return $}));return new e}},MultiServerTokenStorageStrategy:MultiServerTokenStorageStrategy},OfflineClientManager:OfflineClientManager};var N=Object.freeze({__proto__:null,bufferToReadable:async function(e){const{Readable:t}=await import("stream");return t.from(e)},createPassThrough:async function(){const{PassThrough:e}=await import("stream");return new e}});var $=Object.freeze({__proto__:null,MultiServerFileStorageStrategy:class MultiServerFileStorageStrategy extends MultiServerTokenStorageStrategy{constructor(e="tokens.json",t=u.join(m.homedir(),".config","cocolight")){super(),this.filePath=u.join(t,e),d.existsSync(t)||d.mkdirSync(t,{recursive:!0})}_readFile(){if(!d.existsSync(this.filePath))return{};try{return JSON.parse(d.readFileSync(this.filePath,"utf8"))}catch{return{}}}_writeFile(e){d.writeFileSync(this.filePath,JSON.stringify(e,null,2),"utf8")}getAccessToken(){return this._ensureContext(),this._readFile()[this._currentBaseURL]?.accessToken||null}setAccessToken(e){this._ensureContext();const t=this._readFile();t[this._currentBaseURL]={...t[this._currentBaseURL]||{},accessToken:e},this._writeFile(t)}getRefreshToken(){return this._ensureContext(),this._readFile()[this._currentBaseURL]?.refreshToken||null}setRefreshToken(e){this._ensureContext();const t=this._readFile();t[this._currentBaseURL]={...t[this._currentBaseURL]||{},refreshToken:e},this._writeFile(t)}clear(){this._ensureContext();const e=this._readFile();delete e[this._currentBaseURL],this._writeFile(e)}getServers(){return Object.keys(this._readFile())}exportAll(){return this._readFile()}}});var M=Object.freeze({__proto__:null,FileStorageStrategy:class FileStorageStrategy extends TokenStorageStrategy{constructor(e="tokens.json",t=u.join(m.homedir(),".config","cocolight")){super(),this.dir=t,this.filePath=u.join(t,e),this._ensureDirectoryExists()}_ensureDirectoryExists(){d.existsSync(this.dir)||d.mkdirSync(this.dir,{recursive:!0})}_readFile(){if(!d.existsSync(this.filePath))return{};try{return JSON.parse(d.readFileSync(this.filePath,"utf8"))}catch(e){return console.error("Error reading token file:",e),{}}}_writeFile(e){d.writeFileSync(this.filePath,JSON.stringify(e,null,2),"utf8")}getAccessToken(){return this._readFile().accessToken||null}setAccessToken(e){const t=this._readFile();t.accessToken=e,this._writeFile(t)}getRefreshToken(){return this._readFile().refreshToken||null}setRefreshToken(e){const t=this._readFile();t.refreshToken=e,this._writeFile(t)}clear(){this._writeFile({})}}});var q=Object.freeze({__proto__:null,FileOfflineStorage:class FileOfflineStorage extends OfflineQueueStorageStrategy{constructor(e="offline-queue.json",t=u.join(m.homedir(),".config","cocolight")){super(),this.dir=t,this.filePath=u.join(t,e),this._ensureDirectoryExists()}_ensureDirectoryExists(){d.existsSync(this.dir)||d.mkdirSync(this.dir,{recursive:!0})}_readFile(){if(!d.existsSync(this.filePath))return[];try{return JSON.parse(d.readFileSync(this.filePath,"utf8"))}catch(e){return console.error("Erreur lecture offline queue :",e),[]}}_writeFile(e){try{d.writeFileSync(this.filePath,JSON.stringify(e,null,2),"utf8")}catch(e){console.warn("[OfflineQueue] Erreur d'écriture:",e)}}async loadQueue(){return this._readFile()}async saveQueue(e){this._writeFile(e)}}});export{x as default};
2
2
  //# sourceMappingURL=cocolight-api-client.vite.mjs.js.map