@communecter/cocolight-api-client 1.0.8 → 1.0.9
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.
- package/dist/22.cocolight-api-client.mjs.js +1 -0
- package/dist/320.cocolight-api-client.browser.js +1 -0
- package/dist/931.cocolight-api-client.browser.js +1 -0
- package/dist/931.cocolight-api-client.cjs +1 -0
- package/dist/cocolight-api-client.browser.js +3 -3
- package/dist/cocolight-api-client.cjs +1 -2
- package/dist/cocolight-api-client.mjs.js +1 -2
- package/package.json +4 -2
- package/src/Api.js +8 -3
- package/src/ApiClient.js +46 -10
- package/src/api/EndpointApi.js +1534 -0
- package/src/api/News.js +286 -0
- package/src/api/Organization.js +135 -33
- package/src/api/Project.js +136 -33
- package/src/api/User.js +52 -48
- package/src/api/UserApi.js +2 -1
- package/src/endpoints.module.js +2 -2
- package/src/mixin/EntityMixin.js +48 -0
- package/src/mixin/NewsMixin.js +8 -0
- package/src/mixin/UserMixin.js +8 -0
- package/src/mixin/UtilMixin.js +246 -0
- package/src/utils/stream-utils.node.js +10 -0
- package/dist/cocolight-api-client.cjs.LICENSE.txt +0 -1
- package/dist/cocolight-api-client.mjs.js.LICENSE.txt +0 -1
- package/src/api/EntityMixin.js +0 -249
- package/src/api/NewsMixin.js +0 -168
- package/src/api/UserMixin.js +0 -59
- package/src/api/UtilMixin.js +0 -82
|
@@ -1,2 +1 @@
|
|
|
1
|
-
/*! For license information please see cocolight-api-client.mjs.js.LICENSE.txt */
|
|
2
|
-
import*as e from"events";import*as t from"ajv";import*as o from"ajv-formats";import*as n from"axios";import*as i from"axios-retry";import*as r from"ejson";import*as a from"pino";var s={251:(e,t)=>{t.L=function(e,t,o,n,i){var r,a,s=8*i-n-1,c=(1<<s)-1,m=c>>1,p=-7,l=o?i-1:0,d=o?-1:1,u=e[t+l];for(l+=d,r=u&(1<<-p)-1,u>>=-p,p+=s;p>0;r=256*r+e[t+l],l+=d,p-=8);for(a=r&(1<<-p)-1,r>>=-p,p+=n;p>0;a=256*a+e[t+l],l+=d,p-=8);if(0===r)r=1-m;else{if(r===c)return a?NaN:1/0*(u?-1:1);a+=Math.pow(2,n),r-=m}return(u?-1:1)*a*Math.pow(2,r-n)},t.M=function(e,t,o,n,i,r){var a,s,c,m=8*r-i-1,p=(1<<m)-1,l=p>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,u=n?0:r-1,f=n?1:-1,h=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=p):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),(t+=a+l>=1?d/c:d*Math.pow(2,1-l))*c>=2&&(a++,c/=2),a+l>=p?(s=0,a=p):a+l>=1?(s=(t*c-1)*Math.pow(2,i),a+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;e[o+u]=255&s,u+=f,s/=256,i-=8);for(a=a<<i|s,m+=i;m>0;e[o+u]=255&a,u+=f,a/=256,m-=8);e[o+u-f]|=128*h}},585:e=>{var t=1e3,o=60*t,n=60*o,i=24*n,r=7*i;function a(e,t,o,n){var i=t>=1.5*o;return Math.round(e/o)+" "+n+(i?"s":"")}e.exports=function(e,s){s=s||{};var c,m,p=typeof e;if("string"===p&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(a){var s=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return s*r;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*n;case"minutes":case"minute":case"mins":case"min":case"m":return s*o;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===p&&isFinite(e))return s.long?(c=e,(m=Math.abs(c))>=i?a(c,m,i,"day"):m>=n?a(c,m,n,"hour"):m>=o?a(c,m,o,"minute"):m>=t?a(c,m,t,"second"):c+" ms"):function(e){var r=Math.abs(e);return r>=i?Math.round(e/i)+"d":r>=n?Math.round(e/n)+"h":r>=o?Math.round(e/o)+"m":r>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},736:(e,t,o)=>{e.exports=function(e){function t(e){let o,i,r,a=null;function s(...e){if(!s.enabled)return;const n=s,i=Number(new Date),r=i-(o||i);n.diff=r,n.prev=o,n.curr=i,o=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((o,i)=>{if("%%"===o)return"%";a++;const r=t.formatters[i];if("function"==typeof r){const t=e[a];o=r.call(n,t),e.splice(a,1),a--}return o})),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(i!==t.namespaces&&(i=t.namespaces,r=t.enabled(e)),r),set:e=>{a=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,o){const n=t(this.namespace+(void 0===o?":":o)+e);return n.log=this.log,n}function i(e,t){let o=0,n=0,i=-1,r=0;for(;o<e.length;)if(n<t.length&&(t[n]===e[o]||"*"===t[n]))"*"===t[n]?(i=n,r=o,n++):(o++,n++);else{if(-1===i)return!1;n=i+1,r++,o=r}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const o=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of o)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const o of t.skips)if(i(e,o))return!1;for(const o of t.names)if(i(e,o))return!0;return!1},t.humanize=o(585),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((o=>{t[o]=e[o]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let o=0;for(let t=0;t<e.length;t++)o=(o<<5)-o+e.charCodeAt(t),o|=0;return t.colors[Math.abs(o)%t.colors.length]},t.enable(t.load()),t}},833:(e,t,o)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const o="color: "+this.color;t.splice(1,0,o,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,o)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=o(736)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}},c={};function m(e){var t=c[e];if(void 0!==t)return t.exports;var o=c[e]={exports:{}};return s[e](o,o.exports,m),o.exports}m.d=(e,t)=>{for(var o in t)m.o(t,o)&&!m.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},m.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),m.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};m.d(p,{A:()=>mt});var l={};m.r(l),m.d(l,{ApiAuthenticationError:()=>g,ApiClientError:()=>u,ApiError:()=>d,ApiResponseError:()=>y,ApiValidationError:()=>f,CircuitBreakerError:()=>h});class d extends Error{constructor(e,t,o){super(e),this.name="ApiError",this.status=t,this.details=o}}class u extends d{constructor(e,t,o){super(e,t,o),this.name="ApiClientError"}}class f extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiValidationError",this.status=t,this.messages=o,this.details=n}}class h extends d{constructor(e){super(e,503),this.name="CircuitBreakerError"}}class y extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiResponseError",this.status=t,this.responseData=o,this.details=n}}class g extends d{constructor(e,t,o){super(e,t,o),this.name="ApiAuthenticationError"}}const w={async resolveId(e){if(!this.id&&this.slug)try{const t=await this._getElementsKey({pathParams:{slug:this.slug}});if(!t?.contextId||t?.contextType!==e)throw new y(`Le slug ${this.slug} ne correspond pas à un ${e}`,200,t);this._id(t.contextId)}catch(t){throw t instanceof y?t?.responseData?.contextType!==e?t:new y(`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._getElementsAbout({pathParams:{id:this.id,type:this.getEntityType()}})},async _getElementsAbout(e={}){return this.call("GET_ELEMENTS_ABOUT",e)},async _getElementsKey(e={}){return this.call("GET_ELEMENTS_KEY",e)},async _profilImage(e={}){return this.callIsConnected("PROFIL_IMAGE",e)},async _updateSettings(e={}){return this.callIsConnected("UPDATE_SETTINGS",e)},async _updateBlockDescription(e={}){return this.callIsConnected("UPDATE_BLOCK_DESCRIPTION",e)},async _updateBlockInfo(e={}){return this.callIsConnected("UPDATE_BLOCK_INFO",e)},async _updateBlockSocial(e={}){return this.callIsConnected("UPDATE_BLOCK_SOCIAL",e)},async _updateBlockLocality(e={}){return this.callIsConnected("UPDATE_BLOCK_LOCALITY",e)},async _updateBlockSlug(e={}){return this.callIsConnected("UPDATE_BLOCK_SLUG",e)},async _check(e={}){return this.callIsConnected("CHECK",e)}},b={async _getNews(e={}){return this.call("GET_NEWS",e)},async _getNewsById(e={}){return this.call("GET_NEWS_BY_ID",e)},async _addNews(e={}){return this.callIsConnected("ADD_NEWS",e)},async _addImageNews(e={}){return this.callIsConnected("ADD_IMAGE_NEWS",e)},async _addFileNews(e={}){return this.callIsConnected("ADD_FILE_NEWS",e)},async _deleteNews(e={}){return this.callIsConnected("DELETE_NEWS",e)},async _updateNews(e={}){return this.callIsConnected("UPDATE_NEWS",e)},async _shareNews(e={}){return this.callIsConnected("SHARE_NEWS",e)}};function x(e){return new DataView(e.buffer,e.byteOffset)}m(251);const k={len:1,get:(e,t)=>x(e).getUint8(t),put:(e,t,o)=>(x(e).setUint8(t,o),t+1)},v={len:2,get:(e,t)=>x(e).getUint16(t,!0),put:(e,t,o)=>(x(e).setUint16(t,o,!0),t+2)},T={len:2,get:(e,t)=>x(e).getUint16(t),put:(e,t,o)=>(x(e).setUint16(t,o),t+2)},P={len:4,get:(e,t)=>x(e).getUint32(t,!0),put:(e,t,o)=>(x(e).setUint32(t,o,!0),t+4)},_={len:4,get:(e,t)=>x(e).getUint32(t),put:(e,t,o)=>(x(e).setUint32(t,o),t+4)},S={len:4,get:(e,t)=>x(e).getInt32(t),put:(e,t,o)=>(x(e).setInt32(t,o),t+4)},I={len:8,get:(e,t)=>x(e).getBigUint64(t,!0),put:(e,t,o)=>(x(e).setBigUint64(t,o,!0),t+8)};class A{constructor(e,t){this.len=e,this.encoding=t,this.textDecoder=new TextDecoder(t)}get(e,t){return this.textDecoder.decode(e.subarray(t,t+this.len))}}class E extends Error{constructor(){super("End-Of-Stream"),this.name="EndOfStreamError"}}class C extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}class j{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){const o=await this.read(e,t);return this.peekQueue.push(e.subarray(0,o)),o}async read(e,t=!1){if(0===e.length)return 0;let o=this.readFromPeekBuffer(e);if(this.endOfStream||(o+=await this.readRemainderFromStream(e.subarray(o),t)),0===o)throw new E;return o}readFromPeekBuffer(e){let t=e.length,o=0;for(;this.peekQueue.length>0&&t>0;){const n=this.peekQueue.pop();if(!n)throw new Error("peekData should be defined");const i=Math.min(n.length,t);e.set(n.subarray(0,i),o),o+=i,t-=i,i<n.length&&this.peekQueue.push(n.subarray(i))}return o}async readRemainderFromStream(e,t){let o=0;for(;o<e.length&&!this.endOfStream;){if(this.interrupted)throw new C;const n=await this.readFromStream(e.subarray(o),t);if(0===n)break;o+=n}if(!t&&o<e.length)throw new E;return o}}class O extends j{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}class $ extends O{async readFromStream(e,t){if(0===e.length)return 0;const o=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return o.done&&(this.endOfStream=o.done),o.value?(e.set(o.value),o.value.length):0}}class z extends j{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){const o=Math.min(t.length,e.length);return e.set(t.subarray(0,o)),o<t.length?this.buffer=t.subarray(o):this.buffer=null,o}async readFromStream(e,t){if(0===e.length)return 0;let o=0;for(this.buffer&&(o+=this.writeChunk(e,this.buffer));o<e.length&&!this.endOfStream;){const t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(o+=this.writeChunk(e.subarray(o),t.value))}if(0===o&&this.endOfStream)throw new E;return o}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}class q{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",(()=>{this.abort()}))}async readToken(e,t=this.position){const o=new Uint8Array(e.len);if(await this.readBuffer(o,{position:t})<e.len)throw new E;return e.get(o,0)}async peekToken(e,t=this.position){const o=new Uint8Array(e.len);if(await this.peekBuffer(o,{position:t})<e.len)throw new E;return e.get(o,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new E;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new E;return e.get(this.numBuffer,0)}async ignore(e){if(void 0!==this.fileInfo.size){const t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await(this.onClose?.())}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&void 0!==t.position&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}}class N extends q{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){const o=this.normalizeOptions(e,t),n=o.position-this.position;if(n>0)return await this.ignore(n),this.readBuffer(e,t);if(n<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(0===o.length)return 0;const i=await this.streamReader.read(e.subarray(0,o.length),o.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<o.length)throw new E;return i}async peekBuffer(e,t){const o=this.normalizeOptions(e,t);let n=0;if(o.position){const t=o.position-this.position;if(t>0){const i=new Uint8Array(o.length+t);return n=await this.peekBuffer(i,{mayBeLess:o.mayBeLess}),e.set(i.subarray(t)),n-t}if(t<0)throw new Error("Cannot peek from a negative offset in a stream")}if(o.length>0){try{n=await this.streamReader.peek(e.subarray(0,o.length),o.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof E)return 0;throw e}if(!o.mayBeLess&&n<o.length)throw new E}return n}async ignore(e){const t=Math.min(256e3,e),o=new Uint8Array(t);let n=0;for(;n<e;){const i=e-n,r=await this.readBuffer(o,{length:Math.min(t,i)});if(r<0)return r;n+=r}return n}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}class M extends q{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);const o=await this.peekBuffer(e,t);return this.position+=o,o}async peekBuffer(e,t){const o=this.normalizeOptions(e,t),n=Math.min(this.uint8Array.length-o.position,o.length);if(!o.mayBeLess&&n<o.length)throw new E;return e.set(this.uint8Array.subarray(o.position,o.position+n)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}var B=Uint8Array,L=Uint16Array,F=Int32Array,D=new B([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),U=new B([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),R=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),G=function(e,t){for(var o=new L(31),n=0;n<31;++n)o[n]=t+=1<<e[n-1];var i=new F(o[30]);for(n=1;n<30;++n)for(var r=o[n];r<o[n+1];++r)i[r]=r-o[n]<<5|n;return{b:o,r:i}},Z=G(D,2),V=Z.b,K=Z.r;V[28]=258,K[258]=28;for(var W=G(U,0),J=W.b,H=(W.r,new L(32768)),Y=0;Y<32768;++Y){var Q=(43690&Y)>>1|(21845&Y)<<1;Q=(61680&(Q=(52428&Q)>>2|(13107&Q)<<2))>>4|(3855&Q)<<4,H[Y]=((65280&Q)>>8|(255&Q)<<8)>>1}var X=function(e,t,o){for(var n=e.length,i=0,r=new L(t);i<n;++i)e[i]&&++r[e[i]-1];var a,s=new L(t);for(i=1;i<t;++i)s[i]=s[i-1]+r[i-1]<<1;if(o){a=new L(1<<t);var c=15-t;for(i=0;i<n;++i)if(e[i])for(var m=i<<4|e[i],p=t-e[i],l=s[e[i]-1]++<<p,d=l|(1<<p)-1;l<=d;++l)a[H[l]>>c]=m}else for(a=new L(n),i=0;i<n;++i)e[i]&&(a[i]=H[s[e[i]-1]++]>>15-e[i]);return a},ee=new B(288);for(Y=0;Y<144;++Y)ee[Y]=8;for(Y=144;Y<256;++Y)ee[Y]=9;for(Y=256;Y<280;++Y)ee[Y]=7;for(Y=280;Y<288;++Y)ee[Y]=8;var te=new B(32);for(Y=0;Y<32;++Y)te[Y]=5;var oe=X(ee,9,1),ne=X(te,5,1),ie=function(e){for(var t=e[0],o=1;o<e.length;++o)e[o]>t&&(t=e[o]);return t},re=function(e,t,o){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&o},ae=function(e,t){var o=t/8|0;return(e[o]|e[o+1]<<8|e[o+2]<<16)>>(7&t)},se=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ce=function(e,t,o){var n=new Error(t||se[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,ce),!o)throw n;return n},me=function(e,t,o,n){var i=e.length,r=n?n.length:0;if(!i||t.f&&!t.l)return o||new B(0);var a=!o,s=a||2!=t.i,c=t.i;a&&(o=new B(3*i));var m,p=function(e){var t=o.length;if(e>t){var n=new B(Math.max(2*t,e));n.set(o),o=n}},l=t.f||0,d=t.p||0,u=t.b||0,f=t.l,h=t.d,y=t.m,g=t.n,w=8*i;do{if(!f){l=re(e,d,1);var b=re(e,d+1,3);if(d+=3,!b){var x=e[(m=d,(j=4+((m+7)/8|0))-4)]|e[j-3]<<8,k=j+x;if(k>i){c&&ce(0);break}s&&p(u+x),o.set(e.subarray(j,k),u),t.b=u+=x,t.p=d=8*k,t.f=l;continue}if(1==b)f=oe,h=ne,y=9,g=5;else if(2==b){var v=re(e,d,31)+257,T=re(e,d+10,15)+4,P=v+re(e,d+5,31)+1;d+=14;for(var _=new B(P),S=new B(19),I=0;I<T;++I)S[R[I]]=re(e,d+3*I,7);d+=3*T;var A=ie(S),E=(1<<A)-1,C=X(S,A,1);for(I=0;I<P;){var j,O=C[re(e,d,E)];if(d+=15&O,(j=O>>4)<16)_[I++]=j;else{var $=0,z=0;for(16==j?(z=3+re(e,d,3),d+=2,$=_[I-1]):17==j?(z=3+re(e,d,7),d+=3):18==j&&(z=11+re(e,d,127),d+=7);z--;)_[I++]=$}}var q=_.subarray(0,v),N=_.subarray(v);y=ie(q),g=ie(N),f=X(q,y,1),h=X(N,g,1)}else ce(1);if(d>w){c&&ce(0);break}}s&&p(u+131072);for(var M=(1<<y)-1,L=(1<<g)-1,F=d;;F=d){var G=($=f[ae(e,d)&M])>>4;if((d+=15&$)>w){c&&ce(0);break}if($||ce(2),G<256)o[u++]=G;else{if(256==G){F=d,f=null;break}var Z=G-254;if(G>264){var K=D[I=G-257];Z=re(e,d,(1<<K)-1)+V[I],d+=K}var W=h[ae(e,d)&L],H=W>>4;if(W||ce(3),d+=15&W,N=J[H],H>3&&(K=U[H],N+=ae(e,d)&(1<<K)-1,d+=K),d>w){c&&ce(0);break}s&&p(u+131072);var Y=u+Z;if(u<N){var Q=r-N,ee=Math.min(N,Y);for(Q+u<0&&ce(3);u<ee;++u)o[u]=n[Q+u]}for(;u<Y;++u)o[u]=o[u-N]}}t.l=f,t.p=F,t.b=u,t.f=l,f&&(l=1,t.m=y,t.d=h,t.n=g)}while(!l);return u!=o.length&&a?function(e,t,o){return(null==t||t<0)&&(t=0),(null==o||o>e.length)&&(o=e.length),new B(e.subarray(t,o))}(o,0,u):o.subarray(0,u)},pe=new B(0);function le(e,t){var o,n,i=function(e){31==e[0]&&139==e[1]&&8==e[2]||ce(6,"invalid gzip data");var t=e[3],o=10;4&t&&(o+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[o++]);return o+(2&t)}(e);return i+8>e.length&&ce(6,"invalid gzip data"),me(e.subarray(i,-8),{i:2},t&&t.out||new B((n=(o=e).length,(o[n-4]|o[n-3]<<8|o[n-2]<<16|o[n-1]<<24)>>>0)),t&&t.dictionary)}function de(e,t){return me(e.subarray((o=e,n=t&&t.dictionary,(8!=(15&o[0])||o[0]>>4>7||(o[0]<<8|o[1])%31)&&ce(6,"invalid zlib data"),(o[1]>>5&1)==+!n&&ce(6,"invalid zlib data: "+(32&o[1]?"need":"unexpected")+" dictionary"),2+(o[1]>>3&4)),-4),{i:2},t&&t.out,t&&t.dictionary);var o,n}var ue="undefined"!=typeof TextDecoder&&new TextDecoder;try{ue.decode(pe,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;var fe=m(833);const he=67324752,ye=33639248,ge={get:e=>(v.get(e,6),{signature:P.get(e,0),compressedSize:P.get(e,8),uncompressedSize:P.get(e,12)}),len:16},we={get(e){const t=v.get(e,6);return{signature:P.get(e,0),minVersion:v.get(e,4),dataDescriptor:!!(8&t),compressedMethod:v.get(e,8),compressedSize:P.get(e,18),uncompressedSize:P.get(e,22),filenameLength:v.get(e,26),extraFieldLength:v.get(e,28),filename:null}},len:30},be={get:e=>({signature:P.get(e,0),nrOfThisDisk:v.get(e,4),nrOfThisDiskWithTheStart:v.get(e,6),nrOfEntriesOnThisDisk:v.get(e,8),nrOfEntriesOfSize:v.get(e,10),sizeOfCd:P.get(e,12),offsetOfStartOfCd:P.get(e,16),zipFileCommentLength:v.get(e,20)}),len:22},xe={get(e){const t=v.get(e,8);return{signature:P.get(e,0),minVersion:v.get(e,6),dataDescriptor:!!(8&t),compressedMethod:v.get(e,10),compressedSize:P.get(e,20),uncompressedSize:P.get(e,24),filenameLength:v.get(e,28),extraFieldLength:v.get(e,30),fileCommentLength:v.get(e,32),relativeOffsetOfLocalHeader:P.get(e,42),filename:null}},len:46};function ke(e){const t=new Uint8Array(P.len);return P.put(t,0,e),t}const ve=fe("tokenizer:inflate"),Te=262144,Pe=ke(134695760),_e=ke(101010256);class Se{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Te)}async isZip(){return await this.peekSignature()===he}peekSignature(){return this.tokenizer.peekToken(P)}async findEndOfCentralDirectoryLocator(){const e=this.tokenizer,t=Math.min(16384,e.fileInfo.size),o=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(o,{position:e.fileInfo.size-t});for(let n=o.length-4;n>=0;n--)if(o[n]===_e[0]&&o[n+1]===_e[1]&&o[n+2]===_e[2]&&o[n+3]===_e[3])return e.fileInfo.size-t+n;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess())return void ve("Cannot reading central-directory without random-read support");ve("Reading central-directory...");const e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){ve("Central-directory 32-bit signature found");const o=await this.tokenizer.readToken(be,t),n=[];this.tokenizer.setPosition(o.offsetOfStartOfCd);for(let e=0;e<o.nrOfEntriesOfSize;++e){const t=await this.tokenizer.readToken(xe);if(t.signature!==ye)throw new Error("Expected Central-File-Header signature");t.filename=await this.tokenizer.readToken(new A(t.filenameLength,"utf-8")),await this.tokenizer.ignore(t.extraFieldLength),await this.tokenizer.ignore(t.fileCommentLength),n.push(t),ve(`Add central-directory file-entry: n=${e+1}/${n.length}: filename=${n[e].filename}`)}return this.tokenizer.setPosition(e),n}this.tokenizer.setPosition(e)}async unzip(e){const t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let o=!1;do{const t=await this.readLocalFileHeader();if(!t)break;const n=e(t);let i;if(o=!!n.stop,await this.tokenizer.ignore(t.extraFieldLength),t.dataDescriptor&&0===t.compressedSize){const e=[];let o=Te;ve("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let i=-1;for(;i<0&&o===Te;){o=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),i=Ie(this.syncBuffer.subarray(0,o),Pe);const t=i>=0?i:o;if(n.handler){const o=new Uint8Array(t);await this.tokenizer.readBuffer(o),e.push(o)}else await this.tokenizer.ignore(t)}ve(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),n.handler&&await this.inflate(t,Ae(e),n.handler)}else n.handler?(ve(`Reading compressed-file-data: ${t.compressedSize} bytes`),i=new Uint8Array(t.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(t,i,n.handler)):(ve(`Ignoring compressed-file-data: ${t.compressedSize} bytes`),await this.tokenizer.ignore(t.compressedSize));if(ve(`Reading data-descriptor at pos=${this.tokenizer.position}`),t.dataDescriptor&&134695760!==(await this.tokenizer.readToken(ge)).signature)throw new Error("Expected data-descriptor-signature at position "+(this.tokenizer.position-ge.len))}while(!o)}async iterateOverCentralDirectory(e,t){for(const o of e){const e=t(o);if(e.handler){this.tokenizer.setPosition(o.relativeOffsetOfLocalHeader);const t=await this.readLocalFileHeader();if(t){await this.tokenizer.ignore(t.extraFieldLength);const n=new Uint8Array(o.compressedSize);await this.tokenizer.readBuffer(n),await this.inflate(t,n,e.handler)}}if(e.stop)break}}inflate(e,t,o){return 0===e.compressedMethod?o(t):(ve(`Decompress filename=${e.filename}, compressed-size=${t.length}`),o(31==(n=t)[0]&&139==n[1]&&8==n[2]?le(n,i):8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31?function(e,t){return me(e,{i:2},t&&t.out,t&&t.dictionary)}(n,i):de(n,i)));var n,i}async readLocalFileHeader(){const e=await this.tokenizer.peekToken(P);if(e===he){const e=await this.tokenizer.readToken(we);return e.filename=await this.tokenizer.readToken(new A(e.filenameLength,"utf-8")),e}if(e===ye)return!1;if(3759263696===e)throw new Error("Encrypted ZIP");throw new Error("Unexpected signature")}}function Ie(e,t){const o=e.length,n=t.length;if(n>o)return-1;for(let i=0;i<=o-n;i++){let o=!0;for(let r=0;r<n;r++)if(e[i+r]!==t[r]){o=!1;break}if(o)return i}return-1}function Ae(e){const t=e.reduce(((e,t)=>e+t.length),0),o=new Uint8Array(t);let n=0;for(const t of e)o.set(t,n),n+=t.length;return o}function Ee(e){const{byteLength:t}=e;return 6===t?e.getUint16(0)*2**32+e.getUint32(2):5===t?e.getUint8(0)*2**32+e.getUint32(1):4===t?e.getUint32(0):3===t?65536*e.getUint8(0)+e.getUint16(1):2===t?e.getUint16(0):1===t?e.getUint8(0):void 0}Object.prototype.toString,new globalThis.TextDecoder("utf8"),new globalThis.TextEncoder,Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));const Ce={get:(e,t)=>127&e[t+3]|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},je=4100;function Oe(e){switch(e){case"application/epub+zip":return{ext:"epub",mime:"application/epub+zip"};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:"application/vnd.oasis.opendocument.text-template"};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:"application/vnd.oasis.opendocument.spreadsheet-template"};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:"application/vnd.oasis.opendocument.presentation-template"};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:"application/vnd.oasis.opendocument.graphics"};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:"application/vnd.oasis.opendocument.graphics-template"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};case"application/vnd.ms-excel.sheet.macroEnabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroEnabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.template"};case"application/vnd.ms-excel.template.macroEnabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};case"application/vnd.ms-word.document.macroEnabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroEnabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.template"};case"application/vnd.ms-word.template.macroEnabledTemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroEnabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:"application/vnd.openxmlformats-officedocument.presentationml.template"};case"application/vnd.ms-powerpoint.template.macroEnabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroEnabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};case"application/vnd.ms-powerpoint.presentation.macroEnabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroEnabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function $e(e,t,o){o={offset:0,...o};for(const[n,i]of t.entries())if(o.mask){if(i!==(o.mask[n]&e[n+o.offset]))return!1}else if(i!==e[n+o.offset])return!1;return!0}class ze{constructor(e){this.detectors=[...e?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){const t=e.position;for(const o of this.detectors){const n=await o.detect(e);if(n)return n;if(t!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Uint8Array?e:new Uint8Array(e);var o,n;if(t?.length>1)return this.fromTokenizer((o=t,n=this.tokenizerOptions,new M(o,n)))}async fromBlob(e){return this.fromStream(e.stream())}async fromStream(e){const t=await function(e,t){const o=function(e){try{const t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new z(t):new $(t)}catch(t){if(t instanceof TypeError)return new z(e.getReader());throw t}}(e),n=t??{},i=n.onClose;return n.onClose=async()=>{if(await o.close(),i)return i()},new N(o,n)}(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(e,t){const{sampleSize:o=je}=t;let n,i;const r=e.getReader({mode:"byob"});try{const{value:e,done:t}=await r.read(new Uint8Array(o));if(i=e,!t&&e)try{n=await this.fromBuffer(e.slice(0,o))}catch(e){if(!(e instanceof E))throw e;n=void 0}i=e}finally{r.releaseLock()}const a=new TransformStream({async start(e){e.enqueue(i)},transform(e,t){t.enqueue(e)}}),s=e.pipeThrough(a);return s.fileType=n,s}check(e,t){return $e(this.buffer,e,t)}checkString(e,t){return this.check((o=e,[...o].map((e=>e.charCodeAt(0)))),t);var o}detectConfident=async e=>{if(this.buffer=new Uint8Array(je),void 0===e.fileInfo.size&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);const t=await e.readToken(Ce);return e.position+t>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(t),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((67===this.buffer[0]||70===this.buffer[0])&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let o;return await new Se(e).unzip((e=>{switch(e.filename){case"META-INF/mozilla.rsa":return o={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return o={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(e){const t=new TextDecoder("utf-8").decode(e).trim();o=Oe(t)},stop:!0};case"[Content_Types].xml":return{async handler(e){let t=new TextDecoder("utf-8").decode(e);const n=t.indexOf('.main+xml"');if(-1===n){const e="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";t.includes(`ContentType="${e}"`)&&(o=Oe(e))}else{t=t.slice(0,Math.max(0,n));const e=t.lastIndexOf('"'),i=t.slice(Math.max(0,e+1));o=Oe(i)}},stop:!0};default:return/classes\d*\.dex/.test(e.filename)?(o={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})),o??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);const n=new Uint8Array(8);return await e.readBuffer(n),$e(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:$e(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:$e(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:$e(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:$e(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:$e(n,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(3===this.buffer[2]||5===this.buffer[2]||7===this.buffer[2])&&(4===this.buffer[3]||6===this.buffer[3]||8===this.buffer[3]))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/x-flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF")){try{const i=1350;if(i===await e.ignore(i)){const r=10485760,a=new Uint8Array(Math.min(r,e.fileInfo.size-i));if(await e.readBuffer(a,{mayBeLess:!0}),-1!==function(e,t){const o=e.length,n=t.length;if(0===n)return-1;if(n>o)return-1;const i=o-n;for(let o=0;o<=i;o++){let i=!0;for(let r=0;r<n;r++)if(e[o+r]!==t[r]){i=!1;break}if(i)return o}return-1}(a,(new TextEncoder).encode("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}}catch(s){if(!(s instanceof E))throw s}return{ext:"pdf",mime:"application/pdf"}}if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const c=await this.readTiffHeader(!1);if(c)return c}if(this.check([77,77])){const m=await this.readTiffHeader(!0);if(m)return m}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function p(){const t=await e.peekNumber(k);let o=128,n=0;for(;!(t&o)&&0!==o;)++n,o>>=1;const i=new Uint8Array(n+1);return await e.readBuffer(i),i}async function l(){const e=await p(),t=await p();t[0]^=128>>t.length-1;const o=Math.min(6,t.length),n=new DataView(e.buffer),i=new DataView(t.buffer,t.length-o,o);return{id:Ee(n),len:Ee(i)}}async function d(t){for(;t>0;){const o=await l();if(17026===o.id)return(await e.readToken(new A(o.len))).replaceAll(/\00.*$/g,"");await e.ignore(o.len),--t}}const u=await l();switch(await d(u.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/x-matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1"))return{ext:"parquet",mime:"application/x-parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(0===this.buffer[6]||1===this.buffer[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const f=new A(4,"latin1").get(this.buffer,2);if(f.match("^d*")&&f>=1e3&&f<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),"debian-binary"===await e.readToken(new A(13,"ascii"))?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&["\n","\r","\t"," ","\0"].some((e=>this.checkString(e,{offset:6}))))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){async function h(){return{length:await e.readToken(S),type:await e.readToken(new A(4,"latin1"))}}await e.ignore(8);do{const y=await h();if(y.length<0)return;switch(y.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(y.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/x-apache-arrow"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&96&this.buffer[8]){const g=new A(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(g){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return g.startsWith("3g")?g.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function w(){const t=new Uint8Array(16);return await e.readBuffer(t),{id:t,size:Number(await e.readToken(I))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){const b=await w();let x=b.size-24;if($e(b.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const v=new Uint8Array(16);if(x-=await e.readBuffer(v),$e(v,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if($e(v,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(x)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new A(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const T=new DataView(this.buffer.buffer).getUint32(12,!0);if(T>12&&this.buffer.length>=T+16)try{const P=(new TextDecoder).decode(this.buffer.slice(16,T+16));if(JSON.parse(P).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}return this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2])?{ext:"mxf",mime:"application/mxf"}:this.checkString("SCRM",{offset:44})?{ext:"s3m",mime:"audio/x-s3m"}:this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196})?{ext:"mts",mime:"video/mp2t"}:this.check([66,79,79,75,77,79,66,73],{offset:60})?{ext:"mobi",mime:"application/x-mobipocket-ebook"}:this.check([68,73,67,77],{offset:128})?{ext:"dcm",mime:"application/dicom"}:this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70])?{ext:"lnk",mime:"application/x.ms.shortcut"}:this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0])?{ext:"alias",mime:"application/x.apple.alias"}:this.checkString("Kaydara FBX Binary \0")?{ext:"fbx",mime:"application/x.autodesk.fbx"}:this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8}))?{ext:"eot",mime:"application/vnd.ms-fontobject"}:this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29])?{ext:"indd",mime:"application/x-indesign"}:(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),function(e,t=0){const o=Number.parseInt(new A(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(o))return!1;let n=256;for(let o=t;o<t+148;o++)n+=e[o];for(let o=t+156;o<t+512;o++)n+=e[o];return o===n}(this.buffer)?{ext:"tar",mime:"application/x-tar"}:this.check([255,254])?this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0:this.checkString("-----BEGIN PGP MESSAGE-----")?{ext:"pgp",mime:"application/pgp-encrypted"}:void 0)};detectImprecise=async e=>{if(this.buffer=new Uint8Array(je),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(this.buffer.length>=2&&this.check([255,224],{offset:0,mask:[255,224]})){if(this.check([16],{offset:1,mask:[22]}))return this.check([8],{offset:1,mask:[8]}),{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}};async readTiffTag(e){const t=await this.tokenizer.readToken(e?T:v);switch(this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(e){const t=await this.tokenizer.readToken(e?T:v);for(let o=0;o<t;++o){const t=await this.readTiffTag(e);if(t)return t}}async readTiffHeader(e){const t=(e?T:v).get(this.buffer,2),o=(e?_:P).get(this.buffer,4);if(42===t){if(o>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(o>=8){const t=(e?T:v).get(this.buffer,8),o=(e?T:v).get(this.buffer,10);if(28===t&&254===o||31===t&&11===o)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(o),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(43===t)return{ext:"tif",mime:"image/tiff"}}}new Set(["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","rm"]),new Set(["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/x-parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroEnabled.12","application/vnd.ms-word.document.macroEnabled.12","application/vnd.ms-word.template.macroEnabled.12","application/vnd.ms-powerpoint.template.macroEnabled.12","application/vnd.ms-powerpoint.presentation.macroEnabled.12","application/java-archive","application/vnd.rn-realmedia"]);const qe={async call(e,t={}){return this.apiClient.safeCall((async()=>{const o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))},async callNoConnected(e,t={}){if(this.isConnected)throw new g("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 g("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 g("Vous devez être vous-même pour faire cette action.");return"function"==typeof e?await e():await this.callIsConnected(e,t)},async validateImage(e){if(!e)throw new f("Le fichier est requis.");let t="";if("undefined"!=typeof File&&e instanceof File){if(t=e.type,!t||!t.startsWith("image/")||!["image/jpg","image/jpeg","image/png"].includes(t))throw new f("Le fichier doit être une image valide.")}else if("undefined"!=typeof Blob&&e instanceof Blob){t=e.type;const o=`${Date.now()}.${t.split("/")[1]}`;if(e=new File([e],o,{type:t}),console.log(o),!t||!t.startsWith("image/")||!["image/jpg","image/jpeg","image/png"].includes(t))throw new f("Le fichier doit être une image valide (jpg ou png).")}else{if("undefined"==typeof Buffer||!Buffer.isBuffer(e))throw new f("Le fichier doit être de type File (navigateur) ou Buffer (Node).");{const o=await async function(e){return(new ze).fromBuffer(e)}(e);if(!o||!o.mime.startsWith("image/")||!["image/jpg","image/jpeg","image/png"].includes(o.mime))throw new f("Le fichier doit être une image valide.");t=o.mime}}return e}};class Ne{#e;#t;#o=null;constructor(e,{id:t,slug:o}={}){if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer un User.");this.apiClient=e,this.#e=t||null,this.#t=o||null}get id(){return this.#e}_id(e){this.#e=e}get slug(){return this.#t}_slug(e){this.#t=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#o}_setData(e){this.#o=e}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}getEntityType(){return"organizations"}async getProfil(){return this.apiClient.safeCall((async()=>{const e=await this.getPublicProfile();return this._setData(e),e}))}async getNews(e={}){return e.pathParams={type:this.getEntityType(),id:this.id},this._getNews(e)}async addNews(e={}){return e.parentId=this.id,e.parentType=this.getEntityType(),this.callIsConnected((()=>this._addNews(e)))}}Object.assign(Ne.prototype,w,qe,b);class Me{#e;#t;#o=null;constructor(e,{id:t,slug:o}={}){if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer un User.");this.apiClient=e,this.#e=t||null,this.#t=o||null}get id(){return this.#e}_id(e){this.#e=e}get slug(){return this.#t}_slug(e){this.#t=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#o}_setData(e){this.#o=e}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}getEntityType(){return"projects"}async getProfil(){return this.apiClient.safeCall((async()=>{const e=await this.getPublicProfile();return this._setData(e),e}))}async getNews(e={}){return e.pathParams={type:this.getEntityType(),id:this.id},this._getNews(e)}async addNews(e={}){return e.parentId=this.id,e.parentType=this.getEntityType(),this.callIsConnected((()=>this._addNews(e)))}}Object.assign(Me.prototype,w,qe,b);const Be={async _meInfoUrl(){return this.callIsConnected("ME_INFO_URL")},async _changePassword(e={}){return e.userId&&delete e.userId,e.mode&&delete e.mode,this.callIsConnected("CHANGE_PASSWORD",e)},async _deleteAccount(e={}){return e.pathParams&&delete e.pathParams,this.callIsConnected("DELETE_ACCOUNT",e)}};class Le{#e;#t;#o;constructor(e,{id:t,slug:o}={},n={}){if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer un User.");this.apiClient=e,this.#e=t||null,this.#t=o||null,this.#o=n}get id(){return this.#e}_id(e){this.#e=e}get slug(){return this.#t}_slug(e){this.#t=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#o}_setData(e){this.#o=e}getEntityType(){return"citoyens"}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}async getProfil(){return this.apiClient.safeCall((async()=>this.isMe?await this._meInfoUrl():await this.getPublicProfile()))}async changePassword(e={}){return this.callIsMe((()=>this._changePassword(e)))}async delete(e={}){return this.callIsMe((()=>this._deleteAccount(e)))}async updateSettings(e={}){return this.callIsMe((()=>this._updateSettings(e)))}async updateDescription(e={}){return this.callIsMe((()=>this._updateBlockDescription(e)))}async updateInfo(e={}){return this.callIsMe((()=>this._updateBlockInfo(e)))}async updateSocial(e={}){return this.callIsMe((()=>this._updateBlockSocial(e)))}async updateLocality(e={}){return this.callIsMe((()=>this._updateBlockLocality(e)))}async updateSlug(e){try{await this._check({slug:e})}catch(e){if(e instanceof y)throw new y("Erreur lors de la vérification du slug.",e.status,e.data);throw e}return this.callIsMe((()=>this._updateBlockSlug({slug:e})))}async updateImageProfil(e){return e=await this.validateImage(e),this.callIsMe((()=>this._profilImage({profil_avatar:e})))}async getNews(e={}){return e.pathParams&&delete e.pathParams,this.isMe||(e.pathParams={id:this.id}),this._getNews(e)}async addNews(e={}){return e.parentId&&delete e.parentId,e.parentType&&delete e.parentType,this.callIsMe((()=>this._addNews(e)))}}Object.assign(Le.prototype,w,qe,Be,b);const Fe=(e=>{var t={};return m.d(t,e),t})({EventEmitter:()=>e.EventEmitter}),De=(e,t)=>1===t?e:`${e}s`,Ue=e=>{if(""===e)return"$";const t=e.substring(1).split(/\//).map((e=>e.replace(/~1/g,"/").replace(/~0/g,"~").replace(/\./g,"\\."))).map((e=>/^\d+$/.exec(e)?`[${e}]`:`.${e}`)).join("");return"$"+t},Re=e=>{switch(e[0]){case"a":case"e":case"i":case"o":case"u":return"an";default:return"a"}},Ge=(e,t="and")=>0===e.length?"nothing":1===e.length?e[0]:2===e.length?`${e[0]} ${t} ${e[1]}`:`${e.slice(0,-1).join(", ")}, ${t} ${e[e.length-1]}`,Ze={"date-time":"date and time",time:"time",date:"date",email:"email address",hostname:"hostname",ipv4:"IPv4 address",ipv6:"IPv6 address",uri:"URI","uri-reference":"URI Reference","uri-template":"URI-template","json-pointer":"JSON Pointer","relative-json-pointer":"relative JSON Pointer",regex:"regular expression"},Ve={fieldLabels:"title",includeOriginalError:!1,includeData:!1};class Ke extends Error{constructor(e,t={}){super(),this.options={},this.redundant=!1,this.options={...Ve,...t},this.pointer=e.instancePath,this.path=Ue(e.instancePath);const o=(({data:e,keyword:t,message:o,params:n,parentSchema:i,schemaPath:r,instancePath:a},{fieldLabels:s})=>{const c=(({instancePath:e,parentSchema:t},{fieldLabels:o})=>{switch(o){case"js":return""===e?"the root value":`the value at ${Ue(e).replace(/^\$/,"")}`;case"jsonPath":return`the value at ${Ue(e)}`;case"jsonPointer":case"instancePath":return""===e?"the root value":`the value at ${e}`;case"title":return(null==t?void 0:t.title)?t.title:""===e?"the root value":`the value at ${e}`;default:throw new Error(`invalid fieldLabels value: ${o}`)}})({instancePath:a,parentSchema:i},{fieldLabels:s});if(null==i?void 0:i.errorMessage)return`${c} ${i.errorMessage}`;switch(t){case"enum":{const e=n.allowedValues.map(JSON.stringify);return`${c} must be one of: ${Ge(e,"or")}`}case"type":{const t=Array.isArray(n.type)?n.type:n.type.split(","),o=Ge(t,"or"),i=(e=>{const t=typeof e;switch(t){case"object":return null===e?"null":Array.isArray(e)?"an array":"an object";case"undefined":return"undefined";default:return`${Re(t)} ${t}`}})(e);return`${c} must be ${Re(o)} ${o} but it was ${i}`}case"minLength":{const t=n.limit,o=De("character",t),i=e.length;return`${c} must be ${t} ${o} or more but it was ${i} ${De("character",i)}`}case"maxLength":{const t=n.limit,o=De("character",t),i=e.length;return`${c} must be ${t} ${o} or fewer but it was ${i} ${De("character",i)}`}case"pattern":{if(r.endsWith("propertyNames/pattern"))return null;const e=null==i?void 0:i.patternLabel;return e?`${c} must be ${e} but it was not`:`${c} is an invalid string`}case"format":return`${c} must be a valid ${Ze[n.format]||n.format} string but it was not`;case"multipleOf":return`${c} must be a multiple of ${n.multipleOf}`;case"minimum":return`${c} must be equal to or greater than ${n.limit}`;case"exclusiveMinimum":return`${c} must be greater than ${n.limit}`;case"maximum":return`${c} must be equal to or less than ${n.limit}`;case"exclusiveMaximum":return`${c} must be less than ${n.limit}`;case"additionalProperties":{const e=Object.keys(null==i?void 0:i.properties).join(", ");return`${c} has an unexpected property, ${n.additionalProperty}, which is not in the list of allowed properties (${e})`}case"required":return`${c} is missing the required field '${n.missingProperty}'`;case"propertyNames":return`${c} has an invalid property name ${JSON.stringify(n.propertyName)}`;case"minProperties":return`${c} must have ${n.limit} or more properties but it has ${Object.keys(e).length}`;case"maxProperties":return`${c} must have ${n.limit} or fewer properties but it has ${Object.keys(e).length}`;case"dependencies":{const e=n.property;return`${c} must have property ${n.missingProperty} when ${e} is present`}case"minItems":return`${c} must have ${n.limit} or more items but it has ${e.length}`;case"maxItems":return`${c} must have ${n.limit} or fewer items but it has ${e.length}`;case"uniqueItems":{const{i:e,j:t}=n;return`${c} must be unique but elements ${t} and ${e} are the same`}default:return`${c} ${o}`}})(e,this.options);var n;null!==o?(this.message=`${n=o,"string"!=typeof n||0===n.length?n:n.charAt(0).toUpperCase()+n.slice(1)}.`,this.options.includeOriginalError&&(this.original=e),this.options.includeData&&(this.data=e.data)):this.redundant=!0}toJSON(){const e={path:this.path,pointer:this.pointer,message:this.message};return this.options.includeOriginalError&&(e.original=this.original),this.options.includeData&&(e.data=this.data),e}}class We extends Error{constructor(e,t={}){super(),this.name="AggregateAjvError",this.errors=(null!=e?e:[]).map((e=>new Ke(e,t))).filter((e=>!e.redundant)),this.message=this.errors.map((e=>e.message)).join(" ")}toJSON(){return this.errors.map((e=>e.toJSON()))}*[Symbol.iterator](){for(const e of this.errors)yield e}}const Je=(e=>{var t={};return m.d(t,e),t})({default:()=>t.default}),He=(e=>{var t={};return m.d(t,e),t})({default:()=>o.default}),Ye=(e=>{var t={};return m.d(t,e),t})({default:()=>n.default}),Qe=(e=>{var t={};return m.d(t,e),t})({default:()=>i.default}),Xe=(e=>{var t={};return m.d(t,e),t})({default:()=>r.default});class et extends Error{}et.prototype.name="InvalidTokenError";const tt=(e=>{var t={};return m.d(t,e),t})({default:()=>a.default}),ot={_looksLikeObjectID:e=>24===e.length&&/^[0-9a-f]*$/.test(e),ObjectID:class{constructor(e){if(e){if(e=e.toLowerCase(),!ot._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=e}}equals(e){return e instanceof ot.ObjectID&&this.valueOf()===e.valueOf()}toString(){return`ObjectID("${this._str}")`}clone(){return new ot.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()}}},nt=ot,it={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"},common7:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},common8:{default:"",type:"string"},common9:{pattern:"^[a-f0-9]{24}$",type:"string"},common10:{const:"citoyens"},common11:{properties:{value:{type:"boolean"}}},common12:{value:{type:"boolean"}},common13:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},common14:{},common15:{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"}}}},common16:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},common17:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},common18:{properties:{typeElement:{const:"citoyens"}}},common19:{typeElement:{const:"citoyens"}},common20:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}},common21:{not:{type:"null"}},common22:{type:"null"},common23:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common24:{items:{type:"string"},type:"array"},common25:{enum:[""],type:"string"},common26:{properties:{name:{not:{type:"null"}}},required:["name"]},common27:{name:{not:{type:"null"}}},common28:{properties:{url:{not:{type:"null"}}},required:["url"]},common29:{url:{not:{type:"null"}}},common30:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common31:{tags:{not:{type:"null"}}},common32:{properties:{email:{not:{type:"null"}}},required:["email"]},common33:{email:{not:{type:"null"}}},common34:{const:"info",default:"info",type:"string"},common35:{$ref:"#/$defs/sharedFields/email"},common36:{$ref:"#/$defs/sharedFields/name"},common37:{$ref:"#/$defs/sharedFields/tags"},common38:{$ref:"#/$defs/sharedFields/url"},common39:{const:"projects"},common40:{const:"organizations"},common41:{$ref:"#/$defs/socialField"},common42:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},common43:{id:{pattern:"^[a-f0-9]{24}$"}},common44:{pattern:"^[a-f0-9]{24}$"},common45:{minLength:0,type:"string"},common46:{type:["string","number"]},common47:{type:"number"},common48:{const:!0,default:!0,type:"boolean"},common49:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common50:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common51:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"},common52:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common53:{properties:{type:{const:"citoyens"}}},common54:{type:{const:"citoyens"}},common55:{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"},common56:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},common57:{ownerId:{pattern:"^[a-f0-9]{24}$"}},common58:{properties:{folder:{const:"citoyens"}}},common59:{folder:{const:"citoyens"}},common60:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},common61:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common62:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common63:{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"},common64:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},common65:{properties:{parentId:{pattern:"^[a-f0-9]{24}$"}}},common66:{parentId:{pattern:"^[a-f0-9]{24}$"}},common67:{properties:{parentType:{const:"citoyens"}}},common68:{parentType:{const:"citoyens"}},common69:{properties:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common70:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common71:{default:!0,type:"boolean"},common72:{required:["text"]},common73:{required:["mediaImg"]},common74:{required:["mediaFile"]},common75:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common76:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},common77:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common78:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},common79:{additionalProperties:!1,patternProperties:{"^[0-9]+$":{additionalProperties:!1,properties:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"}},type:"object"},common80:{"^[0-9]+$":{additionalProperties:!1,properties:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"}},common81:{additionalProperties:!1,properties:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},required:["id","name","slug","type","value","count"],type:"object"},common82:{count:{type:"number"},id:{type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common83:{default:"public",enum:["public","private","restricted"],type:"string"},common84:{const:"news",default:"news",type:"string"},common85:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common86:{default:!1,type:"boolean"},common87:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common88:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},common89:{default:"news",enum:["news"],type:"string"},common90:{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"},common91:{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"},common92:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common93:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common94:{const:!1,default:!1,type:"boolean"},common95:{const:"",default:"",type:"string"},common96:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common97:{indexMax:{type:"number"},indexMin:{type:"number"}},common98:{default:0,minimum:0,type:"integer"},common99:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common100:{enum:["projects"],type:"string"},common101:{$exists:!0},common102:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common103:{$exists:{const:!0}},common104:{const:!0},common105:{default:30,type:"integer"},common106:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common107:{enum:["poi"],type:"string"},common108:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common109:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},common110:{$exists:!1},common111:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common112:{$exists:{const:!1}},common113:{const:!1},common114:{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"},common115:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common116:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common117:{$exists:{default:!1,type:"boolean"}},common118:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common119:{$in:{items:{type:"string"},minItems:1,type:"array"}},common120:{items:{type:"string"},minItems:1,type:"array"},common121:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common122:{enum:["citoyens"],type:"string"},common123:{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"},common124:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},common125:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common126:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common127:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common128:{"^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"}},common129:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common130:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common131:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common132:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common133:{enum:["badges"],type:"string"},common134:{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"},common135:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common136:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common137:{$exists:{const:!0,type:"boolean"}},common138:{const:!0,type:"boolean"},common139:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common140:{$exists:{const:!1,type:"boolean"}},common141:{const:!1,type:"boolean"},common142:{"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"}},common143:{indexMax:30,indexMin:0},common144:{additionalProperties:!1,allOf:[{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},{if:{properties:{parentType:{const:"events"}}},then:{properties:{connectType:{const:"attendee",default:"attendee"}}}}],properties:{childId:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},childType:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},connectType:{enum:["admin","member","contributor","attendee","friend"],type:"string"},parentId:{pattern:"^[a-f0-9]{24}$",type:"string"},parentType:{enum:["citoyens","organizations","projects","events"],type:"string"}},required:["childId","childType","parentType","parentId","connectType"],type:"object"},common145:{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},common146:{properties:{connectType:{const:"friend",default:"friend"}}},common147:{connectType:{const:"friend",default:"friend"}},common148:{const:"friend",default:"friend"},common149:{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},common150:{properties:{parentType:{const:"organizations"}}},common151:{parentType:{const:"organizations"}},common152:{properties:{connectType:{enum:["admin","member"]}}},common153:{connectType:{enum:["admin","member"]}},common154:{enum:["admin","member"]},common155:{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},common156:{properties:{parentType:{const:"projects"}}},common157:{parentType:{const:"projects"}},common158:{properties:{connectType:{enum:["admin","contributor"]}}},common159:{connectType:{enum:["admin","contributor"]}},common160:{enum:["admin","contributor"]},common161:{if:{properties:{parentType:{const:"events"}}},then:{properties:{connectType:{const:"attendee",default:"attendee"}}}},common162:{properties:{parentType:{const:"events"}}},common163:{parentType:{const:"events"}},common164:{const:"events"},common165:{properties:{connectType:{const:"attendee",default:"attendee"}}},common166:{connectType:{const:"attendee",default:"attendee"}},common167:{const:"attendee",default:"attendee"},common168:{childId:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},childType:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},connectType:{enum:["admin","member","contributor","attendee","friend"],type:"string"},parentId:{pattern:"^[a-f0-9]{24}$",type:"string"},parentType:{enum:["citoyens","organizations","projects","events"],type:"string"}},common169:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common170:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common171:{enum:["admin","member","contributor","attendee","friend"],type:"string"},common172:{enum:["citoyens","organizations","projects","events"],type:"string"}},rt=[{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:it.common1,email:it.common2,isInvitation:it.common3,mode:it.common1,name:it.common1,pendingUserId:it.common1,pwd:it.common1,username:it.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:it.common2,password:it.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:it.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:it.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:it.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:it.common1,newPassword2:it.common1,oldPassword:it.common1,scope:{default:"",type:["string"]},userId:it.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:it.common6,postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:{additionalProperties:!1,properties:{reason:it.common8},required:["reason"],type:"object"}},{auth:"bearer",constant:"UPDATE_SETTINGS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatesettings",request:{additionalProperties:!1,allOf:[{else:{properties:{idEntity:it.common9}},if:{properties:{typeEntity:it.common10}},then:{properties:{idEntity:it.common5}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:it.common10}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:it.common10}},then:it.common11},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:it.common10}}},then:it.common11}],properties:{idEntity:it.common1,type:it.common1,typeEntity:it.common13,value:it.common14},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:[it.common15,{anyOf:[{properties:{description:it.common21},required:["description"]},{properties:{shortDescription:it.common21},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:it.common8,description:it.common1,id:it.common1,scope:{default:"",type:["string","null"]},shortDescription:it.common1,typeElement:it.common13},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:it.common2,name:it.common1,tags:it.common23,url:it.common4}},allOf:[{if:it.common18,then:{additionalProperties:!1,anyOf:[it.common26,{properties:{birthDate:it.common21},required:["birthDate"]},{properties:{fixe:it.common21},required:["fixe"]},{properties:{mobile:it.common21},required:["mobile"]},it.common28,it.common30,it.common32],properties:{birthDate:{format:"date",type:"string"},block:it.common34,email:it.common35,fixe:it.common1,id:it.common5,mobile:it.common1,name:it.common36,scope:it.common8,tags:it.common37,typeElement:it.common13,url:it.common38}}},{if:{properties:{typeElement:it.common39}},then:{additionalProperties:!1,anyOf:[it.common26,it.common28,it.common30,it.common32,{properties:{avancement:it.common21},required:["avancement"]},{properties:{parent:it.common21},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:it.common34,email:it.common35,id:it.common1,name:it.common36,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":{additionalProperties:!1,properties:{name:it.common1,type:it.common1},required:["type","name"],type:"object"}},type:"object"},scope:it.common8,tags:it.common37,typeElement:it.common13,url:it.common38}}},{if:{properties:{typeElement:it.common40}},then:{additionalProperties:!1,anyOf:[it.common26,it.common28,it.common30,it.common32,{properties:{type:it.common21},required:["type"]}],properties:{block:it.common34,email:it.common35,id:it.common1,name:it.common36,scope:it.common8,tags:it.common37,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:it.common13,url:it.common38}}}],properties:{block:it.common34,id:it.common1,scope:it.common8,typeElement:it.common13},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:[it.common25,it.common4]}},allOf:[it.common15,{anyOf:[{properties:{gitlab:it.common21},required:["gitlab"]},{properties:{github:it.common21},required:["github"]},{properties:{twitter:it.common21},required:["twitter"]},{properties:{facebook:it.common21},required:["facebook"]},{properties:{instagram:it.common21},required:["instagram"]},{properties:{diaspora:it.common21},required:["diaspora"]},{properties:{mastodon:it.common21},required:["mastodon"]},{properties:{telegram:it.common21},required:["telegram"]},{properties:{signal:it.common21},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:it.common41,facebook:it.common41,github:it.common41,gitlab:it.common41,id:it.common1,instagram:it.common41,mastodon:it.common41,scope:it.common8,signal:it.common41,telegram:it.common41,twitter:it.common41,typeElement:it.common13},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:it.common42,if:it.common18,properties:{address:{additionalProperties:!1,properties:{"@type":{const:"PostalAddress",type:"string"},addressCountry:it.common1,addressLocality:it.common1,codeInsee:it.common1,level1:it.common1,level1Name:it.common1,level3:it.common45,level3Name:it.common45,level4:it.common45,level4Name:it.common45,localityId:it.common1,postalCode:it.common1,streetAddress:it.common1},required:["@type","addressCountry","codeInsee","addressLocality","localityId","level1","level1Name"],type:"object"},block:{const:"localities",default:"localities",type:"string"},geo:{additionalProperties:!1,properties:{"@type":{const:"GeoCoordinates",type:"string"},latitude:it.common46,longitude:it.common46},required:["latitude","longitude"],type:"object"},geoPosition:{additionalProperties:!0,properties:{coordinates:{items:it.common47,maxItems:2,minItems:2,type:"array"},float:it.common48,type:{const:"Point",type:"string"}},required:["type","coordinates","float"],type:"object"},id:it.common1,scope:it.common8,typeElement:it.common13},required:["block","typeElement","id","address"],then:it.common49,type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:it.common42,if:it.common18,properties:{block:it.common34,id:it.common1,scope:it.common8,slug:it.common52,typeElement:it.common13},required:["block","typeElement","id","slug"],then:it.common49,type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,else:it.common42,if:it.common53,properties:{block:it.common34,id:it.common1,slug:it.common52,type:it.common13},required:["block","type","id","slug"],then:it.common49,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:it.common55,request:{additionalProperties:!1,properties:{profil_avatar:it.common14},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:it.common63,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:it.common65,if:it.common67,properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:it.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:it.common1,parentType:it.common13},required:["parentId","parentType","listInvite"],then:it.common69,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:it.common42,if:it.common53,properties:{id:it.common1,isLive:it.common71,type:it.common13},required:["isLive","type","id"],then:it.common49,type:"object"},request:{additionalProperties:!1,properties:{dateLimit:{default:0,type:"integer"},indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:it.common8},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:it.common9,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:[it.common72,it.common73,it.common74],else:it.common65,if:it.common67,properties:{json:it.common48,markdownActive:it.common71,mediaFile:it.common75,mediaImg:it.common77,mentions:it.common79,parentId:it.common1,parentType:it.common13,scope:it.common83,tags:it.common23,text:it.common1,type:it.common84},required:["scope","markdownActive","parentId","parentType","type","json"],then:it.common69,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:it.common55,request:{additionalProperties:!1,properties:{newsImage:it.common14},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:it.common55,request:{additionalProperties:!1,properties:{newsFile:it.common14},required:["newsFile"],type:"object"}},{auth:"bearer",constant:"DELETE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/delete/id/{id}",pathParams:it.common85,request:{additionalProperties:!1,properties:{isLive:it.common86},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:[it.common72,it.common73,it.common74],else:it.common65,if:it.common67,properties:{idNews:it.common9,markdownActive:it.common71,mediaFile:it.common75,mediaImg:it.common77,mentions:it.common79,parentId:it.common1,parentType:it.common13,scope:it.common83,tags:it.common23,text:it.common1,type:it.common84},required:["idNews","scope","markdownActive","parentId","parentType","type"],then:it.common69,type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:{properties:{childId:it.common44}},if:{properties:{childType:it.common10}},properties:{childId:it.common9,childType:it.common13,comment:it.common1,connectType:{const:"share",default:"share",type:"string"},parentId:it.common9,parentType:it.common84},required:["parentId","parentType","childId","childType","connectType"],then:{properties:{childId:it.common51}},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:it.common87},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:it.common8,contextId:it.common9,contextType:it.common89,mentions:it.common90,parentCommentId:it.common9,path:it.common8,text:it.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:it.common85},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:it.common9,params:{properties:{mentions:it.common90,text:it.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:it.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:it.common87},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:it.common48,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:it.common93,type:"array"},fediverse:it.common94,filters:it.common95,indexMin:{const:0,default:0,type:"number"},indexStep:it.common47,initType:it.common95,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:it.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:it.common1,notSourceKey:it.common48,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":it.common96},type:"object"},searchTags:it.common24,searchType:{items:it.common93,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:it.common95,name:it.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:it.common98,name:it.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:it.common48,countType:it.common99,fediverse:it.common94,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":it.common101,"parent.@userId":it.common101},"links.contributors.@userId":it.common101},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":it.common102},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":it.common102,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":it.common102},type:"object"}},required:["$or"],type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common99},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:it.common63,request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common99,fediverse:it.common94,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":it.common101,"parent.@{pathParams.id}":it.common101},"links.contributors.@{pathParams.id}":it.common101},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102},type:"object"}},required:["$or"],type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common99},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:it.common48,countType:it.common106,fediverse:it.common94,filters:{additionalProperties:!1,default:{"parent.@userId":it.common101},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":it.common102},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common106},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:it.common63,request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common106,fediverse:it.common94,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":it.common101},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common106},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:it.common48,countType:it.common108,fediverse:it.common94,filters:{additionalProperties:!1,default:{"links.members.@userId":it.common101,"links.members.@userId.isInviting":it.common110,"links.members.@userId.toBeValidated":it.common110},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":it.common102,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":it.common111,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":it.common111},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common108},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:it.common42,if:it.common53,properties:{id:it.common1,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],then:it.common49,type:"object"},request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common108,fediverse:it.common94,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":it.common101,"links.members.@{pathParams.id}.isInviting":it.common110,"links.members.@{pathParams.id}.toBeValidated":it.common110},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":it.common111,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":it.common111},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common108},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:it.common48,countType:it.common114,fediverse:it.common94,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+)$":it.common102,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":it.common102,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":it.common116,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":it.common118,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":it.common111},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common114},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:it.common85,request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common114,fediverse:it.common94,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}":it.common101,"links.memberOf.@{pathParams.id}.isInviting":it.common110,"links.memberOf.@{pathParams.id}.toBeValidated":it.common110},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":it.common102,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":it.common116,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":it.common118,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":it.common116},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common114},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:it.common6,request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common121,fediverse:it.common94,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}":it.common101,"links.friends.@{pathParams.id}.isInviting":it.common110,"links.friends.@{pathParams.id}.toBeValidated":it.common110},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":it.common116,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":it.common116},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common121},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:it.common48,countType:it.common123,fediverse:it.common94,filters:{additionalProperties:!1,allOf:[it.common125],default:{"links.followers.@userId":it.common101,"links.followers.@{userId}.isInviting":it.common110,"links.followers.@{userId}.toBeValidated":it.common110},patternProperties:it.common128,type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common123},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:it.common6,request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common123,fediverse:it.common94,filters:{additionalProperties:!1,allOf:[it.common125],default:{"links.followers.@{pathParams.id}":it.common101,"links.followers.@{pathParams.id}.isInviting":it.common110,"links.followers.@{pathParams.id}.toBeValidated":it.common110},patternProperties:it.common128,type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common123},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:it.common48,countType:it.common121,fediverse:it.common94,filters:{additionalProperties:!1,allOf:[it.common129],default:{"links.follows.@userId":it.common101,"links.follows.@{userId}.isInviting":it.common110,"links.follows.@{userId}.toBeValidated":it.common110},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":it.common111,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":it.common111},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common121},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:it.common42,if:it.common53,then:it.common49}],properties:{id:it.common1,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common121,fediverse:it.common94,filters:{additionalProperties:!1,allOf:[it.common129],default:{"links.follows.@{pathParams.id}":it.common101},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common121},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_CONTRIBUTORS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common114,fediverse:it.common94,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+)$":it.common102,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":it.common102,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":it.common116,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":it.common118,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":it.common111},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common114},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:it.common85,request:{additionalProperties:!1,properties:{count:it.common48,countType:it.common114,fediverse:it.common94,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}":it.common101,"links.projects.@{pathParams.id}.isInviting":it.common110,"links.projects.@{pathParams.id}.toBeValidated":it.common110},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":it.common102,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":it.common102,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":it.common116,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":it.common118,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":it.common116},type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common114},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:it.common48,countType:it.common132,fediverse:it.common94,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":it.common102},type:"object"},isParcours:it.common3,"preferences.private":it.common94},required:["preferences.private"],type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,searchType:it.common132},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:it.common48,countType:it.common134,fediverse:it.common94,fields:it.common132,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":it.common136}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":it.common136,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":it.common139,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":it.common139}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:it.common142},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:it.common142,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":it.common138}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":it.common136}}],type:"object"},indexMin:it.common98,indexStep:it.common105,initType:it.common95,locality:it.common95,name:it.common1,notSourceKey:it.common48,ranges:{additionalProperties:!1,default:{Cooperative:it.common143,GovernmentOrganization:it.common143,Group:it.common143,LocalBusiness:it.common143,NGO:it.common143,citoyens:it.common143,projects:it.common143},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":it.common96},type:"object"},searchType:it.common134},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:it.common144},{auth:"bearer",constant:"DISCONNECT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/link/disconnect",request:it.common144},{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"}}];Xe.default.addType("oid",(e=>new nt.ObjectID(e)));class at extends Fe.EventEmitter{constructor({baseURL:e,accessToken:t,refreshToken:o,refreshUrl:n="/api/cocolight/refreshtoken",endpoints:i=rt,timeout:r=3e4,debug:a=!1,maxRetries:s=0,circuitBreakerThreshold:c=5,circuitBreakerResetTime:m=6e4,fromJSONValue:p=!0}={}){if(super(),!e)throw new u('Le paramètre "baseURL" est obligatoire.',500);this._baseURL=e,this._refreshToken=o,this._refreshUrl=n,this._endpoints=i,this._debug=a;let l=null;this._fromJSONValue=p,Object.defineProperty(this,"userId",{get:()=>l,set:()=>{throw new Error("Modification directe de userId non autorisée.")},enumerable:!0}),this._setUserId=e=>{l=e,this._logger.debug(`[ApiClient] userId set: ${e}`)},this._ajv=new Je.default({strict:!1,useDefaults:!0,allErrors:!0,verbose:!0}),(0,He.default)(this._ajv),this._logger=(0,tt.default)({transport:{target:"pino-pretty",options:{colorize:!0}},level:a?"debug":"info"}),this._client=Ye.default.create({baseURL:e,timeout:r}),s>0&&((0,Qe.default)(this._client,{retries:s,retryDelay:Qe.default.exponentialDelay,retryCondition:e=>Qe.default.isNetworkError(e)||Qe.default.isRetryableError(e)}),this._logger.info(`[ApiClient] Retry activé : ${s} max`)),this._breakerThreshold=c,this._breakerResetTime=m,this._breakerErrorCount=0,this._breakerOpen=!1,this._lastBreakerOpenTime=null,t&&this.setToken(t),this._client.interceptors.response.use((e=>e),(async e=>{if(e.response&&401===e.response.status&&this._refreshToken)try{if(await this._refreshAccessToken())return this._client.request(e.config)}catch(e){throw new u(e.message,401,e)}throw e}))}setToken(e){this._accessToken=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){this._refreshToken=e;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=function(e,t){if("string"!=typeof e)throw new et("Invalid token specified: must be a string");t||(t={});const o=!0===t.header?0:1,n=e.split(".")[o];if("string"!=typeof n)throw new et(`Invalid token specified: missing part #${o+1}`);let i;try{i=function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let o=t.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o})))}(t)}catch(e){return atob(t)}}(n)}catch(e){throw new et(`Invalid token specified: invalid base64 for part #${o+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new et(`Invalid token specified: invalid json for part #${o+1} (${e.message})`)}}(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;try{const e=await this._client.post(this._refreshUrl,{refreshToken:this._refreshToken},{headers:{"Content-Type":"application/json"}});return!(!e.data||!e.data.accessToken||(this.setToken(e.data.accessToken),e.data.refreshToken&&this.setRefreshToken(e.data.refreshToken),this.emit("refreshSuccess",e.data),0))}catch(e){return this.resetSession(),this._logger.error(`[ApiClient] Refresh Error : ${e.message}`),!1}}_checkCircuitBreaker(){return!this._breakerOpen||Date.now()-this._lastBreakerOpenTime>this._breakerResetTime&&(this._breakerOpen=!1,this._breakerErrorCount=0,this._logger.warn("[ApiClient] Circuit breaker réinitialisé"),!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"))}_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]&&at.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]&&at.stripNullsInPlace(e[t]));return e}_resolveSpecialValuesInPlace(e,t={}){const o={userId:()=>this.userId,accessToken:()=>this._accessToken,refreshToken:()=>this._refreshToken,baseURL:()=>this._baseURL,pathParams:e=>{const o=this._getValueByPath(t,e);return null!=o?o:void 0}},n=/@(?:\{([^}]+)\}|([\w.]+))/g,i=e=>"string"!=typeof e?e:e.replace(n,((t,n,i)=>{if(n){if(n.startsWith("pathParams.")){const e=n.substring(11),t=o.pathParams(e);return null!=t?t:`@{${n}}`}{const e=o[n];if("function"==typeof e){const t=e();return null!=t?t:`@{${n}}`}return`@{${n}}`}}if(i){if(i.startsWith("pathParams.")){const e=i.match(/^pathParams\.([^.]+)(.*)$/);if(e){const t=e[1],n=e[2],r=o.pathParams(t);return null!=r?r+n:`@${i}`}return`@${i}`}{const e=o[i];if("function"==typeof e){const t=e();return null!=t?t:`@${i}`}return`@${i}`}}return e})),r=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(r);if((e=>"[object Object]"===Object.prototype.toString.call(e))(e)){const t={};for(const[o,n]of Object.entries(e))t[i(o)]=r(n);return t}return"string"==typeof e?i(e):e};return r(e)}_cleanSchemaLeftoverAlias(e){const t=/@\w+/;if(Array.isArray(e))return e.map((e=>this._cleanSchemaLeftoverAlias(e)));if(e&&"object"==typeof e){const o={};for(const n of Object.keys(e)){const i=e[n];if(!t.test(n)){if("default"===n){if("string"==typeof i&&t.test(i))continue;if(i&&"object"==typeof i){const e=this._cleanSchemaLeftoverAlias(i);Object.keys(e).length>0&&(o[n]=e);continue}}"string"==typeof i&&t.test(i)||(o[n]=this._cleanSchemaLeftoverAlias(i))}}return o}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={},o=!0,n=!0){if(!this._checkCircuitBreaker())throw new h("Le circuit breaker est activé, impossible d'appeler l'API");const i=this._endpoints.find((t=>t.constant===e));if(!i)throw new u(`Endpoint introuvable : ${e}`,404);const{path:r,method:a,contentType:s,auth:c,pathParams:m,request:p,responses:l}=i,d=(a||"GET").toLowerCase(),y=s||"application/json",g={"Content-Type":y};if(this._accessToken)"bearer"===c?g.Authorization=`Bearer ${this._accessToken}`:c&&"none"!==c||g.Authorization||(g.Authorization=`Bearer ${this._accessToken}`);else if("bearer"===c)throw new u(`Token requis pour l'endpoint sécurisé : ${e}`,401);let w,b=r,x={};if(m){let e=m;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(m));const o=t.pathParams||{},n=this._ajv.compile(e);if(!n(o)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"pathParams",errors:n.errors}),new f("Path parameter validation failed.",400,e,n.errors)}x=this._resolveSpecialValuesInPlace(o),b=b.replace(/\{(\w+)\}/g,((e,t)=>{const o=x[t];if(void 0!==o)return encodeURIComponent(o);throw new u(`Path param manquant ou non résolu : {${t}}`,400)}))}if(p){let e=p;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(p));const o={...t};delete o.pathParams;const n=at.stripNullsInPlace(o),i=this._ajv.compile(e);if(!i(n)){const e=this._ajvErrorHuman(i.errors);throw this.emit("validationError",{stage:"request",errors:i.errors}),new f("Request validation failed.",400,e,i.errors)}t=this._resolveSpecialValuesInPlace(n,x)}"application/json"===y||"multipart/form-data"===y?w=t:"application/x-www-form-urlencoded"===y&&(w=at.toURLSearchParams(t)),this._logger.debug(`[ApiClient] callEndpoint: ${e} -> ${b}, method=${d}`);try{const e=await this._client.request({url:b,method:d,headers:g,["get"===d?"params":"data"]:w});if(n){const t=e.status.toString(),o=l?.[t];if(o){const n=this._ajv.compile(o);if(!n(e.data)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"response",errors:n.errors}),new f("Response validation failed.",t,e,n.errors)}}}return this._resetCircuitBreakerSuccess(),"function"==typeof o?e.data=o(e.data):!0===o&&(e.data=this._transformData(e.data)),Array.isArray(i.postActions)&&i.postActions.forEach((t=>{const o=t.path?this._getValueByPath(e.data,t.path):null;switch(t.type){case"setToken":this.setToken(o);break;case"setRefreshToken":this.setRefreshToken(o);break;case"resetSession":this.resetSession();break;case"emitEvent":t.event&&(this.emit(t.event,o),this._logger.debug(`[ApiClient] Event émis : ${t.event}`,o));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}`),new u(`Erreur lors de l'appel de l'API : ${t.message}`,t.response?t.response.status:500,t.response?t.response.data:null)}}_ajvErrorHuman(e){return new We(e).errors.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 y(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 y(t.resultErrors.msg||"Erreur inconnue",e.status,t);return e}resetSession(){this.setToken(null),this.setRefreshToken(null),this._setUserId(null),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 t.split(".").reduce(((e,t)=>e&&e[t]),e)}static toURLSearchParams(e,t={}){return this._buildParams(e,new URLSearchParams,t)}static _buildParams(e,t,o={}){if("object"!=typeof e||null===e)throw new TypeError("La donnée doit être un objet non nul.");const{dots:n=!1,indexes:i=!1,metaTokens:r=!0}=o,a=[];function s(e){return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)}function c(e){return e.endsWith("[]")?e.slice(0,-2):e}function m(e,t,o=!1){return e?e.concat(t).map(((e,t)=>(e=c(e),!o&&t?`[${e}]`:e))).join(o?".":""):t}function p(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(o,l=[]){null==o||a.includes(o)||(a.push(o),Object.entries(o).forEach((([o,a])=>{void 0!==a&&function(e,o,a){if(e&&"object"==typeof e){if(o.endsWith("{}"))return o=r?o:o.slice(0,-2),t.append(m(a,o,n),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(s)||o.endsWith("[]"))return o=c(o),e.forEach(((e,r)=>{if(null!=e){const s=i?m(a.concat(o),r,n):`${m(a,o,n)}[]`;t.append(s,p(e))}})),!1}return!!s(e)||(t.append(m(a,o,n),p(e)),!1)}(a,o.trim(),l)&&e(a,l.concat(c(o)))})),a.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?Xe.default.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"];_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((o=>{let n=this._normalizeRecursively(e[o]);this._dateFields.includes(o)&&(n=this._normalizeDate(n)),this._imageFields.includes(o)&&(n=this._normalizeImage(n)),"content"===o&&n&&"object"==typeof n&&n.image&&(n.image=this._normalizeImage(n.image)),t[o]=n})),this._normalizeId(t)}return e}}class st{constructor(e){this.client=new at(e),this.loggedUser=null}async login(e,t){return this.client.safeCall((async()=>{const o=await this.client.callEndpoint("AUTHENTICATE_URL",{email:e,password:t});return this.loggedUser=new Le(this.client,{id:o.data.user.id},o.data.user),this.loggedUser}))}async register({name:e,username:t,email:o,pwd:n}={}){return this.client.safeCall((async()=>{const i=await this.client.callEndpoint("PERSON_REGISTER",{name:e,username:t,email:o,pwd:n});if(!1===i?.data?.result)throw new y(i.data.msg,i.status,i.data);return i.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 y(t.data.msg,t.status,t.data);return t.data}))}}class ct{static async userLogin(e,t,o){const n=ct.userApi(o);return await ct.userApiLogin(n,e,t)}static userApi(e){try{return new st(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,o){try{const n=await e.login(t,o);return new ct(n,e.client)}catch(e){if(e instanceof u&&e?.details?.error)throw new g(e.details.error,e.status,e.details);throw e}}constructor(e,t){this._loggedUser=e,this._client=t}me(){if(!this._loggedUser)throw new g("Accès refusé : utilisateur non authentifié.");return this._loggedUser}user(e){try{return new Le(this._client,e)}catch(e){throw console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :",e.message),e}}async organization(e,t={getProfile:!0}){try{const o=new Ne(this._client,e);return t.getProfile&&await o.getProfil(),o}catch(e){throw console.error("[Api.organization] Erreur lors de la création d'un objet organisation :",e.message),e}}async project(e,t={getProfile:!0}){try{const o=new Me(this._client,e);return t.getProfile&&await o.getProfil(),o}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}}const mt={ApiClient:at,Api:ct,error:l};var pt=p.A;export{pt as default};
|
|
1
|
+
import*as e from"stream";import*as t from"file-type";import*as o from"events";import*as n from"@segment/ajv-human-errors";import*as r from"ajv";import*as i from"ajv-formats";import*as s from"axios";import*as a from"axios-retry";import*as c from"ejson";import*as p from"jwt-decode";import*as m from"pino";var d,l,u={702:(t,o,n)=>{var r,i;t.exports=(r={PassThrough:()=>e.PassThrough,Readable:()=>e.Readable},i={},n.d(i,r),i)}},y={};function h(e){var t=y[e];if(void 0!==t)return t.exports;var o=y[e]={exports:{}};return u[e](o,o.exports,h),o.exports}h.m=u,h.d=(e,t)=>{for(var o in t)h.o(t,o)&&!h.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},h.f={},h.e=e=>Promise.all(Object.keys(h.f).reduce(((t,o)=>(h.f[o](e,t),t)),[])),h.u=e=>e+".cocolight-api-client.mjs.js",h.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),h.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d={792:0},l=e=>{var t,o,{__webpack_ids__:n,__webpack_modules__:r,__webpack_runtime__:i}=e,s=0;for(t in r)h.o(r,t)&&(h.m[t]=r[t]);for(i&&i(h);s<n.length;s++)o=n[s],h.o(d,o)&&d[o]&&d[o][0](),d[n[s]]=0},h.f.j=(e,t)=>{var o=h.o(d,e)?d[e]:void 0;if(0!==o)if(o)t.push(o[1]);else{var n=import("./"+h.u(e)).then(l,(t=>{throw 0!==d[e]&&(d[e]=void 0),t}));n=Promise.race([n,new Promise((t=>o=d[e]=[t]))]),t.push(o[1]=n)}};var f={};h.d(f,{A:()=>Y});var g={};h.r(g),h.d(g,{ApiAuthenticationError:()=>P,ApiClientError:()=>T,ApiError:()=>w,ApiResponseError:()=>_,ApiValidationError:()=>b,CircuitBreakerError:()=>E});class w extends Error{constructor(e,t,o){super(e),this.name="ApiError",this.status=t,this.details=o}}class T extends w{constructor(e,t,o){super(e,t,o),this.name="ApiClientError"}}class b extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiValidationError",this.status=t,this.messages=o,this.details=n}}class E extends w{constructor(e){super(e,503),this.name="CircuitBreakerError"}}class _ extends Error{constructor(e,t,o,n=null){super(e),this.name="ApiResponseError",this.status=t,this.responseData=o,this.details=n}}class P extends w{constructor(e,t,o){super(e,t,o),this.name="ApiAuthenticationError"}}const A=class{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 o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))}async callNoConnected(e,t={}){if(this.isConnected)throw new P("Vous ne devez pas être connecté pour faire cette action.");return this.call(e,t)}async callIsConnected(e,t={}){if(!this.isConnected)throw new P("Vous devez être connecté pour effectuer cette action.");return this.call(e,t)}async personRegister(e={}){return this.callNoConnected("PERSON_REGISTER",e)}async authenticateUrl(e={}){return this.callNoConnected("AUTHENTICATE_URL",e)}async refreshTokenUrl(e={}){return this.call("REFRESH_TOKEN_URL",e)}async meInfoUrl(e={}){return this.callIsConnected("ME_INFO_URL",e)}async passwordRecovery(e={}){return this.callNoConnected("PASSWORD_RECOVERY",e)}async serverExchangeToken(e={}){return this.callIsConnected("SERVER_EXCHANGE_TOKEN",e)}async changePassword(e={}){return this.callIsConnected("CHANGE_PASSWORD",e)}async deleteAccount(e={}){return this.callIsConnected("DELETE_ACCOUNT",e)}async updateSettings(e={}){return this.callIsConnected("UPDATE_SETTINGS",e)}async updateBlockDescription(e={}){return this.callIsConnected("UPDATE_BLOCK_DESCRIPTION",e)}async updateBlockInfo(e={}){return this.callIsConnected("UPDATE_BLOCK_INFO",e)}async updateBlockSocial(e={}){return this.callIsConnected("UPDATE_BLOCK_SOCIAL",e)}async updateBlockLocality(e={}){return this.callIsConnected("UPDATE_BLOCK_LOCALITY",e)}async updateBlockSlug(e={}){return this.callIsConnected("UPDATE_BLOCK_SLUG",e)}async check(e={}){return this.callIsConnected("CHECK",e)}async profilImage(e={}){return this.callIsConnected("PROFIL_IMAGE",e)}async getElementsAbout(e={}){return this.call("GET_ELEMENTS_ABOUT",e)}async multiconnect(e={}){return this.callIsConnected("MULTICONNECT",e)}async getNews(e={}){return this.call("GET_NEWS",e)}async getNewsById(e={}){return this.call("GET_NEWS_BY_ID",e)}async addNews(e={}){return this.callIsConnected("ADD_NEWS",e)}async addImageNews(e={}){return this.callIsConnected("ADD_IMAGE_NEWS",e)}async addFileNews(e={}){return this.callIsConnected("ADD_FILE_NEWS",e)}async deleteNews(e={}){return this.callIsConnected("DELETE_NEWS",e)}async updateNews(e={}){return this.callIsConnected("UPDATE_NEWS",e)}async shareNews(e={}){return this.callIsConnected("SHARE_NEWS",e)}async getComments(e={}){return this.call("GET_COMMENTS",e)}async addComments(e={}){return this.callIsConnected("ADD_COMMENTS",e)}async deleteComments(e={}){return this.callIsConnected("DELETE_COMMENTS",e)}async updateComments(e={}){return this.callIsConnected("UPDATE_COMMENTS",e)}async searchTags(e={}){return this.call("SEARCH_TAGS",e)}async showVote(e={}){return this.call("SHOW_VOTE",e)}async globalAutocomplete(e={}){return this.call("GLOBAL_AUTOCOMPLETE",e)}async cityAutocomplete(e={}){return this.call("CITY_AUTOCOMPLETE",e)}async suggestionInput(e={}){return this.call("SUGGESTION_INPUT",e)}async getProjectsNoAdmin(e={}){return this.call("GET_PROJECTS_NO_ADMIN",e)}async getProjectsAdmin(e={}){return this.callIsConnected("GET_PROJECTS_ADMIN",e)}async getPoisNoAdmin(e={}){return this.call("GET_POIS_NO_ADMIN",e)}async getPoisAdmin(e={}){return this.callIsConnected("GET_POIS_ADMIN",e)}async getOrganizationsNoAdmin(e={}){return this.call("GET_ORGANIZATIONS_NO_ADMIN",e)}async getOrganizationsAdmin(e={}){return this.callIsConnected("GET_ORGANIZATIONS_ADMIN",e)}async getMembersNoAdmin(e={}){return this.call("GET_MEMBERS_NO_ADMIN",e)}async getMembersAdmin(e={}){return this.callIsConnected("GET_MEMBERS_ADMIN",e)}async getFriendsAdmin(e={}){return this.callIsConnected("GET_FRIENDS_ADMIN",e)}async getSubscriptions(e={}){return this.call("GET_SUBSCRIPTIONS",e)}async getSubscriptionsAdmin(e={}){return this.callIsConnected("GET_SUBSCRIPTIONS_ADMIN",e)}async getSubscribers(e={}){return this.call("GET_SUBSCRIBERS",e)}async getSubscribersAdmin(e={}){return this.callIsConnected("GET_SUBSCRIBERS_ADMIN",e)}async getContributors(e={}){return this.call("GET_CONTRIBUTORS",e)}async getContributorsAdmin(e={}){return this.callIsConnected("GET_CONTRIBUTORS_ADMIN",e)}async getBadges(e={}){return this.call("GET_BADGES",e)}async getBadgesFilters(e={}){return this.call("GET_BADGES_FILTERS",e)}async connect(e={}){return this.callIsConnected("CONNECT",e)}async disconnect(e={}){return this.callIsConnected("DISCONNECT",e)}async getElementsKey(e={}){return this.call("GET_ELEMENTS_KEY",e)}async getFavoris(e={}){return this.callIsConnected("GET_FAVORIS",e)}async deleteFavoris(e={}){return this.callIsConnected("DELETE_FAVORIS",e)}async addFavoris(e={}){return this.callIsConnected("ADD_FAVORIS",e)}async addOrganization(e={}){return this.callIsConnected("ADD_ORGANIZATION",e)}async addProject(e={}){return this.callIsConnected("ADD_PROJECT",e)}async addPoi(e={}){return this.callIsConnected("ADD_POI",e)}async addEvent(e={}){return this.callIsConnected("ADD_EVENT",e)}async deletePoi(e={}){return this.callIsConnected("DELETE_POI",e)}async deleteEvent(e={}){return this.callIsConnected("DELETE_EVENT",e)}async deleteElement(e={}){return this.callIsConnected("DELETE_ELEMENT",e)}async addImageElement(e={}){return this.callIsConnected("ADD_IMAGE_ELEMENT",e)}},I={},O=(S={fileTypeFromBuffer:()=>t.fileTypeFromBuffer},j={},h.d(j,S),j),v={async call(e,t={}){return this.apiClient.safeCall((async()=>{const o=await this.apiClient.callEndpoint(e,t);return this.apiClient.checkAndThrowApiResponseError(o),o.data}))},async callNoConnected(e,t={}){if(this.isConnected)throw new P("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 P("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 P("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:o="any"}){if(!e)throw new b("Le fichier est requis.");const n="undefined"==typeof window&&"undefined"!=typeof process;let r="",i=e;if("undefined"!=typeof File&&e instanceof File){if(r=e.type,!t.includes(r))throw new b("Le type du fichier est invalide.")}else if("undefined"!=typeof Blob&&e instanceof Blob){if(r=e.type,!t.includes(r))throw new b("Le type du fichier est invalide.");const o=r.split("/")[1]||"bin",n=`${Date.now()}.${o}`;i=new File([e],n,{type:r})}else if(n&&Buffer.isBuffer(e)){const n=await(0,O.fileTypeFromBuffer)(e);if(r=n?.mime,!n||!t.includes(r))throw new b("Le type du fichier est invalide.");if("image"===o){const t=n.ext,o=`${Date.now()}.${t}`;i=await this._createReadStreamFromBuffer(e,o,r)}}else{if(!n||!e?.readable||"function"!=typeof e._read)throw new b("Type de fichier non reconnu.");{const o=[],n=await this._passThrough(),s=await this._passThrough(),a=4100;let c=0;e.on("data",(e=>{c<a&&(o.push(e),c+=e.length)})),e.pipe(n).pipe(s),await new Promise((e=>setTimeout(e,10)));const p=Buffer.concat(o),m=await(0,O.fileTypeFromBuffer)(p);if(r=m?.mime,!m||!t.includes(r))throw new b("Le type du fichier est invalide.");s.path=`${Date.now()}.${m.ext}`,s.mimeType=r,i=s}}return i},async _createReadStreamFromBuffer(e,t="file.bin",o="application/octet-stream"){const n=await this._bufferToReadable(e);return n.path=t,n.mimeType=o,n},async _bufferToReadable(e){if("undefined"==typeof window){const{bufferToReadable:t}=await h.e(22).then(h.bind(h,22));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 h.e(22).then(h.bind(h,22));return e()}throw new Error("passThrough ne doit pas être appelé dans le navigateur")},_omitProps(e,t){if(!e||"object"!=typeof e)return{};const o={...e};for(const e of t)delete o[e];return o},_pickProps(e,t,o={}){if(!e||"object"!=typeof e)return{};const n={};for(const r of t)if(r in e){const t=e[r];"function"==typeof o[r]?n[r]=o[r](t,e):n[r]=t}return n},_createFilteredProxy:e=>new Proxy(e,{get:(e,t,o)=>"string"!=typeof t||isNaN(t)?"length"===t?e.filter((e=>!e._isDeleted)).length:"function"==typeof e[t]?(...o)=>e.filter((e=>!e._isDeleted))[t](...o):Reflect.get(e,t,o):e.filter((e=>!e._isDeleted))[t]})};var S,j;class C{#e={};#t=null;constructor(e,t={},o={}){if(!o.EndpointApi)throw new w("EndpointApi class must be injected to avoid circular dependency.");if(!o.User)throw new w("User class must be injected to avoid circular dependency.");if(!e)throw new w("Parent is required.");if(this.deps=o,this.UserClass=o.User,this.apiClient=e.apiClient,"function"==typeof o.EndpointApi)this.endpointApi=new o.EndpointApi(this.apiClient);else{if("object"!=typeof o.EndpointApi)throw new w("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=o.EndpointApi}this.#e={...t},this.parent=e}get id(){return this.#e.id||null}get isConnected(){return this.apiClient.isConnected}get draftData(){return this.#e}get serverData(){return this.#t}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.parent.id}getEntityType(){return"news"}static fromServerData(e,t,o){const n=new C(t,{id:e.id},o);return n.#t={...e},n.#e=n._getDraftFromServerData(e),n}async refresh(){if(!this.id)throw new w("Impossible de rafraîchir sans ID.");return this.get()}async get(){if(!this.id)throw new w("Vous devez fournir un id pour récupérer une news.");const e=await this.callIsConnected((()=>this.endpointApi.getNewsById({ids:[this.id]})));if(e&&e.length>0)return this.#t=e[0],this.#e=this._getDraftFromServerData(this.#t),this.#t;throw new w(`Aucune actualité trouvée pour l'ID ${this.id}`)}_getDraftFromServerData(e){const t=this._pickProps(e,["scope","text","tags","mentions","mediaImg","mediaFile"],{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:parseInt(e.countImages)||t.length,images:t}:void 0},mediaFile:e=>{const t=e?.files?.map((e=>e.id)).filter(Boolean)||[];return t.length>0?{countFiles:parseInt(e.countFiles)||t.length,files:t}:void 0}});return{id:e.id,...Object.fromEntries(Object.entries(t).filter((([,e])=>void 0!==e)))}}async save(){""===this.#e?.text&&(this.#e.text=" ");const e={...this.#e};if(e.parentId=this.parent.id,e.parentType=this.parent.getEntityType(),this.id){e.id&&delete e.id;const t=await this.callIsConnected((()=>this.endpointApi.updateNews({...e,idNews:this.id})));return t?.object&&(this.#t={...t.object}),t}{const t=await this.callIsConnected((()=>this.endpointApi.addNews(e)));return this.#e.id=t.object.id,t?.object&&(this.#t={...t.object}),t}}async addMention({slug:e,id:t}){try{if(!e&&!t)throw new w("Vous devez fournir un slug ou un id pour ajouter une mention.");const o=new this.UserClass(this.apiClient,{id:t,slug:e},null,{EndpointApi:this.endpointApi}),n=await o.getProfil();if(this.#e.mentions||(this.#e.mentions=[]),this.#e.mentions.find((e=>e.id===n.id)))return this.#e.mentions=this.#e.mentions.map((e=>(e.id===n.id&&(e.count+=1),e))),this.#e.mentions;const r={id:n.id,slug:n.slug,type:o.getEntityType(),name:n.name,value:n.name,count:1};return this.#e.mentions.push(r),this.#e.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},o=await this.callIsConnected((()=>this.endpointApi.addImageNews(t)));return this.#e.mediaImg?(this.#e.mediaImg.countImages=this.#e.mediaImg.countImages+1,this.#e.mediaImg.images.push(o.id)):this.#e.mediaImg={countImages:1,images:[o.id]},o}async addFile(e){e=await this.validateFile(e);const t={pathParams:{folder:this.parent.getEntityType(),ownerId:this.parent.id},newsFile:e},o=await this.callIsConnected((()=>this.endpointApi.addFileNews(t)));return this.#e.mediaFile?(this.#e.mediaFile.countFiles=this.#e.mediaFile.countFiles+1,this.#e.mediaFile.files.push(o)):this.#e.mediaFile={countFiles:1,files:[o]},o}async delete(){if(!this.id)throw new w("Vous devez fournir un id pour supprimer une news.");const e={pathParams:{id:this.id}};await this.callIsConnected((()=>this.endpointApi.deleteNews(e))),this.#e={},this.#t=null,this.#e.id=null,this._isDeleted=!0}}Object.assign(C.prototype,v,I);const k={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 _(`Le slug ${this.slug} ne correspond pas à un ${e}`,200,t);this._id(t.contextId)}catch(t){throw t instanceof _?t?.responseData?.contextType!==e?t:new _(`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()}})}};class D{#o;#n;#r;constructor(e,{id:t,slug:o}={},n={},r={}){if(!r.EndpointApi)throw new Error("EndpointApi class must be injected to avoid circular dependency.");if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer un User.");if(this.apiClient=e,this.deps=r,"function"==typeof r.EndpointApi)this.endpointApi=new r.EndpointApi(this.apiClient);else{if("object"!=typeof r.EndpointApi)throw new Error("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=r.EndpointApi}this.#o=t||null,this.#n=o||null,this.#r=n}get id(){return this.#o}_id(e){this.#o=e}get slug(){return this.#n}_slug(e){this.#n=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#r}_setData(e){this.#r=e}getEntityType(){return"citoyens"}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}async getProfil(){return this.apiClient.safeCall((async()=>this.isMe?await this.endpointApi.meInfoUrl():await this.getPublicProfile()))}async changePassword(e={}){return this.callIsMe((()=>this.endpointApi.changePassword(e)))}async delete(e={}){return this.callIsMe((()=>this.endpointApi.deleteAccount(e)))}async updateSettings(e={}){return this.callIsMe((()=>this.endpointApi.updateSettings(e)))}async updateDescription(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockDescription(e)))}async updateInfo(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockInfo(e)))}async updateSocial(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockSocial(e)))}async updateLocality(e={}){return this.callIsMe((()=>this.endpointApi.updateBlockLocality(e)))}async updateSlug(e){try{await this.endpointApi.check({slug:e})}catch(e){if(e instanceof _)throw new _("Erreur lors de la vérification du slug.",e.status,e.data);throw e}return this.callIsMe((()=>this.endpointApi.updateBlockSlug({slug:e})))}async updateImageProfil(e){return e=await this.validateImage(e),this.callIsMe((()=>this.endpointApi.profilImage({profil_avatar:e})))}async getNews(e={}){e.pathParams&&delete e.pathParams,this.isMe||(e.pathParams={id:this.id});const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new _("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>C.fromServerData(e,this,{User:D,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)}async news(e={}){try{const t=new C(this,e,{User:D,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw console.error("[Api.user.news] Erreur lors de la création d'une instance news :",e.message),e}}}Object.assign(D.prototype,k,v,{},I);class x{#o;#n;#r=null;constructor(e,{id:t,slug:o}={},n={}){if(!n.EndpointApi)throw new Error("EndpointApi class must be injected to avoid circular dependency.");if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer une instance User.");if(this.apiClient=e,this.deps=n,"function"==typeof n.EndpointApi)this.endpointApi=new n.EndpointApi(this.apiClient);else{if("object"!=typeof n.EndpointApi)throw new Error("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=n.EndpointApi}this.#o=t||null,this.#n=o||null}get id(){return this.#o}_id(e){this.#o=e}get slug(){return this.#n}_slug(e){this.#n=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#r}_setData(e){this.#r=e}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}getEntityType(){return"organizations"}async getProfil(){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(e){try{await this.endpointApi.check({slug:e})}catch(e){if(e instanceof _)throw new _("Erreur lors de la vérification du slug.",e.status,e.data);throw e}const t={typeElement:this.getEntityType(),id:this.id,slug:e};return this.callIsConnected((()=>this.endpointApi.updateBlockSlug(t)))}async updateImageProfil(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 getNews(e={}){e.pathParams={type:this.getEntityType(),id:this.id};const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new _("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>C.fromServerData(e,this,{User:D,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)}async news(e){try{const t=new C(this,e,{User:D,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw console.error("[Api.project.news] Erreur lors de la création d'une instance news :",e.message),e}}}Object.assign(x.prototype,k,v,I);class ${#o;#n;#r=null;constructor(e,{id:t,slug:o}={},n={}){if(!n.EndpointApi)throw new Error("EndpointApi class must be injected to avoid circular dependency.");if(!t&&!o)throw new Error("Vous devez fournir un id ou un slug pour créer une instance Project.");if(this.apiClient=e,this.deps=n,"function"==typeof n.EndpointApi)this.endpointApi=new n.EndpointApi(this.apiClient);else{if("object"!=typeof n.EndpointApi)throw new Error("deps.EndpointApi doit être une classe ou une instance valide.");this.endpointApi=n.EndpointApi}this.#o=t||null,this.#n=o||null}get id(){return this.#o}_id(e){this.#o=e}get slug(){return this.#n}_slug(e){this.#n=e}get isConnected(){return this.apiClient.isConnected}get data(){return this.#r}_setData(e){this.#r=e}get userId(){return this.apiClient.userId}get isMe(){return this.isConnected&&this.userId===this.id}getEntityType(){return"projects"}async getProfil(){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(e){try{await this.endpointApi.check({slug:e})}catch(e){if(e instanceof _)throw new _("Erreur lors de la vérification du slug.",e.status,e.data);throw e}const t={typeElement:this.getEntityType(),id:this.id,slug:e};return this.callIsConnected((()=>this.endpointApi.updateBlockSlug(t)))}async updateImageProfil(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 getNews(e={}){e.pathParams={type:this.getEntityType(),id:this.id};const t=await this.endpointApi.getNews(e);if(!Array.isArray(t))throw new _("Erreur lors de la récupération des actualités.",500,t);const o=t.map((e=>C.fromServerData(e,this,{User:D,EndpointApi:this.deps.EndpointApi})));return this._createFilteredProxy(o)}async news(e){try{const t=new C(this,e,{User:D,EndpointApi:this.deps.EndpointApi});return e.id&&await t.get(),t}catch(e){throw console.error("[Api.project.news] Erreur lors de la création d'une instance news :",e.message),e}}}Object.assign($.prototype,k,v,I);const q=(e=>{var t={};return h.d(t,e),t})({EventEmitter:()=>o.EventEmitter}),N=(e=>{var t={};return h.d(t,e),t})({AggregateAjvError:()=>n.AggregateAjvError}),z=(e=>{var t={};return h.d(t,e),t})({default:()=>r.default}),L=(e=>{var t={};return h.d(t,e),t})({default:()=>i.default}),M=(e=>{var t={};return h.d(t,e),t})({default:()=>s.default}),B=(e=>{var t={};return h.d(t,e),t})({default:()=>a.default}),G=(e=>{var t={};return h.d(t,e),t})({default:()=>c.default}),R=(e=>{var t={};return h.d(t,e),t})({jwtDecode:()=>p.jwtDecode}),U=(e=>{var t={};return h.d(t,e),t})({default:()=>m.default}),F={_looksLikeObjectID:e=>24===e.length&&/^[0-9a-f]*$/.test(e),ObjectID:class{constructor(e){if(e){if(e=e.toLowerCase(),!F._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");this._str=e}}equals(e){return e instanceof F.ObjectID&&this.valueOf()===e.valueOf()}toString(){return`ObjectID("${this._str}")`}clone(){return new F.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()}}},Z=F,V={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"},common7:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}},common8:{additionalProperties:!1,properties:{reason:{default:"",type:"string"}},required:["reason"],type:"object"},common9:{reason:{default:"",type:"string"}},common10:{default:"",type:"string"},common11:{pattern:"^[a-f0-9]{24}$",type:"string"},common12:{const:"citoyens"},common13:{properties:{value:{type:"boolean"}}},common14:{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"}}}},common18:{properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}}},common19:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},common20:{properties:{typeElement:{const:"citoyens"}}},common21:{typeElement:{const:"citoyens"}},common22:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"}}},common23:{not:{type:"null"}},common24:{type:"null"},common25:{anyOf:[{items:{type:"string"},type:"array"},{enum:[""],type:"string"}]},common26:{items:{type:"string"},type:"array"},common27:{enum:[""],type:"string"},common28:{properties:{name:{not:{type:"null"}}},required:["name"]},common29:{name:{not:{type:"null"}}},common30:{properties:{url:{not:{type:"null"}}},required:["url"]},common31:{url:{not:{type:"null"}}},common32:{properties:{tags:{not:{type:"null"}}},required:["tags"]},common33:{tags:{not:{type:"null"}}},common34:{properties:{email:{not:{type:"null"}}},required:["email"]},common35:{email:{not:{type:"null"}}},common36:{const:"info",default:"info",type:"string"},common37:{$ref:"#/$defs/sharedFields/email"},common38:{$ref:"#/$defs/sharedFields/name"},common39:{$ref:"#/$defs/sharedFields/tags"},common40:{$ref:"#/$defs/sharedFields/url"},common41:{const:"projects"},common42:{name:{type:"string"},type:{type:"string"}},common43:{const:"organizations"},common44:{$ref:"#/$defs/socialField"},common45:{properties:{id:{pattern:"^[a-f0-9]{24}$"}}},common46:{id:{pattern:"^[a-f0-9]{24}$"}},common47:{pattern:"^[a-f0-9]{24}$"},common48:{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"},common49:{"@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"}},common50:{const:"PostalAddress",type:"string"},common51:{minLength:0,type:"string"},common52:{additionalProperties:!1,properties:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},required:["latitude","longitude"],type:"object"},common53:{"@type":{const:"GeoCoordinates",type:"string"},latitude:{type:["string","number"]},longitude:{type:["string","number"]}},common54:{const:"GeoCoordinates",type:"string"},common55:{type:["string","number"]},common56:{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"},common57:{coordinates:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},float:{const:!0,default:!0,type:"boolean"},type:{const:"Point",type:"string"}},common58:{items:{type:"number"},maxItems:2,minItems:2,type:"array"},common59:{type:"number"},common60:{const:!0,default:!0,type:"boolean"},common61:{const:"Point",type:"string"},common62:{properties:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common63:{id:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common64:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"},common65:{maxLength:100,minLength:3,pattern:"^[a-zA-Z0-9]+$",type:"string"},common66:{properties:{type:{const:"citoyens"}}},common67:{type:{const:"citoyens"}},common68:{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"},common69:{properties:{ownerId:{pattern:"^[a-f0-9]{24}$"}}},common70:{ownerId:{pattern:"^[a-f0-9]{24}$"}},common71:{properties:{folder:{const:"citoyens"}}},common72:{folder:{const:"citoyens"}},common73:{folder:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"},ownerId:{type:"string"}},common74:{properties:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common75:{ownerId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common76:{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"},common77:{id:{type:"string"},type:{default:"citoyens",enum:["citoyens","projects","organizations"],type:"string"}},common78:{properties:{parentId:{pattern:"^[a-f0-9]{24}$"}}},common79:{parentId:{pattern:"^[a-f0-9]{24}$"}},common80:{properties:{parentType:{const:"citoyens"}}},common81:{parentType:{const:"citoyens"}},common82:{properties:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}}},common83:{parentId:{default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$"}},common84:{default:!0,type:"boolean"},common85:{required:["text"]},common86:{required:["mediaImg"]},common87:{required:["mediaFile"]},common88:{additionalProperties:!1,properties:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},required:["countFiles","files"],type:"object"},common89:{countFiles:{type:"number"},files:{items:{type:"string"},type:"array"}},common90:{additionalProperties:!1,properties:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},required:["countImages","images"],type:"object"},common91:{countImages:{type:"number"},images:{items:{type:"string"},type:"array"}},common92:{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"},common93:{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"},common94:{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"}},common95:{minimum:1,type:"integer"},common96:{default:"public",enum:["public","private","restricted"],type:"string"},common97:{const:"news",default:"news",type:"string"},common98:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"}},required:["id"],type:"object"},common99:{default:!1,type:"boolean"},common100:{additionalProperties:!1,properties:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},required:["type","id"],type:"object"},common101:{id:{pattern:"^[a-f0-9]{24}$",type:"string"},type:{default:"news",enum:["news"],type:"string"}},common102:{default:"news",enum:["news"],type:"string"},common103:{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"},common104:{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"},common105:{count:{type:"number"},id:{pattern:"^[a-f0-9]{24}$",type:"string"},name:{type:"string"},slug:{type:"string"},type:{type:"string"},value:{type:"string"}},common106:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],type:"string"},common107:{const:!1,default:!1,type:"boolean"},common108:{const:"",default:"",type:"string"},common109:{additionalProperties:!1,properties:{indexMax:{type:"number"},indexMin:{type:"number"}},required:["indexMin","indexMax"],type:"object"},common110:{indexMax:{type:"number"},indexMin:{type:"number"}},common111:{default:0,minimum:0,type:"integer"},common112:{const:["projects"],default:["projects"],items:{enum:["projects"],type:"string"},type:"array"},common113:{enum:["projects"],type:"string"},common114:{$exists:!0},common115:{additionalProperties:!1,properties:{$exists:{const:!0}},required:["$exists"],type:"object"},common116:{$exists:{const:!0}},common117:{const:!0},common118:{default:30,type:"integer"},common119:{const:["poi"],default:["poi"],items:{enum:["poi"],type:"string"},type:"array"},common120:{enum:["poi"],type:"string"},common121:{const:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],default:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],items:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},type:"array"},common122:{enum:["NGO","Cooperative","LocalBusiness","Group","GovernmentOrganization"],type:"string"},common123:{$exists:!1},common124:{additionalProperties:!1,properties:{$exists:{const:!1}},required:["$exists"],type:"object"},common125:{$exists:{const:!1}},common126:{const:!1},common127:{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"},common128:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common129:{additionalProperties:!1,properties:{$exists:{default:!1,type:"boolean"}},required:["$exists"],type:"object"},common130:{$exists:{default:!1,type:"boolean"}},common131:{additionalProperties:!1,properties:{$in:{items:{type:"string"},minItems:1,type:"array"}},required:["$in"],type:"object"},common132:{$in:{items:{type:"string"},minItems:1,type:"array"}},common133:{items:{type:"string"},minItems:1,type:"array"},common134:{const:["citoyens"],default:["citoyens"],items:{enum:["citoyens"],type:"string"},type:"array"},common135:{enum:["citoyens"],type:"string"},common136:{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"},common137:{enum:["citoyens","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects"],type:"string"},common138:{not:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common139:{propertyNames:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common140:{pattern:"^(?!links\\.followers\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common141:{"^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"}},common142:{not:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}}},common143:{propertyNames:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"}},common144:{pattern:"^(?!links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$)"},common145:{const:["badges"],default:["badges"],items:{enum:["badges"],type:"string"},type:"array"},common146:{enum:["badges"],type:"string"},common147:{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"},common148:{enum:["citoyens","projects","NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},common149:{additionalProperties:!1,properties:{$exists:{const:!0,type:"boolean"}},required:["$exists"],type:"object"},common150:{$exists:{const:!0,type:"boolean"}},common151:{const:!0,type:"boolean"},common152:{additionalProperties:!1,properties:{$exists:{const:!1,type:"boolean"}},required:["$exists"],type:"object"},common153:{$exists:{const:!1,type:"boolean"}},common154:{const:!1,type:"boolean"},common155:{"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"}},common156:{indexMax:30,indexMin:0},common157:{if:{properties:{parentType:{const:"citoyens"}}},then:{properties:{connectType:{const:"friend",default:"friend"}}}},common158:{properties:{connectType:{const:"friend",default:"friend"}}},common159:{connectType:{const:"friend",default:"friend"}},common160:{const:"friend",default:"friend"},common161:{if:{properties:{parentType:{const:"organizations"}}},then:{properties:{connectType:{enum:["admin","member"]}}}},common162:{properties:{parentType:{const:"organizations"}}},common163:{parentType:{const:"organizations"}},common164:{properties:{connectType:{enum:["admin","member"]}}},common165:{connectType:{enum:["admin","member"]}},common166:{enum:["admin","member"]},common167:{if:{properties:{parentType:{const:"projects"}}},then:{properties:{connectType:{enum:["admin","contributor"]}}}},common168:{properties:{parentType:{const:"projects"}}},common169:{parentType:{const:"projects"}},common170:{properties:{connectType:{enum:["admin","contributor"]}}},common171:{connectType:{enum:["admin","contributor"]}},common172:{enum:["admin","contributor"]},common173:{properties:{parentType:{const:"events"}}},common174:{parentType:{const:"events"}},common175:{const:"events"},common176:{default:"@userId",pattern:"^([a-f0-9]{24}|@\\w+)$",type:"string"},common177:{const:"citoyens",default:"citoyens",enum:["citoyens"],type:"string"},common178:{enum:["citoyens","organizations","projects","events"],type:"string"},common179:{const:"citoyens",default:"citoyens",type:"string"},common180:{const:"@userId",default:"@userId",pattern:"^(?:[a-f0-9]{24}|@userId)$",type:"string"},common181:{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"},common182:{"@userId":{type:"citoyens"}},common183:{type:"citoyens"},common184:{"^(?:[a-f0-9]{24}|@userId)$":{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"}},common185:{additionalProperties:!1,properties:{name:{type:"string"},type:{type:"string"}},required:["type"],type:"object"},common186:{const:"poi",default:"poi",type:"string"},common187:{format:"date-time",type:"string"},common188:{pattern:"^([01]\\d|2[0-3]):[0-5]\\d$",type:"string"}},K=[{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:V.common1,email:V.common2,isInvitation:V.common3,mode:V.common1,name:V.common1,pendingUserId:V.common1,pwd:V.common1,username:V.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:V.common2,password:V.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:V.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:V.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:V.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:V.common1,newPassword2:V.common1,oldPassword:V.common1,scope:{default:"",type:["string"]},userId:V.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:V.common6,postActions:[{type:"resetSession"},{event:"accountDeleted",path:null,type:"emitEvent"}],request:V.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:V.common11}},if:{properties:{typeEntity:V.common12}},then:{properties:{idEntity:V.common5}}},{if:{properties:{type:{enum:["birthDate","email","locality","phone","directory"]},typeEntity:V.common12}},then:{properties:{value:{enum:["private","public","mask"],type:"string"}}}},{if:{properties:{type:{enum:["activitypub","isOpenData"]},typeEntity:V.common12}},then:V.common13},{if:{properties:{type:{enum:["isOpenData","isOpenEdition","private","feedback"]},typeEntity:{not:V.common12}}},then:V.common13}],properties:{idEntity:V.common1,type:V.common1,typeEntity:V.common15,value:V.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:[V.common17,{anyOf:[{properties:{description:V.common23},required:["description"]},{properties:{shortDescription:V.common23},required:["shortDescription"]}]}],properties:{block:{const:"descriptions",default:"descriptions",type:"string"},descMentions:V.common10,description:V.common1,id:V.common1,scope:{default:"",type:["string","null"]},shortDescription:V.common1,typeElement:V.common15},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:V.common2,name:V.common1,tags:V.common25,url:V.common4}},allOf:[{if:V.common20,then:{additionalProperties:!1,anyOf:[V.common28,{properties:{birthDate:V.common23},required:["birthDate"]},{properties:{fixe:V.common23},required:["fixe"]},{properties:{mobile:V.common23},required:["mobile"]},V.common30,V.common32,V.common34],properties:{birthDate:{format:"date",type:"string"},block:V.common36,email:V.common37,fixe:V.common1,id:V.common5,mobile:V.common1,name:V.common38,scope:V.common10,tags:V.common39,typeElement:V.common15,url:V.common40}}},{if:{properties:{typeElement:V.common41}},then:{additionalProperties:!1,anyOf:[V.common28,V.common30,V.common32,V.common34,{properties:{avancement:V.common23},required:["avancement"]},{properties:{parent:V.common23},required:["parent"]}],properties:{avancement:{enum:["abandoned","concept","development","production","started","testing","idea","mature","qa","finished"],type:"string"},block:V.common36,email:V.common37,id:V.common1,name:V.common38,parent:{additionalProperties:!1,patternProperties:{"^[a-fA-F0-9]{24}$":{additionalProperties:!1,properties:V.common42,required:["type","name"],type:"object"}},type:"object"},scope:V.common10,tags:V.common39,typeElement:V.common15,url:V.common40}}},{if:{properties:{typeElement:V.common43}},then:{additionalProperties:!1,anyOf:[V.common28,V.common30,V.common32,V.common34,{properties:{type:V.common23},required:["type"]}],properties:{block:V.common36,email:V.common37,id:V.common1,name:V.common38,scope:V.common10,tags:V.common39,type:{enum:["NGO","Cooperative","LocalBusiness","GovernmentOrganizationautre"],type:"string"},typeElement:V.common15,url:V.common40}}}],properties:{block:V.common36,id:V.common1,scope:V.common10,typeElement:V.common15},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:[V.common27,V.common4]}},allOf:[V.common17,{anyOf:[{properties:{gitlab:V.common23},required:["gitlab"]},{properties:{github:V.common23},required:["github"]},{properties:{twitter:V.common23},required:["twitter"]},{properties:{facebook:V.common23},required:["facebook"]},{properties:{instagram:V.common23},required:["instagram"]},{properties:{diaspora:V.common23},required:["diaspora"]},{properties:{mastodon:V.common23},required:["mastodon"]},{properties:{telegram:V.common23},required:["telegram"]},{properties:{signal:V.common23},required:["signal"]}]}],properties:{block:{const:"network",default:"network",type:"string"},diaspora:V.common44,facebook:V.common44,github:V.common44,gitlab:V.common44,id:V.common1,instagram:V.common44,mastodon:V.common44,scope:V.common10,signal:V.common44,telegram:V.common44,twitter:V.common44,typeElement:V.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:V.common45,if:V.common20,properties:{address:V.common48,block:{const:"localities",default:"localities",type:"string"},geo:V.common52,geoPosition:V.common56,id:V.common1,scope:V.common10,typeElement:V.common15},required:["block","typeElement","id","address"],then:V.common62,type:"object"}},{auth:"bearer",constant:"UPDATE_BLOCK_SLUG",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updateblock/",request:{else:V.common45,if:V.common20,properties:{block:V.common36,id:V.common1,scope:V.common10,slug:V.common65,typeElement:V.common15},required:["block","typeElement","id","slug"],then:V.common62,type:"object"}},{auth:"bearer",constant:"CHECK",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/slug/check",request:{additionalProperties:!1,else:V.common45,if:V.common66,properties:{block:V.common36,id:V.common1,slug:V.common65,type:V.common15},required:["block","type","id","slug"],then:V.common62,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:V.common68,request:{additionalProperties:!1,properties:{profil_avatar:V.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:V.common76,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:V.common78,if:V.common80,properties:{listInvite:{additionalProperties:!1,patternProperties:{"^(citoyens|projects|organizations)$":{additionalProperties:!1,patternProperties:{"^[0-9a-fA-F]{24}$":{additionalProperties:!1,properties:{name:V.common1},required:["name"],type:"object"}},type:"object"}},type:"object"},parentId:V.common1,parentType:V.common15},required:["parentId","parentType","listInvite"],then:V.common82,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:V.common45,if:V.common66,properties:{id:V.common1,isLive:V.common84,type:V.common15},required:["isLive","type","id"],then:V.common62,type:"object"},request:{additionalProperties:!1,properties:{dateLimit:{default:0,type:"integer"},indexStep:{default:12,type:"integer"},search:{additionalProperties:!1,properties:{name:V.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:V.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:[V.common85,V.common86,V.common87],else:V.common78,if:V.common80,properties:{json:V.common60,markdownActive:V.common84,mediaFile:V.common88,mediaImg:V.common90,mentions:V.common92,parentId:V.common1,parentType:V.common15,scope:V.common96,tags:V.common25,text:V.common1,type:V.common97},required:["scope","markdownActive","parentId","parentType","type","json"],then:V.common82,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:V.common68,request:{additionalProperties:!1,properties:{newsImage:V.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:V.common68,request:{additionalProperties:!1,properties:{newsFile:V.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:V.common98,request:{additionalProperties:!1,properties:{isLive:V.common99},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:[V.common85,V.common86,V.common87],else:V.common78,if:V.common80,properties:{idNews:V.common11,markdownActive:V.common84,mediaFile:V.common88,mediaImg:V.common90,mentions:V.common92,parentId:V.common1,parentType:V.common15,scope:V.common96,tags:V.common25,text:V.common1,type:V.common97},required:["idNews","scope","markdownActive","parentId","parentType","type"],then:V.common82,type:"object"}},{auth:"bearer",constant:"SHARE_NEWS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/news/co/share",request:{additionalProperties:!1,else:{properties:{childId:V.common47}},if:{properties:{childType:V.common12}},properties:{childId:V.common11,childType:V.common15,comment:V.common1,connectType:{const:"share",default:"share",type:"string"},parentId:V.common11,parentType:V.common97},required:["parentId","parentType","childId","childType","connectType"],then:{properties:{childId:V.common64}},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:V.common100},{auth:"bearer",constant:"ADD_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/save",request:{additionalProperties:!1,properties:{argval:V.common10,contextId:V.common11,contextType:V.common102,mentions:V.common103,parentCommentId:V.common11,path:V.common10,text:V.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:V.common98},{auth:"bearer",constant:"UPDATE_COMMENTS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/comment/update",request:{additionalProperties:!1,properties:{id:V.common11,params:{properties:{mentions:V.common103,text:V.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:V.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:V.common100},{auth:"none",constant:"GLOBAL_AUTOCOMPLETE",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:{const:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],default:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative","projects","citoyens","poi"],items:V.common106,type:"array"},fediverse:V.common107,filters:V.common108,indexMin:{const:0,default:0,type:"number"},indexStep:V.common59,initType:V.common108,locality:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":{additionalProperties:!1,properties:{id:V.common1,type:{enum:["cities","level1"],type:"string"}},required:["id","type"],type:"object"}},type:"object"},name:V.common1,notSourceKey:V.common60,ranges:{additionalProperties:!1,patternProperties:{"^[^\\s]+$":V.common109},type:"object"},searchTags:V.common26,searchType:{items:V.common106,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:V.common108,name:V.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:V.common111,name:V.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:V.common60,countType:V.common112,fediverse:V.common107,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@userId":V.common114,"parent.@userId":V.common114},"links.contributors.@userId":V.common114},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115,"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115},type:"object"}},required:["$or"],type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common112},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:V.common76,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common112,fediverse:V.common107,filters:{additionalProperties:!1,default:{$or:{"links.contributors.@{pathParams.id}":V.common114,"parent.@{pathParams.id}":V.common114},"links.contributors.@{pathParams.id}":V.common114},patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115},properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:{"^links\\.contributors\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115},type:"object"}},required:["$or"],type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common112},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:V.common60,countType:V.common119,fediverse:V.common107,filters:{additionalProperties:!1,default:{"parent.@userId":V.common114},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common119},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:V.common76,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common119,fediverse:V.common107,filters:{additionalProperties:!1,default:{"parent.@{pathParams.id}":V.common114},patternProperties:{"^parent\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common119},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:V.common60,countType:V.common121,fediverse:V.common107,filters:{additionalProperties:!1,default:{"links.members.@userId":V.common114,"links.members.@userId.isInviting":V.common123,"links.members.@userId.toBeValidated":V.common123},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":V.common124,"^links\\.members\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common121},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:V.common45,if:V.common66,properties:{id:V.common1,type:{default:"citoyens",enum:["citoyens","organizations"],type:"string"}},required:["type","id"],then:V.common62,type:"object"},request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common121,fediverse:V.common107,filters:{additionalProperties:!1,default:{"links.members.@{pathParams.id}":V.common114,"links.members.@{pathParams.id}.isInviting":V.common123,"links.members.@{pathParams.id}.toBeValidated":V.common123},patternProperties:{"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common124,"^links\\.members\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common121},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:V.common60,countType:V.common127,fediverse:V.common107,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+)$":V.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":V.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":V.common129,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":V.common131,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common127},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:V.common98,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common127,fediverse:V.common107,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}":V.common114,"links.memberOf.@{pathParams.id}.isInviting":V.common123,"links.memberOf.@{pathParams.id}.toBeValidated":V.common123},patternProperties:{"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":V.common115,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common129,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":V.common131,"^links\\.memberOf\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common129},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common127},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:V.common6,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common134,fediverse:V.common107,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}":V.common114,"links.friends.@{pathParams.id}.isInviting":V.common123,"links.friends.@{pathParams.id}.toBeValidated":V.common123},patternProperties:{"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common129,"^links\\.friends\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common129},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common134},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:V.common60,countType:V.common136,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[V.common138],default:{"links.followers.@userId":V.common114,"links.followers.@{userId}.isInviting":V.common123,"links.followers.@{userId}.toBeValidated":V.common123},patternProperties:V.common141,type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common136},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:V.common6,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common136,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[V.common138],default:{"links.followers.@{pathParams.id}":V.common114,"links.followers.@{pathParams.id}.isInviting":V.common123,"links.followers.@{pathParams.id}.toBeValidated":V.common123},patternProperties:V.common141,type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common136},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:V.common60,countType:V.common134,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[V.common142],default:{"links.follows.@userId":V.common114,"links.follows.@{userId}.isInviting":V.common123,"links.follows.@{userId}.toBeValidated":V.common123},patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common124,"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common134},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:V.common45,if:V.common66,then:V.common62}],properties:{id:V.common1,type:{default:"citoyens",enum:["citoyens","organizations","projects"],type:"string"}},required:["type","id"],type:"object"},request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common134,fediverse:V.common107,filters:{additionalProperties:!1,allOf:[V.common142],default:{"links.follows.@{pathParams.id}":V.common114},maxProperties:1,minProperties:1,patternProperties:{"^links\\.follows\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common134},required:["searchType","indexMin","initType","count","countType","indexStep","notSourceKey","filters","locality","fediverse"],type:"object"}},{auth:"none",constant:"GET_CONTRIBUTORS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/search/globalautocomplete",request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common127,fediverse:V.common107,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+)$":V.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isAdmin$":V.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.isInviting$":V.common129,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.roles$":V.common131,"^links\\.projects\\.(?:[a-f0-9]{24}|@\\w+)\\.toBeValidated$":V.common124},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common127},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:V.common98,request:{additionalProperties:!1,properties:{count:V.common60,countType:V.common127,fediverse:V.common107,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}":V.common114,"links.projects.@{pathParams.id}.isInviting":V.common123,"links.projects.@{pathParams.id}.toBeValidated":V.common123},patternProperties:{"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))$":V.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isAdmin$":V.common115,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.isInviting$":V.common129,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.roles$":V.common131,"^links\\.projects\\.(?:[a-f0-9]{24}|@(?:\\{[^}]+\\}|[A-Za-z0-9_]+(?:\\.[A-Za-z0-9_]+)?))\\.toBeValidated$":V.common129},type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common127},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:V.common60,countType:V.common145,fediverse:V.common107,filters:{properties:{$or:{additionalProperties:!1,minProperties:1,patternProperties:{"^issuer\\.(?:[a-f0-9]{24}|@\\w+)$":V.common115},type:"object"},isParcours:V.common3,"preferences.private":V.common107},required:["preferences.private"],type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,searchType:V.common145},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:V.common60,countType:V.common147,fediverse:V.common107,fields:V.common145,filters:{oneOf:[{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":V.common149}},{additionalProperties:!1,maxProperties:3,minProperties:3,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)$":V.common149,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":V.common152,"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteRecepteur$":V.common152}},{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:V.common155},{additionalProperties:!1,maxProperties:1,minProperties:1,properties:{$or:{additionalProperties:!1,maxProperties:2,minProperties:2,patternProperties:V.common155,type:"object"}},required:["$or"]},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.revoke$":V.common151}},{additionalProperties:!1,maxProperties:1,minProperties:1,patternProperties:{"badges\\.(?:[a-f0-9]{24}|@\\w+)\\.attenteEmetteur$":V.common149}}],type:"object"},indexMin:V.common111,indexStep:V.common118,initType:V.common108,locality:V.common108,name:V.common1,notSourceKey:V.common60,ranges:{additionalProperties:!1,default:{Cooperative:V.common156,GovernmentOrganization:V.common156,Group:V.common156,LocalBusiness:V.common156,NGO:V.common156,citoyens:V.common156,projects:V.common156},maxProperties:7,minProperties:7,patternProperties:{"^[a-zA-Z][a-zA-Z0-9]*$":V.common109},type:"object"},searchType:V.common147},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:[V.common157,V.common161,V.common167,{if:V.common173,then:{properties:{connectType:{default:"attendee",enum:["attendee","connect"]}}}}],properties:{childId:V.common176,childType:V.common177,connectType:{enum:["admin","member","contributor","attendee","friend","connect"],type:"string"},parentId:V.common11,parentType:V.common178},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:[V.common157,V.common161,V.common167,{if:V.common173,then:{properties:{connectType:{const:"attendee",default:"attendee"}}}}],properties:{childId:V.common176,childType:V.common177,connectType:{enum:["admin","member","contributor","attendee","friend"],type:"string"},parentId:V.common11,parentType:V.common178},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:V.common6},{auth:"bearer",constant:"DELETE_FAVORIS",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/updatepathvalue?index={index}",pathParams:{properties:{index:V.common59},type:"object"},request:{additionalProperties:!1,properties:{collection:V.common179,id:V.common180,path:{const:"preferences.search.@{pathParams.index}",default:"preferences.search.@{pathParams.index}",type:"string"},pull:{const:"preferences.search",type:"string"},value:V.common108},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:V.common151,collection:V.common179,id:V.common180,path:{const:"preferences.search",default:"preferences.search",type:"string"},value:{additionalProperties:!1,properties:{description:V.common1,locality:{patternProperties:{"^[a-f0-9]{24}$":{additionalProperties:!1,properties:V.common42,required:["name","type"]}},type:"object"},name:V.common1,tags:V.common26,url:V.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:V.common48,collection:{const:"organizations",default:"organizations",type:"string"},email:V.common2,geo:V.common52,geoPosition:V.common56,id:V.common11,key:{const:"organization",default:"organization",type:"string"},name:V.common1,preferences:{default:{isOpenData:!0,isOpenEdition:!0},properties:{isOpenData:V.common84,isOpenEdition:V.common84},required:["isOpenData","isOpenEdition"],type:"object"},role:{enum:["admin","member"],type:"string"},scope:V.common108,shortDescription:V.common1,tags:V.common26,type:{enum:["NGO","LocalBusiness","Group","GovernmentOrganization","Cooperative"],type:"string"},url:V.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:V.common48,collection:{const:"projects",default:"projects",type:"string"},geo:V.common52,geoPosition:V.common56,id:V.common11,key:{const:"project",default:"project",type:"string"},name:V.common1,parent:V.common181,preferences:{default:{crowdfunding:!0,isOpenData:!1,isOpenEdition:!1},properties:{crowdfunding:V.common84,isOpenData:V.common99,isOpenEdition:V.common99},required:["isOpenData","isOpenEdition"],type:"object"},public:V.common84,scope:V.common108,shortDescription:V.common1,tags:V.common26,url:V.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:V.common48,collection:V.common186,description:V.common1,geo:V.common52,geoPosition:V.common56,id:V.common11,key:V.common186,name:V.common1,parent:V.common181,scope:V.common108,tags:V.common26,type:{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"},urls:V.common26},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:V.common126}},properties:{address:V.common48,collection:{const:"events",default:"events",type:"string"},email:V.common2,endDate:V.common187,geo:V.common52,geoPosition:V.common56,id:V.common11,key:{const:"event",default:"event",type:"string"},name:V.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:V.common188,opens:V.common188},required:["opens","closes"],type:"object"},type:"array"}},required:["dayOfWeek","hours"],type:"object"}]},maxItems:7,minItems:7,type:"array"},organizer:V.common181,parent:{additionalProperties:!1,patternProperties:V.common184,type:"object"},preferences:{default:{isOpenData:!1,isOpenEdition:!1},properties:{isOpenData:V.common99,isOpenEdition:V.common99},required:["isOpenData","isOpenEdition"],type:"object"},public:V.common84,recurrency:V.common99,scope:V.common108,shortDescription:V.common1,startDate:V.common187,tags:V.common26,timeZone:V.common1,type:{enum:["workshop","competition","concert","contest","conference","debate","exhibition","festival","crowdfunding","fair","course","protest","market","film","getTogether","meeting","spectacle","internship","stand","others"],type:"string"},url:V.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:V.common98,request:V.common8},{auth:"bearer",constant:"DELETE_EVENT",contentType:"application/x-www-form-urlencoded",method:"POST",path:"/co2/element/delete/type/events/id/{id}/",pathParams:V.common98,request:V.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:V.common11,type:V.common1},required:["type","id"],type:"object"},request:V.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:V.common11},required:["folder","ownerId"],type:"object"},request:{additionalProperties:!1,properties:{qqfile:V.common16,qqfilename:V.common1,qqtotalfilesize:{type:"integer"},qquuid:V.common11},required:["qquuid","qqfilename","qqtotalfilesize","qqfile"],type:"object"}}];G.default.addType("oid",(e=>new Z.ObjectID(e)));class W extends q.EventEmitter{constructor({baseURL:e,accessToken:t,refreshToken:o,refreshUrl:n="/api/cocolight/refreshtoken",endpoints:r=K,timeout:i=3e4,debug:s=!1,maxRetries:a=0,circuitBreakerThreshold:c=5,circuitBreakerResetTime:p=6e4,fromJSONValue:m=!0}={}){if(super(),!e)throw new T('Le paramètre "baseURL" est obligatoire.',500);this._baseURL=e,this._refreshToken=o,this._refreshUrl=n,this._endpoints=r,this._debug=s;let d=null;this._fromJSONValue=m,Object.defineProperty(this,"userId",{get:()=>d,set:()=>{throw new Error("Modification directe de userId non autorisée.")},enumerable:!0}),this._setUserId=e=>{d=e,this._logger.debug(`[ApiClient] userId set: ${e}`)},this._ajv=new z.default({strict:!1,useDefaults:!0,allErrors:!0,verbose:!0}),(0,L.default)(this._ajv),this._ajv.addKeyword({keyword:"startBeforeEnd",type:"object",errors:!0,validate:this._startBeforeEndValidate}),this._logger=(0,U.default)({transport:{target:"pino-pretty",options:{colorize:!0}},level:s?"debug":"info"}),this._client=M.default.create({baseURL:e,timeout:i}),a>0&&((0,B.default)(this._client,{retries:a,retryDelay:B.default.exponentialDelay,retryCondition:e=>B.default.isNetworkError(e)||B.default.isRetryableError(e)}),this._logger.info(`[ApiClient] Retry activé : ${a} max`)),this._breakerThreshold=c,this._breakerResetTime=p,this._breakerErrorCount=0,this._breakerOpen=!1,this._lastBreakerOpenTime=null,t&&this.setToken(t),this._client.interceptors.response.use((e=>e),(async e=>{if(e.response&&401===e.response.status&&this._refreshToken)try{if(await this._refreshAccessToken())return this._client.request(e.config)}catch(e){throw new T(e.message,401,e)}throw e}))}setToken(e){this._accessToken=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){this._refreshToken=e;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=(0,R.jwtDecode)(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;try{const e=await this._client.post(this._refreshUrl,{refreshToken:this._refreshToken},{headers:{"Content-Type":"application/json"}});return!(!e.data||!e.data.accessToken||(this.setToken(e.data.accessToken),e.data.refreshToken&&this.setRefreshToken(e.data.refreshToken),this.emit("refreshSuccess",e.data),0))}catch(e){return this.resetSession(),this._logger.error(`[ApiClient] Refresh Error : ${e.message}`),!1}}_checkCircuitBreaker(){return!this._breakerOpen||Date.now()-this._lastBreakerOpenTime>this._breakerResetTime&&(this._breakerOpen=!1,this._breakerErrorCount=0,this._logger.warn("[ApiClient] Circuit breaker réinitialisé"),!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"))}_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]&&W.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]&&W.stripNullsInPlace(e[t]));return e}_resolveSpecialValuesInPlace(e,t={}){const o={userId:()=>this.userId,accessToken:()=>this._accessToken,refreshToken:()=>this._refreshToken,baseURL:()=>this._baseURL,pathParams:e=>{const o=this._getValueByPath(t,e);return null!=o?o:void 0}},n=/@(?:\{([^}]+)\}|([\w.]+))/g,r=e=>"string"!=typeof e?e:e.replace(n,((t,n,r)=>{if(n){if(n.startsWith("pathParams.")){const e=n.substring(11),t=o.pathParams(e);return null!=t?t:`@{${n}}`}{const e=o[n];if("function"==typeof e){const t=e();return null!=t?t:`@{${n}}`}return`@{${n}}`}}if(r){if(r.startsWith("pathParams.")){const e=r.match(/^pathParams\.([^.]+)(.*)$/);if(e){const t=e[1],n=e[2],i=o.pathParams(t);return null!=i?i+n:`@${r}`}return`@${r}`}{const e=o[r];if("function"==typeof e){const t=e();return null!=t?t:`@${r}`}return`@${r}`}}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[o,n]of Object.entries(e))t[r(o)]=i(n);return t}return"string"==typeof e?r(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 o={};for(const n of Object.keys(e)){const r=e[n];if(!t.test(n)){if("default"===n){if("string"==typeof r&&t.test(r))continue;if(r&&"object"==typeof r){const e=this._cleanSchemaLeftoverAlias(r);Object.keys(e).length>0&&(o[n]=e);continue}}"string"==typeof r&&t.test(r)||(o[n]=this._cleanSchemaLeftoverAlias(r))}}return o}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={},o=!0,n=!0){if(!this._checkCircuitBreaker())throw new E("Le circuit breaker est activé, impossible d'appeler l'API");const r=this._endpoints.find((t=>t.constant===e));if(!r)throw new T(`Endpoint introuvable : ${e}`,404);const{path:i,method:s,contentType:a,auth:c,pathParams:p,request:m,responses:d}=r,l=(s||"GET").toLowerCase(),u=a||"application/json",y={"Content-Type":u};if(this._accessToken)"bearer"===c?y.Authorization=`Bearer ${this._accessToken}`:c&&"none"!==c||y.Authorization||(y.Authorization=`Bearer ${this._accessToken}`);else if("bearer"===c)throw new T(`Token requis pour l'endpoint sécurisé : ${e}`,401);let h,f=i,g={};if(p){let e=p;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(p));const o=t.pathParams||{},n=this._ajv.compile(e);if(!n(o)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"pathParams",errors:n.errors}),new b("Path parameter validation failed.",400,e,n.errors)}g=this._resolveSpecialValuesInPlace(o),f=f.replace(/\{(\w+)\}/g,((e,t)=>{const o=g[t];if(void 0!==o)return encodeURIComponent(o);throw new T(`Path param manquant ou non résolu : {${t}}`,400)}))}if(m){let e=m;"none"===c&&null===this.userId&&(e=this._cleanSchemaLeftoverAlias(m));const o={...t};delete o.pathParams;const n=W.stripNullsInPlace(o),r=this._ajv.compile(e);if(!r(n)){const e=r.errors?this._ajvErrorHuman(r.errors):[];throw this.emit("validationError",{stage:"request",errors:r.errors}),new b("Request validation failed.",400,e,r.errors)}t=this._resolveSpecialValuesInPlace(n,g)}"application/json"===u||"multipart/form-data"===u?h=t:"application/x-www-form-urlencoded"===u&&(h=W.toURLSearchParams(t)),this._logger.debug(`[ApiClient] callEndpoint: ${e} -> ${f}, method=${l}`);try{const e=await this._client.request({url:f,method:l,headers:y,["get"===l?"params":"data"]:h});if(n){const t=e.status.toString(),o=d?.[t];if(o){const n=this._ajv.compile(o);if(!n(e.data)){const e=this._ajvErrorHuman(n.errors);throw this.emit("validationError",{stage:"response",errors:n.errors}),new b("Response validation failed.",t,e,n.errors)}}}return this._resetCircuitBreakerSuccess(),"function"==typeof o?e.data=o(e.data):!0===o&&(e.data=this._transformData(e.data)),Array.isArray(r.postActions)&&r.postActions.forEach((t=>{const o=t.path?this._getValueByPath(e.data,t.path):null;switch(t.type){case"setToken":this.setToken(o);break;case"setRefreshToken":this.setRefreshToken(o);break;case"resetSession":this.resetSession();break;case"emitEvent":t.event&&(this.emit(t.event,o),this._logger.debug(`[ApiClient] Event émis : ${t.event}`,o));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 b?t:new T(`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{return new N.AggregateAjvError(e).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 _(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 _(t.resultErrors.msg||"Erreur inconnue",e.status,t);return e}resetSession(){this.setToken(null),this.setRefreshToken(null),this._setUserId(null),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 t.split(".").reduce(((e,t)=>e&&e[t]),e)}static toURLSearchParams(e,t={}){return this._buildParams(e,new URLSearchParams,t)}static _buildParams(e,t,o={}){if("object"!=typeof e||null===e)throw new TypeError("La donnée doit être un objet non nul.");const{dots:n=!1,indexes:r=!1,metaTokens:i=!0}=o,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,o=!1){return e?e.concat(t).map(((e,t)=>(e=c(e),!o&&t?`[${e}]`:e))).join(o?".":""):t}function m(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(o,d=[]){null==o||s.includes(o)||(s.push(o),Object.entries(o).forEach((([o,s])=>{void 0!==s&&function(e,o,s){if(e&&"object"==typeof e){if(o.endsWith("{}"))return o=i?o:o.slice(0,-2),t.append(p(s,o,n),JSON.stringify(e)),!1;if(Array.isArray(e)&&!e.some(a)||o.endsWith("[]"))return o=c(o),e.forEach(((e,i)=>{if(null!=e){const a=r?p(s.concat(o),i,n):`${p(s,o,n)}[]`;t.append(a,m(e))}})),!1}return!!a(e)||(t.append(p(s,o,n),m(e)),!1)}(s,o.trim(),d)&&e(s,d.concat(c(o)))})),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?G.default.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"];_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((o=>{let n=this._normalizeRecursively(e[o]);this._dateFields.includes(o)&&(n=this._normalizeDate(n)),this._imageFields.includes(o)&&(n=this._normalizeImage(n)),"content"===o&&n&&"object"==typeof n&&n.image&&(n.image=this._normalizeImage(n.image)),t[o]=n})),this._normalizeId(t)}return e}_startBeforeEndValidate=(e,t)=>{if(!t.startDate||!t.endDate)return!0;const o=new Date(t.startDate)<new Date(t.endDate);return o||(this._startBeforeEndValidate.errors=[{instancePath:"",schemaPath:"#/startBeforeEnd",keyword:"startBeforeEnd",params:{},message:"startDate must be before endDate"}]),o}}class J{constructor(e){this.client=new W(e),this.loggedUser=null}async login(e,t){return this.client.safeCall((async()=>{const o=await this.client.callEndpoint("AUTHENTICATE_URL",{email:e,password:t});return this.loggedUser=new D(this.client,{id:o.data.user.id},o.data.user,{EndpointApi:A}),this.loggedUser}))}async register({name:e,username:t,email:o,pwd:n}={}){return this.client.safeCall((async()=>{const r=await this.client.callEndpoint("PERSON_REGISTER",{name:e,username:t,email:o,pwd:n});if(!1===r?.data?.result)throw new _(r.data.msg,r.status,r.data);return r.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 _(t.data.msg,t.status,t.data);return t.data}))}}class H{static async userLogin(e,t,o){const n=H.userApi(o);return await H.userApiLogin(n,e,t)}static userApi(e){try{return new J(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,o){try{const n=await e.login(t,o);return new H(n,e.client)}catch(e){if(e instanceof T&&e?.details?.error)throw new P(e.details.error,e.status,e.details);throw e}}constructor(e,t){this._loggedUser=e,this._client=t}me(){if(!this._loggedUser)throw new P("Accès refusé : utilisateur non authentifié.");return this._loggedUser}user(e){try{return new D(this._client,e,{},{EndpointApi:A})}catch(e){throw console.error("[Api.user] Erreur lors de la création d'un objet utilisateur public :",e.message),e}}async organization(e,t={getProfile:!0}){try{const o=new x(this._client,e,{EndpointApi:A});return t.getProfile&&await o.getProfil(),o}catch(e){throw console.error("[Api.organization] Erreur lors de la création d'un objet organisation :",e.message),e}}async project(e,t={getProfile:!0}){try{const o=new $(this._client,e,{EndpointApi:A});return t.getProfile&&await o.getProfil(),o}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 A(this._client)}}const Y={ApiClient:W,Api:H,error:g};var X=f.A;export{X as default};
|