mftsccs-node 0.0.82-dev → 0.0.85-dev

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/bundle.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see bundle.mjs.LICENSE.txt */
2
- import{createRequire as e}from"node:module";var t={144:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n=!1)=>{if(e instanceof r)return e;try{return new r(e,t)}catch(e){if(!n)return null;throw e}}},181:t=>{t.exports=e(import.meta.url)("buffer")},270:(e,t,n)=>{const r=n(3908),o=n(8311);e.exports=(e,t,n)=>{let i=null,c=null,s=null;try{s=new o(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(i&&1!==c.compare(e)||(i=e,c=new r(i,n)))})),i}},560:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n)=>new r(e,n).compare(new r(t,n))},855:(e,t,n)=>{var r=n(6585);e.exports=function(e,t){var n=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var o=r(e);if(void 0===o)return;return Math.floor(n+o/1e3)}return"number"==typeof e?n+e:void 0}},909:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n)=>{const o=new r(e,n),i=new r(t,n);return o.compare(i)||o.compareBuild(i)}},1045:(e,t,n)=>{var r=n(181).Buffer,o=n(181).SlowBuffer;function i(e,t){if(!r.isBuffer(e)||!r.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var n=0,o=0;o<e.length;o++)n|=e[o]^t[o];return 0===n}e.exports=i,i.install=function(){r.prototype.equal=o.prototype.equal=function(e){return i(this,e)}};var c=r.prototype.equal,s=o.prototype.equal;i.restore=function(){r.prototype.equal=c,o.prototype.equal=s}},1123:e=>{const t=/^[0-9]+$/,n=(e,n)=>{const r=t.test(e),o=t.test(n);return r&&o&&(e=+e,n=+n),e===n?0:r&&!o?-1:o&&!r?1:e<n?-1:1};e.exports={compareIdentifiers:n,rcompareIdentifiers:(e,t)=>n(t,e)}},1261:(e,t,n)=>{const r=n(3908),o=n(8311),i=n(5580);e.exports=(e,t)=>{e=new o(e,t);let n=new r("0.0.0");if(e.test(n))return n;if(n=new r("0.0.0-0"),e.test(n))return n;n=null;for(let t=0;t<e.set.length;++t){const o=e.set[t];let c=null;o.forEach((e=>{const t=new r(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":c&&!i(t,c)||(c=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!c||n&&!i(n,c)||(n=c)}return n&&e.test(n)?n:null}},1691:(e,t,n)=>{const r=n(1741),o=n(3726),i=n(8980),c=n(7260),s=n(855),a=n(7019),l=n(4977),u=n(5747),{KeyObject:d,createSecretKey:h,createPublicKey:f}=n(6982),p=["RS256","RS384","RS512"],y=["ES256","ES384","ES512"],v=["RS256","RS384","RS512"],g=["HS256","HS384","HS512"];l&&(p.splice(p.length,0,"PS256","PS384","PS512"),v.splice(v.length,0,"PS256","PS384","PS512")),e.exports=function(e,t,n,l){let m;if("function"!=typeof n||l||(l=n,n={}),n||(n={}),n=Object.assign({},n),m=l||function(e,t){if(e)throw e;return t},n.clockTimestamp&&"number"!=typeof n.clockTimestamp)return m(new r("clockTimestamp must be a number"));if(void 0!==n.nonce&&("string"!=typeof n.nonce||""===n.nonce.trim()))return m(new r("nonce must be a non-empty string"));if(void 0!==n.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof n.allowInvalidAsymmetricKeyTypes)return m(new r("allowInvalidAsymmetricKeyTypes must be a boolean"));const C=n.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return m(new r("jwt must be provided"));if("string"!=typeof e)return m(new r("jwt must be a string"));const w=e.split(".");if(3!==w.length)return m(new r("jwt malformed"));let T;try{T=c(e,{complete:!0})}catch(e){return m(e)}if(!T)return m(new r("invalid token"));const I=T.header;let N;if("function"==typeof t){if(!l)return m(new r("verify must be called asynchronous if secret or public key is provided as a callback"));N=t}else N=function(e,n){return n(null,t)};return N(I,(function(t,c){if(t)return m(new r("error in secret or public key callback: "+t.message));const l=""!==w[2].trim();if(!l&&c)return m(new r("jwt signature is required"));if(l&&!c)return m(new r("secret or public key must be provided"));if(!l&&!n.algorithms)return m(new r('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=c&&!(c instanceof d))try{c=f(c)}catch(e){try{c=h("string"==typeof c?Buffer.from(c):c)}catch(e){return m(new r("secretOrPublicKey is not valid key material"))}}if(n.algorithms||("secret"===c.type?n.algorithms=g:["rsa","rsa-pss"].includes(c.asymmetricKeyType)?n.algorithms=v:"ec"===c.asymmetricKeyType?n.algorithms=y:n.algorithms=p),-1===n.algorithms.indexOf(T.header.alg))return m(new r("invalid algorithm"));if(I.alg.startsWith("HS")&&"secret"!==c.type)return m(new r(`secretOrPublicKey must be a symmetric key when using ${I.alg}`));if(/^(?:RS|PS|ES)/.test(I.alg)&&"public"!==c.type)return m(new r(`secretOrPublicKey must be an asymmetric key when using ${I.alg}`));if(!n.allowInvalidAsymmetricKeyTypes)try{a(I.alg,c)}catch(e){return m(e)}let N;try{N=u.verify(e,T.header.alg,c)}catch(e){return m(e)}if(!N)return m(new r("invalid signature"));const A=T.payload;if(void 0!==A.nbf&&!n.ignoreNotBefore){if("number"!=typeof A.nbf)return m(new r("invalid nbf value"));if(A.nbf>C+(n.clockTolerance||0))return m(new o("jwt not active",new Date(1e3*A.nbf)))}if(void 0!==A.exp&&!n.ignoreExpiration){if("number"!=typeof A.exp)return m(new r("invalid exp value"));if(C>=A.exp+(n.clockTolerance||0))return m(new i("jwt expired",new Date(1e3*A.exp)))}if(n.audience){const e=Array.isArray(n.audience)?n.audience:[n.audience];if(!(Array.isArray(A.aud)?A.aud:[A.aud]).some((function(t){return e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))})))return m(new r("jwt audience invalid. expected: "+e.join(" or ")))}if(n.issuer&&("string"==typeof n.issuer&&A.iss!==n.issuer||Array.isArray(n.issuer)&&-1===n.issuer.indexOf(A.iss)))return m(new r("jwt issuer invalid. expected: "+n.issuer));if(n.subject&&A.sub!==n.subject)return m(new r("jwt subject invalid. expected: "+n.subject));if(n.jwtid&&A.jti!==n.jwtid)return m(new r("jwt jwtid invalid. expected: "+n.jwtid));if(n.nonce&&A.nonce!==n.nonce)return m(new r("jwt nonce invalid. expected: "+n.nonce));if(n.maxAge){if("number"!=typeof A.iat)return m(new r("iat required when maxAge is specified"));const e=s(n.maxAge,A.iat);if(void 0===e)return m(new r('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(C>=e+(n.clockTolerance||0))return m(new i("maxAge exceeded",new Date(1e3*e)))}if(!0===n.complete){const e=T.signature;return m(null,{header:I,payload:A,signature:e})}return m(null,A)}))}},1729:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,t);return n&&n.prerelease.length?n.prerelease:null}},1741:e=>{var t=function(e,t){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,t&&(this.inner=t)};(t.prototype=Object.create(Error.prototype)).constructor=t,e.exports=t},1763:(e,t,n)=>{const r=n(560);e.exports=(e,t)=>r(e,t,!0)},1832:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,null,!0),o=r(t,null,!0),i=n.compare(o);if(0===i)return null;const c=i>0,s=c?n:o,a=c?o:n,l=!!s.prerelease.length;if(a.prerelease.length&&!l){if(!a.patch&&!a.minor)return"major";if(0===a.compareMain(s))return a.minor&&!a.patch?"minor":"patch"}const u=l?"pre":"";return n.major!==o.major?u+"major":n.minor!==o.minor?u+"minor":n.patch!==o.patch?u+"patch":"prerelease"}},1977:(e,t,n)=>{const r=n(9589);e.exports=r.satisfies(process.version,">=15.7.0")},2010:(e,t,n)=>{var r=n(2861).Buffer,o=n(3527);function i(e){if(r.isBuffer(e))return e;if("string"==typeof e)return r.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function c(e,t,n){for(var r=0;t+r<n&&0===e[t+r];)++r;return e[t+r]>=128&&--r,r}e.exports={derToJose:function(e,t){e=i(e);var n=o(t),c=n+1,s=e.length,a=0;if(48!==e[a++])throw new Error('Could not find expected "seq"');var l=e[a++];if(129===l&&(l=e[a++]),s-a<l)throw new Error('"seq" specified length of "'+l+'", only "'+(s-a)+'" remaining');if(2!==e[a++])throw new Error('Could not find expected "int" for "r"');var u=e[a++];if(s-a-2<u)throw new Error('"r" specified length of "'+u+'", only "'+(s-a-2)+'" available');if(c<u)throw new Error('"r" specified length of "'+u+'", max of "'+c+'" is acceptable');var d=a;if(a+=u,2!==e[a++])throw new Error('Could not find expected "int" for "s"');var h=e[a++];if(s-a!==h)throw new Error('"s" specified length of "'+h+'", expected "'+(s-a)+'"');if(c<h)throw new Error('"s" specified length of "'+h+'", max of "'+c+'" is acceptable');var f=a;if((a+=h)!==s)throw new Error('Expected to consume entire buffer, but "'+(s-a)+'" bytes remain');var p=n-u,y=n-h,v=r.allocUnsafe(p+u+y+h);for(a=0;a<p;++a)v[a]=0;e.copy(v,a,d+Math.max(-p,0),d+u);for(var g=a=n;a<g+y;++a)v[a]=0;return e.copy(v,a,f+Math.max(-y,0),f+h),(v=v.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=i(e);var n=o(t),s=e.length;if(s!==2*n)throw new TypeError('"'+t+'" signatures must be "'+2*n+'" bytes, saw "'+s+'"');var a=c(e,0,n),l=c(e,n,e.length),u=n-a,d=n-l,h=2+u+1+1+d,f=h<128,p=r.allocUnsafe((f?2:3)+h),y=0;return p[y++]=48,f?p[y++]=h:(p[y++]=129,p[y++]=255&h),p[y++]=2,p[y++]=u,a<0?(p[y++]=0,y+=e.copy(p,y,0,n)):y+=e.copy(p,y,a,n),p[y++]=2,p[y++]=d,l<0?(p[y++]=0,e.copy(p,y,n)):e.copy(p,y,n+l),p}}},2111:(e,t,n)=>{const r=n(4641),o=n(3999),i=n(5580),c=n(4089),s=n(7059),a=n(5200);e.exports=(e,t,n,l)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e===n;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e!==n;case"":case"=":case"==":return r(e,n,l);case"!=":return o(e,n,l);case">":return i(e,n,l);case">=":return c(e,n,l);case"<":return s(e,n,l);case"<=":return a(e,n,l);default:throw new TypeError(`Invalid operator: ${t}`)}}},2203:t=>{t.exports=e(import.meta.url)("stream")},2525:(e,t,n)=>{const r=n(7638),o=n(560);e.exports=(e,t,n)=>{const i=[];let c=null,s=null;const a=e.sort(((e,t)=>o(e,t,n)));for(const e of a)r(e,t,n)?(s=e,c||(c=e)):(s&&i.push([c,s]),s=null,c=null);c&&i.push([c,null]);const l=[];for(const[e,t]of i)e===t?l.push(e):t||e!==a[0]?t?e===a[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`):l.push("*");const u=l.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return u.length<d.length?u:t}},2851:(e,t,n)=>{var r=n(181).Buffer;e.exports=function(e){return"string"==typeof e?e:"number"==typeof e||r.isBuffer(e)?e.toString():JSON.stringify(e)}},2861:(e,t,n)=>{var r=n(181),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function c(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=c),c.prototype=Object.create(o.prototype),i(o,c),c.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},c.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},c.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},c.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},2938:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).major},3007:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n,o,i)=>{"string"==typeof n&&(i=o,o=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,o,i).version}catch(e){return null}}},3387:(e,t,n)=>{var r=n(2861).Buffer,o=n(8948),i=n(8789),c=n(2203),s=n(2851),a=n(9023);function l(e,t){return r.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function u(e){var t=e.header,n=e.payload,r=e.secret||e.privateKey,o=e.encoding,c=i(t.alg),u=function(e,t,n){n=n||"utf8";var r=l(s(e),"binary"),o=l(s(t),n);return a.format("%s.%s",r,o)}(t,n,o),d=c.sign(u,r);return a.format("%s.%s",u,d)}function d(e){var t=e.secret||e.privateKey||e.key,n=new o(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new o(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}a.inherits(d,c),d.prototype.sign=function(){try{var e=u({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},d.sign=u,e.exports=d},3527:e=>{function t(e){return(e/8|0)+(e%8==0?0:1)}var n={ES256:t(256),ES384:t(384),ES512:t(521)};e.exports=function(e){var t=n[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},3639:e=>{var t=Object.prototype.toString;e.exports=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==t.call(e)}},3726:(e,t,n)=>{var r=n(1741),o=function(e,t){r.call(this,e),this.name="NotBeforeError",this.date=t};(o.prototype=Object.create(r.prototype)).constructor=o,e.exports=o},3874:(e,t,n)=>{const r=n(8311);e.exports=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}}},3904:(e,t,n)=>{const r=Symbol("SemVer ANY");class o{static get ANY(){return r}constructor(e,t){if(t=i(t),e instanceof o){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),l("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===r?this.value="":this.value=this.operator+this.semver.version,l("comp",this)}parse(e){const t=this.options.loose?c[s.COMPARATORLOOSE]:c[s.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==n[1]?n[1]:"","="===this.operator&&(this.operator=""),n[2]?this.semver=new u(n[2],this.options.loose):this.semver=r}toString(){return this.value}test(e){if(l("Comparator.test",e,this.options.loose),this.semver===r||e===r)return!0;if("string"==typeof e)try{e=new u(e,this.options)}catch(e){return!1}return a(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof o))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new d(e.value,t).test(this.value):""===e.operator?""===e.value||new d(this.value,t).test(e.semver):!((t=i(t)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===e.value)||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))||(!this.operator.startsWith(">")||!e.operator.startsWith(">"))&&(!this.operator.startsWith("<")||!e.operator.startsWith("<"))&&(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))&&!(a(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))&&!(a(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}}e.exports=o;const i=n(8587),{safeRe:c,t:s}=n(9718),a=n(2111),l=n(7272),u=n(3908),d=n(8311)},3908:(e,t,n)=>{const r=n(7272),{MAX_LENGTH:o,MAX_SAFE_INTEGER:i}=n(6874),{safeRe:c,safeSrc:s,t:a}=n(9718),l=n(8587),{compareIdentifiers:u}=n(1123);class d{constructor(e,t){if(t=l(t),e instanceof d){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>o)throw new TypeError(`version is longer than ${o} characters`);r("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?c[a.LOOSE]:c[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(r("SemVer.compare",this.version,this.options,e),!(e instanceof d)){if("string"==typeof e&&e===this.version)return 0;e=new d(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof d||(e=new d(e,this.options)),u(this.major,e.major)||u(this.minor,e.minor)||u(this.patch,e.patch)}comparePre(e){if(e instanceof d||(e=new d(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],o=e.prerelease[t];if(r("prerelease compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}compareBuild(e){e instanceof d||(e=new d(e,this.options));let t=0;do{const n=this.build[t],o=e.build[t];if(r("build compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=new RegExp(`^${this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]}$`),n=`-${t}`.match(e);if(!n||n[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];!1===n&&(r=[t]),0===u(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=d},3927:(e,t,n)=>{const r=n(909);e.exports=(e,t)=>e.sort(((e,n)=>r(e,n,t)))},3999:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>0!==r(e,t,n)},4040:(e,t,n)=>{e.exports={decode:n(7260),verify:n(1691),sign:n(7651),JsonWebTokenError:n(1741),NotBeforeError:n(3726),TokenExpiredError:n(8980)}},4089:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)>=0},4277:(e,t,n)=>{const r=n(909);e.exports=(e,t)=>e.sort(((e,n)=>r(n,e,t)))},4493:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).patch},4623:(e,t,n)=>{const r=n(9589);e.exports=r.satisfies(process.version,">=16.9.0")},4641:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>0===r(e,t,n)},4977:(e,t,n)=>{var r=n(9589);e.exports=r.satisfies(process.version,"^6.12.0 || >=8.0.0")},5032:(e,t,n)=>{const r=n(8311),o=n(3904),{ANY:i}=o,c=n(7638),s=n(560),a=[new o(">=0.0.0-0")],l=[new o(">=0.0.0")],u=(e,t,n)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===i){if(1===t.length&&t[0].semver===i)return!0;e=n.includePrerelease?a:l}if(1===t.length&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}const r=new Set;let o,u,f,p,y,v,g;for(const t of e)">"===t.operator||">="===t.operator?o=d(o,t,n):"<"===t.operator||"<="===t.operator?u=h(u,t,n):r.add(t.semver);if(r.size>1)return null;if(o&&u){if(f=s(o.semver,u.semver,n),f>0)return null;if(0===f&&(">="!==o.operator||"<="!==u.operator))return null}for(const e of r){if(o&&!c(e,String(o),n))return null;if(u&&!c(e,String(u),n))return null;for(const r of t)if(!c(e,String(r),n))return!1;return!0}let m=!(!u||n.includePrerelease||!u.semver.prerelease.length)&&u.semver,C=!(!o||n.includePrerelease||!o.semver.prerelease.length)&&o.semver;m&&1===m.prerelease.length&&"<"===u.operator&&0===m.prerelease[0]&&(m=!1);for(const e of t){if(g=g||">"===e.operator||">="===e.operator,v=v||"<"===e.operator||"<="===e.operator,o)if(C&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===C.major&&e.semver.minor===C.minor&&e.semver.patch===C.patch&&(C=!1),">"===e.operator||">="===e.operator){if(p=d(o,e,n),p===e&&p!==o)return!1}else if(">="===o.operator&&!c(o.semver,String(e),n))return!1;if(u)if(m&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===m.major&&e.semver.minor===m.minor&&e.semver.patch===m.patch&&(m=!1),"<"===e.operator||"<="===e.operator){if(y=h(u,e,n),y===e&&y!==u)return!1}else if("<="===u.operator&&!c(u.semver,String(e),n))return!1;if(!e.operator&&(u||o)&&0!==f)return!1}return!(o&&v&&!u&&0!==f||u&&g&&!o&&0!==f||C||m)},d=(e,t,n)=>{if(!e)return t;const r=s(e.semver,t.semver,n);return r>0?e:r<0||">"===t.operator&&">="===e.operator?t:e},h=(e,t,n)=>{if(!e)return t;const r=s(e.semver,t.semver,n);return r<0?e:r>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,n={})=>{if(e===t)return!0;e=new r(e,n),t=new r(t,n);let o=!1;e:for(const r of e.set){for(const e of t.set){const t=u(r,e,n);if(o=o||null!==t,t)continue e}if(o)return!1}return!0}},5200:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)<=0},5342:(e,t,n)=>{const r=n(7075);e.exports=(e,t,n)=>r(e,t,"<",n)},5571:(e,t,n)=>{const r=n(7075);e.exports=(e,t,n)=>r(e,t,">",n)},5580:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)>0},5747:(e,t,n)=>{var r=n(3387),o=n(7599);t.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],t.sign=r.sign,t.verify=o.verify,t.decode=o.decode,t.isValid=o.isValid,t.createSign=function(e){return new r(e)},t.createVerify=function(e){return new o(e)}},5931:e=>{var t=Object.prototype.toString,n=Array.isArray;e.exports=function(e){return"string"==typeof e||!n(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==t.call(e)}},6111:e=>{var t=1/0,n=9007199254740991,r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,c=/^0o[0-7]+$/i,s=/^(?:0|[1-9]\d*)$/,a=parseInt;function l(e){return e!=e}var u,d,h=Object.prototype,f=h.hasOwnProperty,p=h.toString,y=h.propertyIsEnumerable,v=(u=Object.keys,d=Object,function(e){return u(d(e))}),g=Math.max;function m(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||s.test(e))&&e>-1&&e%1==0&&e<t}var C=Array.isArray;function w(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=T(e)?p.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)}function T(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function I(e){return!!e&&"object"==typeof e}e.exports=function(e,n,s,u){var d;e=w(e)?e:(d=e)?function(e,t){return function(t){for(var n=-1,r=t?t.length:0,o=Array(r);++n<r;)o[n]=(i=t[n],e[i]);var i;return o}(t)}(d,function(e){return w(e)?function(e,t){var n=C(e)||function(e){return function(e){return I(e)&&w(e)}(e)&&f.call(e,"callee")&&(!y.call(e,"callee")||"[object Arguments]"==p.call(e))}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var i in e)!t&&!f.call(e,i)||o&&("length"==i||m(i,r))||n.push(i);return n}(e):function(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||h))return v(e);var t,n,r=[];for(var o in Object(e))f.call(e,o)&&"constructor"!=o&&r.push(o);return r}(e)}(d)):[],s=s&&!u?function(e){var n=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||I(e)&&"[object Symbol]"==p.call(e)}(e))return NaN;if(T(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=T(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var n=i.test(e);return n||c.test(e)?a(e.slice(2),n?2:8):o.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),s=n%1;return n==n?s?n-s:n:0}(s):0;var N=e.length;return s<0&&(s=g(N+s,0)),function(e){return"string"==typeof e||!C(e)&&I(e)&&"[object String]"==p.call(e)}(e)?s<=N&&e.indexOf(n,s)>-1:!!N&&function(e,t,n){if(t!=t)return function(e,t,n){for(var r=e.length,o=n+-1;++o<r;)if(t(e[o],o,e))return o;return-1}(e,l,n);for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}(e,n,s)>-1}},6170:(e,t,n)=>{const r=n(3908),o=n(144),{safeRe:i,t:c}=n(9718);e.exports=(e,t)=>{if(e instanceof r)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){const r=t.includePrerelease?i[c.COERCERTLFULL]:i[c.COERCERTL];let o;for(;(o=r.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&o.index+o[0].length===n.index+n[0].length||(n=o),r.lastIndex=o.index+o[1].length+o[2].length;r.lastIndex=-1}else n=e.match(t.includePrerelease?i[c.COERCEFULL]:i[c.COERCE]);if(null===n)return null;const s=n[2],a=n[3]||"0",l=n[4]||"0",u=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return o(`${s}.${a}.${l}${u}${d}`,t)}},6254:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).minor},6585:e=>{var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o;function c(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,s){s=s||{};var a,l,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var c=/^(-?(?:\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(c){var s=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return s*i;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*r;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;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"===u&&isFinite(e))return s.long?(a=e,(l=Math.abs(a))>=o?c(a,l,o,"day"):l>=r?c(a,l,r,"hour"):l>=n?c(a,l,n,"minute"):l>=t?c(a,l,t,"second"):a+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=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))}},6780:(e,t,n)=>{const r=n(8311);e.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))},6874:e=>{const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},6953:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,t);return n?n.version:null}},6982:t=>{t.exports=e(import.meta.url)("crypto")},7019:(e,t,n)=>{const r=n(1977),o=n(4623),i={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},c={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};e.exports=function(e,t){if(!e||!t)return;const n=t.asymmetricKeyType;if(!n)return;const s=i[n];if(!s)throw new Error(`Unknown key type "${n}".`);if(!s.includes(e))throw new Error(`"alg" parameter for "${n}" key type must be one of: ${s.join(", ")}.`);if(r)switch(n){case"ec":const n=t.asymmetricKeyDetails.namedCurve,r=c[e];if(n!==r)throw new Error(`"alg" parameter "${e}" requires curve "${r}".`);break;case"rsa-pss":if(o){const n=parseInt(e.slice(-3),10),{hashAlgorithm:r,mgf1HashAlgorithm:o,saltLength:i}=t.asymmetricKeyDetails;if(r!==`sha${n}`||o!==r)throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${e}.`);if(void 0!==i&&i>n>>3)throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${e}.`)}}}},7059:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)<0},7075:(e,t,n)=>{const r=n(3908),o=n(3904),{ANY:i}=o,c=n(8311),s=n(7638),a=n(5580),l=n(7059),u=n(5200),d=n(4089);e.exports=(e,t,n,h)=>{let f,p,y,v,g;switch(e=new r(e,h),t=new c(t,h),n){case">":f=a,p=u,y=l,v=">",g=">=";break;case"<":f=l,p=d,y=a,v="<",g="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(s(e,t,h))return!1;for(let n=0;n<t.set.length;++n){const r=t.set[n];let c=null,s=null;if(r.forEach((e=>{e.semver===i&&(e=new o(">=0.0.0")),c=c||e,s=s||e,f(e.semver,c.semver,h)?c=e:y(e.semver,s.semver,h)&&(s=e)})),c.operator===v||c.operator===g)return!1;if((!s.operator||s.operator===v)&&p(e,s.semver))return!1;if(s.operator===g&&y(e,s.semver))return!1}return!0}},7083:e=>{var t=1/0,n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt,s=Object.prototype.toString;function a(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return function(e,l){var u;if("function"!=typeof l)throw new TypeError("Expected a function");return e=function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return NaN;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=o.test(e);return l||i.test(e)?c(e.slice(2),l?2:8):r.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),u=l%1;return l==l?u?l-u:l:0}(e),function(){return--e>0&&(u=l.apply(this,arguments)),e<=1&&(l=void 0),u}}(2,e)}},7260:(e,t,n)=>{var r=n(5747);e.exports=function(e,t){t=t||{};var n=r.decode(e,t);if(!n)return null;var o=n.payload;if("string"==typeof o)try{var i=JSON.parse(o);null!==i&&"object"==typeof i&&(o=i)}catch(e){}return!0===t.complete?{header:n.header,payload:o,signature:n.signature}:o}},7272:e=>{const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},7414:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},7599:(e,t,n)=>{var r=n(2861).Buffer,o=n(8948),i=n(8789),c=n(2203),s=n(2851),a=n(9023),l=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function u(e){var t=e.split(".",1)[0];return function(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}(r.from(t,"base64").toString("binary"))}function d(e){return e.split(".")[2]}function h(e){return l.test(e)&&!!u(e)}function f(e,t,n){if(!t){var r=new Error("Missing algorithm parameter for jws.verify");throw r.code="MISSING_ALGORITHM",r}var o=d(e=s(e)),c=function(e){return e.split(".",2).join(".")}(e);return i(t).verify(c,o,n)}function p(e,t){if(t=t||{},!h(e=s(e)))return null;var n=u(e);if(!n)return null;var o=function(e,t){t=t||"utf8";var n=e.split(".")[1];return r.from(n,"base64").toString(t)}(e);return("JWT"===n.typ||t.json)&&(o=JSON.parse(o,t.encoding)),{header:n,payload:o,signature:d(e)}}function y(e){var t=(e=e||{}).secret||e.publicKey||e.key,n=new o(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new o(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}a.inherits(y,c),y.prototype.verify=function(){try{var e=f(this.signature.buffer,this.algorithm,this.key.buffer),t=p(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},y.decode=p,y.isValid=h,y.verify=f,e.exports=y},7631:(e,t,n)=>{const r=n(8311);e.exports=(e,t)=>new r(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},7638:(e,t,n)=>{const r=n(8311);e.exports=(e,t,n)=>{try{t=new r(t,n)}catch(e){return!1}return t.test(e)}},7651:(e,t,n)=>{const r=n(855),o=n(4977),i=n(7019),c=n(5747),s=n(6111),a=n(7914),l=n(8928),u=n(3639),d=n(9001),h=n(5931),f=n(7083),{KeyObject:p,createSecretKey:y,createPrivateKey:v}=n(6982),g=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];o&&g.splice(3,0,"PS256","PS384","PS512");const m={expiresIn:{isValid:function(e){return l(e)||h(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return l(e)||h(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return h(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:s.bind(null,g),message:'"algorithm" must be a valid string enum value'},header:{isValid:d,message:'"header" must be an object'},encoding:{isValid:h,message:'"encoding" must be a string'},issuer:{isValid:h,message:'"issuer" must be a string'},subject:{isValid:h,message:'"subject" must be a string'},jwtid:{isValid:h,message:'"jwtid" must be a string'},noTimestamp:{isValid:a,message:'"noTimestamp" must be a boolean'},keyid:{isValid:h,message:'"keyid" must be a string'},mutatePayload:{isValid:a,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:a,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:a,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},C={iat:{isValid:u,message:'"iat" should be a number of seconds'},exp:{isValid:u,message:'"exp" should be a number of seconds'},nbf:{isValid:u,message:'"nbf" should be a number of seconds'}};function w(e,t,n,r){if(!d(n))throw new Error('Expected "'+r+'" to be a plain object.');Object.keys(n).forEach((function(o){const i=e[o];if(i){if(!i.isValid(n[o]))throw new Error(i.message)}else if(!t)throw new Error('"'+o+'" is not allowed in "'+r+'"')}))}const T={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},I=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];e.exports=function(e,t,n,o){"function"==typeof n?(o=n,n={}):n=n||{};const s="object"==typeof e&&!Buffer.isBuffer(e),a=Object.assign({alg:n.algorithm||"HS256",typ:s?"JWT":void 0,kid:n.keyid},n.header);function l(e){if(o)return o(e);throw e}if(!t&&"none"!==n.algorithm)return l(new Error("secretOrPrivateKey must have a value"));if(null!=t&&!(t instanceof p))try{t=v(t)}catch(e){try{t=y("string"==typeof t?Buffer.from(t):t)}catch(e){return l(new Error("secretOrPrivateKey is not valid key material"))}}if(a.alg.startsWith("HS")&&"secret"!==t.type)return l(new Error(`secretOrPrivateKey must be a symmetric key when using ${a.alg}`));if(/^(?:RS|PS|ES)/.test(a.alg)){if("private"!==t.type)return l(new Error(`secretOrPrivateKey must be an asymmetric key when using ${a.alg}`));if(!n.allowInsecureKeySizes&&!a.alg.startsWith("ES")&&void 0!==t.asymmetricKeyDetails&&t.asymmetricKeyDetails.modulusLength<2048)return l(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`))}if(void 0===e)return l(new Error("payload is required"));if(s){try{!function(e){w(C,!0,e,"payload")}(e)}catch(e){return l(e)}n.mutatePayload||(e=Object.assign({},e))}else{const t=I.filter((function(e){return void 0!==n[e]}));if(t.length>0)return l(new Error("invalid "+t.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==n.expiresIn)return l(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==n.notBefore)return l(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){w(m,!1,e,"options")}(n)}catch(e){return l(e)}if(!n.allowInvalidAsymmetricKeyTypes)try{i(a.alg,t)}catch(e){return l(e)}const u=e.iat||Math.floor(Date.now()/1e3);if(n.noTimestamp?delete e.iat:s&&(e.iat=u),void 0!==n.notBefore){try{e.nbf=r(n.notBefore,u)}catch(e){return l(e)}if(void 0===e.nbf)return l(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==n.expiresIn&&"object"==typeof e){try{e.exp=r(n.expiresIn,u)}catch(e){return l(e)}if(void 0===e.exp)return l(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(T).forEach((function(t){const r=T[t];if(void 0!==n[t]){if(void 0!==e[r])return l(new Error('Bad "options.'+t+'" option. The payload already has an "'+r+'" property.'));e[r]=n[t]}}));const d=n.encoding||"utf8";if("function"!=typeof o){let r=c.sign({header:a,payload:e,secret:t,encoding:d});if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(a.alg)&&r.length<256)throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`);return r}o=o&&f(o),c.createSign({header:a,privateKey:t,payload:e,encoding:d}).once("error",o).once("done",(function(e){if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(a.alg)&&e.length<256)return o(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`));o(null,e)}))}},7914:e=>{var t=Object.prototype.toString;e.exports=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==t.call(e)}},8311:(e,t,n)=>{const r=/\s+/g;class o{constructor(e,t){if(t=c(t),e instanceof o)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new o(e.raw,t);if(e instanceof s)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(r," "),this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!g(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&y)|(this.options.loose&&v))+":"+e,n=i.get(t);if(n)return n;const r=this.options.loose,o=r?u[d.HYPHENRANGELOOSE]:u[d.HYPHENRANGE];e=e.replace(o,b(this.options.includePrerelease)),a("hyphen replace",e),e=e.replace(u[d.COMPARATORTRIM],h),a("comparator trim",e),e=e.replace(u[d.TILDETRIM],f),a("tilde trim",e),e=e.replace(u[d.CARETTRIM],p),a("caret trim",e);let c=e.split(" ").map((e=>w(e,this.options))).join(" ").split(/\s+/).map((e=>x(e,this.options)));r&&(c=c.filter((e=>(a("loose invalid filter",e,this.options),!!e.match(u[d.COMPARATORLOOSE]))))),a("range list",c);const l=new Map,m=c.map((e=>new s(e,this.options)));for(const e of m){if(g(e))return[e];l.set(e.value,e)}l.size>1&&l.has("")&&l.delete("");const C=[...l.values()];return i.set(t,C),C}intersects(e,t){if(!(e instanceof o))throw new TypeError("a Range is required");return this.set.some((n=>C(n,t)&&e.set.some((e=>C(e,t)&&n.every((n=>e.every((e=>n.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new l(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if($(this.set[t],e,this.options))return!0;return!1}}e.exports=o;const i=new(n(8794)),c=n(8587),s=n(3904),a=n(7272),l=n(3908),{safeRe:u,t:d,comparatorTrimReplace:h,tildeTrimReplace:f,caretTrimReplace:p}=n(9718),{FLAG_INCLUDE_PRERELEASE:y,FLAG_LOOSE:v}=n(6874),g=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,C=(e,t)=>{let n=!0;const r=e.slice();let o=r.pop();for(;n&&r.length;)n=r.every((e=>o.intersects(e,t))),o=r.pop();return n},w=(e,t)=>(a("comp",e,t),e=A(e,t),a("caret",e),e=I(e,t),a("tildes",e),e=S(e,t),a("xrange",e),e=k(e,t),a("stars",e),e),T=e=>!e||"x"===e.toLowerCase()||"*"===e,I=(e,t)=>e.trim().split(/\s+/).map((e=>N(e,t))).join(" "),N=(e,t)=>{const n=t.loose?u[d.TILDELOOSE]:u[d.TILDE];return e.replace(n,((t,n,r,o,i)=>{let c;return a("tilde",e,t,n,r,o,i),T(n)?c="":T(r)?c=`>=${n}.0.0 <${+n+1}.0.0-0`:T(o)?c=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:i?(a("replaceTilde pr",i),c=`>=${n}.${r}.${o}-${i} <${n}.${+r+1}.0-0`):c=`>=${n}.${r}.${o} <${n}.${+r+1}.0-0`,a("tilde return",c),c}))},A=(e,t)=>e.trim().split(/\s+/).map((e=>E(e,t))).join(" "),E=(e,t)=>{a("caret",e,t);const n=t.loose?u[d.CARETLOOSE]:u[d.CARET],r=t.includePrerelease?"-0":"";return e.replace(n,((t,n,o,i,c)=>{let s;return a("caret",e,t,n,o,i,c),T(n)?s="":T(o)?s=`>=${n}.0.0${r} <${+n+1}.0.0-0`:T(i)?s="0"===n?`>=${n}.${o}.0${r} <${n}.${+o+1}.0-0`:`>=${n}.${o}.0${r} <${+n+1}.0.0-0`:c?(a("replaceCaret pr",c),s="0"===n?"0"===o?`>=${n}.${o}.${i}-${c} <${n}.${o}.${+i+1}-0`:`>=${n}.${o}.${i}-${c} <${n}.${+o+1}.0-0`:`>=${n}.${o}.${i}-${c} <${+n+1}.0.0-0`):(a("no pr"),s="0"===n?"0"===o?`>=${n}.${o}.${i}${r} <${n}.${o}.${+i+1}-0`:`>=${n}.${o}.${i}${r} <${n}.${+o+1}.0-0`:`>=${n}.${o}.${i} <${+n+1}.0.0-0`),a("caret return",s),s}))},S=(e,t)=>(a("replaceXRanges",e,t),e.split(/\s+/).map((e=>R(e,t))).join(" ")),R=(e,t)=>{e=e.trim();const n=t.loose?u[d.XRANGELOOSE]:u[d.XRANGE];return e.replace(n,((n,r,o,i,c,s)=>{a("xRange",e,n,r,o,i,c,s);const l=T(o),u=l||T(i),d=u||T(c),h=d;return"="===r&&h&&(r=""),s=t.includePrerelease?"-0":"",l?n=">"===r||"<"===r?"<0.0.0-0":"*":r&&h?(u&&(i=0),c=0,">"===r?(r=">=",u?(o=+o+1,i=0,c=0):(i=+i+1,c=0)):"<="===r&&(r="<",u?o=+o+1:i=+i+1),"<"===r&&(s="-0"),n=`${r+o}.${i}.${c}${s}`):u?n=`>=${o}.0.0${s} <${+o+1}.0.0-0`:d&&(n=`>=${o}.${i}.0${s} <${o}.${+i+1}.0-0`),a("xRange return",n),n}))},k=(e,t)=>(a("replaceStars",e,t),e.trim().replace(u[d.STAR],"")),x=(e,t)=>(a("replaceGTE0",e,t),e.trim().replace(u[t.includePrerelease?d.GTE0PRE:d.GTE0],"")),b=e=>(t,n,r,o,i,c,s,a,l,u,d,h)=>`${n=T(r)?"":T(o)?`>=${r}.0.0${e?"-0":""}`:T(i)?`>=${r}.${o}.0${e?"-0":""}`:c?`>=${n}`:`>=${n}${e?"-0":""}`} ${a=T(l)?"":T(u)?`<${+l+1}.0.0-0`:T(d)?`<${l}.${+u+1}.0-0`:h?`<=${l}.${u}.${d}-${h}`:e?`<${l}.${u}.${+d+1}-0`:`<=${a}`}`.trim(),$=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(a(e[n].semver),e[n].semver!==s.ANY&&e[n].semver.prerelease.length>0){const r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}},8587:e=>{const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},8789:(e,t,n)=>{var r=n(1045),o=n(2861).Buffer,i=n(6982),c=n(2010),s=n(9023),a="secret must be a string or buffer",l="key must be a string or a buffer",u="function"==typeof i.createPublicKey;function d(e){if(!o.isBuffer(e)&&"string"!=typeof e){if(!u)throw y(l);if("object"!=typeof e)throw y(l);if("string"!=typeof e.type)throw y(l);if("string"!=typeof e.asymmetricKeyType)throw y(l);if("function"!=typeof e.export)throw y(l)}}function h(e){if(!o.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw y("key must be a string, a buffer or an object")}function f(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function p(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var n=0;n<t;++n)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function y(e){var t=[].slice.call(arguments,1),n=s.format.bind(s,e).apply(null,t);return new TypeError(n)}function v(e){var t;return t=e,o.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function g(e){return function(t,n){!function(e){if(!o.isBuffer(e)){if("string"==typeof e)return e;if(!u)throw y(a);if("object"!=typeof e)throw y(a);if("secret"!==e.type)throw y(a);if("function"!=typeof e.export)throw y(a)}}(n),t=v(t);var r=i.createHmac("sha"+e,n);return f((r.update(t),r.digest("base64")))}}function m(e){return function(t,n,i){var c=g(e)(t,i);return r(o.from(n),o.from(c))}}function C(e){return function(t,n){h(n),t=v(t);var r=i.createSign("RSA-SHA"+e);return f((r.update(t),r.sign(n,"base64")))}}function w(e){return function(t,n,r){d(r),t=v(t),n=p(n);var o=i.createVerify("RSA-SHA"+e);return o.update(t),o.verify(r,n,"base64")}}function T(e){return function(t,n){h(n),t=v(t);var r=i.createSign("RSA-SHA"+e);return f((r.update(t),r.sign({key:n,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function I(e){return function(t,n,r){d(r),t=v(t),n=p(n);var o=i.createVerify("RSA-SHA"+e);return o.update(t),o.verify({key:r,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function N(e){var t=C(e);return function(){var n=t.apply(null,arguments);return c.derToJose(n,"ES"+e)}}function A(e){var t=w(e);return function(n,r,o){return r=c.joseToDer(r,"ES"+e).toString("base64"),t(n,r,o)}}function E(){return function(){return""}}function S(){return function(e,t){return""===t}}u&&(l+=" or a KeyObject",a+="or a KeyObject"),e.exports=function(e){var t={hs:g,rs:C,ps:T,es:N,none:E},n={hs:m,rs:w,ps:I,es:A,none:S},r=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);if(!r)throw y('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',e);var o=(r[1]||r[3]).toLowerCase(),i=r[2];return{sign:t[o](i),verify:n[o](i)}}},8794:e=>{e.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}},8928:e=>{var t=1/0,n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt,s=Object.prototype.toString;function a(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return"number"==typeof e&&e==function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return NaN;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=o.test(e);return l||i.test(e)?c(e.slice(2),l?2:8):r.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),u=l%1;return l==l?u?l-u:l:0}(e)}},8948:(e,t,n)=>{var r=n(2861).Buffer,o=n(2203);function i(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=r.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=r.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}n(9023).inherits(i,o),i.prototype.write=function(e){this.buffer=r.concat([this.buffer,r.from(e)]),this.emit("data",e)},i.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},e.exports=i},8980:(e,t,n)=>{var r=n(1741),o=function(e,t){r.call(this,e),this.name="TokenExpiredError",this.expiredAt=t};(o.prototype=Object.create(r.prototype)).constructor=o,e.exports=o},9001:e=>{var t,n,r=Function.prototype,o=Object.prototype,i=r.toString,c=o.hasOwnProperty,s=i.call(Object),a=o.toString,l=(t=Object.getPrototypeOf,n=Object,function(e){return t(n(e))});e.exports=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=a.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=l(e);if(null===t)return!0;var n=c.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&i.call(n)==s}},9023:t=>{t.exports=e(import.meta.url)("util")},9589:(e,t,n)=>{const r=n(9718),o=n(6874),i=n(3908),c=n(1123),s=n(144),a=n(6953),l=n(7414),u=n(3007),d=n(1832),h=n(2938),f=n(6254),p=n(4493),y=n(1729),v=n(560),g=n(9970),m=n(1763),C=n(909),w=n(3927),T=n(4277),I=n(5580),N=n(7059),A=n(4641),E=n(3999),S=n(4089),R=n(5200),k=n(2111),x=n(6170),b=n(3904),$=n(8311),L=n(7638),_=n(7631),P=n(9628),O=n(270),U=n(1261),B=n(3874),D=n(7075),F=n(5571),G=n(5342),j=n(6780),V=n(2525),M=n(5032);e.exports={parse:s,valid:a,clean:l,inc:u,diff:d,major:h,minor:f,patch:p,prerelease:y,compare:v,rcompare:g,compareLoose:m,compareBuild:C,sort:w,rsort:T,gt:I,lt:N,eq:A,neq:E,gte:S,lte:R,cmp:k,coerce:x,Comparator:b,Range:$,satisfies:L,toComparators:_,maxSatisfying:P,minSatisfying:O,minVersion:U,validRange:B,outside:D,gtr:F,ltr:G,intersects:j,simplifyRange:V,subset:M,SemVer:i,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:o.SEMVER_SPEC_VERSION,RELEASE_TYPES:o.RELEASE_TYPES,compareIdentifiers:c.compareIdentifiers,rcompareIdentifiers:c.rcompareIdentifiers}},9628:(e,t,n)=>{const r=n(3908),o=n(8311);e.exports=(e,t,n)=>{let i=null,c=null,s=null;try{s=new o(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(i&&-1!==c.compare(e)||(i=e,c=new r(i,n)))})),i}},9718:(e,t,n)=>{const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:i}=n(6874),c=n(7272),s=(t=e.exports={}).re=[],a=t.safeRe=[],l=t.src=[],u=t.safeSrc=[],d=t.t={};let h=0;const f="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[f,o]],y=(e,t,n)=>{const r=(e=>{for(const[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=h++;c(e,o,t),d[e]=o,l[o]=t,u[o]=r,s[o]=new RegExp(t,n?"g":void 0),a[o]=new RegExp(r,n?"g":void 0)};y("NUMERICIDENTIFIER","0|[1-9]\\d*"),y("NUMERICIDENTIFIERLOOSE","\\d+"),y("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),y("MAINVERSION",`(${l[d.NUMERICIDENTIFIER]})\\.(${l[d.NUMERICIDENTIFIER]})\\.(${l[d.NUMERICIDENTIFIER]})`),y("MAINVERSIONLOOSE",`(${l[d.NUMERICIDENTIFIERLOOSE]})\\.(${l[d.NUMERICIDENTIFIERLOOSE]})\\.(${l[d.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASEIDENTIFIER",`(?:${l[d.NUMERICIDENTIFIER]}|${l[d.NONNUMERICIDENTIFIER]})`),y("PRERELEASEIDENTIFIERLOOSE",`(?:${l[d.NUMERICIDENTIFIERLOOSE]}|${l[d.NONNUMERICIDENTIFIER]})`),y("PRERELEASE",`(?:-(${l[d.PRERELEASEIDENTIFIER]}(?:\\.${l[d.PRERELEASEIDENTIFIER]})*))`),y("PRERELEASELOOSE",`(?:-?(${l[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[d.PRERELEASEIDENTIFIERLOOSE]})*))`),y("BUILDIDENTIFIER",`${f}+`),y("BUILD",`(?:\\+(${l[d.BUILDIDENTIFIER]}(?:\\.${l[d.BUILDIDENTIFIER]})*))`),y("FULLPLAIN",`v?${l[d.MAINVERSION]}${l[d.PRERELEASE]}?${l[d.BUILD]}?`),y("FULL",`^${l[d.FULLPLAIN]}$`),y("LOOSEPLAIN",`[v=\\s]*${l[d.MAINVERSIONLOOSE]}${l[d.PRERELEASELOOSE]}?${l[d.BUILD]}?`),y("LOOSE",`^${l[d.LOOSEPLAIN]}$`),y("GTLT","((?:<|>)?=?)"),y("XRANGEIDENTIFIERLOOSE",`${l[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),y("XRANGEIDENTIFIER",`${l[d.NUMERICIDENTIFIER]}|x|X|\\*`),y("XRANGEPLAIN",`[v=\\s]*(${l[d.XRANGEIDENTIFIER]})(?:\\.(${l[d.XRANGEIDENTIFIER]})(?:\\.(${l[d.XRANGEIDENTIFIER]})(?:${l[d.PRERELEASE]})?${l[d.BUILD]}?)?)?`),y("XRANGEPLAINLOOSE",`[v=\\s]*(${l[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[d.XRANGEIDENTIFIERLOOSE]})(?:${l[d.PRERELEASELOOSE]})?${l[d.BUILD]}?)?)?`),y("XRANGE",`^${l[d.GTLT]}\\s*${l[d.XRANGEPLAIN]}$`),y("XRANGELOOSE",`^${l[d.GTLT]}\\s*${l[d.XRANGEPLAINLOOSE]}$`),y("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),y("COERCE",`${l[d.COERCEPLAIN]}(?:$|[^\\d])`),y("COERCEFULL",l[d.COERCEPLAIN]+`(?:${l[d.PRERELEASE]})?`+`(?:${l[d.BUILD]})?(?:$|[^\\d])`),y("COERCERTL",l[d.COERCE],!0),y("COERCERTLFULL",l[d.COERCEFULL],!0),y("LONETILDE","(?:~>?)"),y("TILDETRIM",`(\\s*)${l[d.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",y("TILDE",`^${l[d.LONETILDE]}${l[d.XRANGEPLAIN]}$`),y("TILDELOOSE",`^${l[d.LONETILDE]}${l[d.XRANGEPLAINLOOSE]}$`),y("LONECARET","(?:\\^)"),y("CARETTRIM",`(\\s*)${l[d.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",y("CARET",`^${l[d.LONECARET]}${l[d.XRANGEPLAIN]}$`),y("CARETLOOSE",`^${l[d.LONECARET]}${l[d.XRANGEPLAINLOOSE]}$`),y("COMPARATORLOOSE",`^${l[d.GTLT]}\\s*(${l[d.LOOSEPLAIN]})$|^$`),y("COMPARATOR",`^${l[d.GTLT]}\\s*(${l[d.FULLPLAIN]})$|^$`),y("COMPARATORTRIM",`(\\s*)${l[d.GTLT]}\\s*(${l[d.LOOSEPLAIN]}|${l[d.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",y("HYPHENRANGE",`^\\s*(${l[d.XRANGEPLAIN]})\\s+-\\s+(${l[d.XRANGEPLAIN]})\\s*$`),y("HYPHENRANGELOOSE",`^\\s*(${l[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[d.XRANGEPLAINLOOSE]})\\s*$`),y("STAR","(<|>)?=?\\s*\\*"),y("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),y("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},9970:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(t,e,n)}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};r.d(o,{BG:()=>ri,$e:()=>Jo,TR:()=>no,Tc:()=>ro,U3:()=>s,Wg:()=>V,g2:()=>Eo,BO:()=>Tr,WW:()=>gr,BS:()=>yr,ji:()=>M,Ij:()=>z,Ng:()=>se,du:()=>pe,RC:()=>Ft,d4:()=>kt,Cd:()=>un,IM:()=>hn,oI:()=>H,u9:()=>wn,B7:()=>jr,mF:()=>Mr,Q9:()=>Nr,wT:()=>Rt,hZ:()=>yn,y0:()=>Zo,iw:()=>ti,pU:()=>ii,qN:()=>Vn,mZ:()=>qt,Ec:()=>zt,L0:()=>mo,Te:()=>Io,vw:()=>ao,z8:()=>ne,k9:()=>Ti,sP:()=>ke,Y3:()=>Ne,WC:()=>Ni,Nj:()=>$e,dF:()=>Yn,cw:()=>Qn,p8:()=>Zn,rv:()=>tr,pX:()=>Ke,iD:()=>Xe,Mb:()=>Le,bq:()=>Ur,ke:()=>Fr,w1:()=>Dr,yz:()=>De,RW:()=>Pe,WL:()=>Ue,rh:()=>ve,nW:()=>He,RH:()=>Je,Aj:()=>$t,cV:()=>Lt,jM:()=>zn,nS:()=>Kt,Yu:()=>Co,xf:()=>jt,KS:()=>Er,L6:()=>gn,Z9:()=>mn,Ny:()=>Bn,qY:()=>Dn,jQ:()=>Xr,NT:()=>qr,Xr:()=>ee,ab:()=>te,SV:()=>Yt,EA:()=>to,M2:()=>eo,OY:()=>Ai,ry:()=>re,cS:()=>y,ZJ:()=>ei,RA:()=>Cn,BH:()=>Jr,SL:()=>oi,Ne:()=>ir,fg:()=>Bt,M4:()=>Kn,UG:()=>$n,CT:()=>nt,yv:()=>Qo,vI:()=>wo,oe:()=>Ko,XZ:()=>ni,ZE:()=>rr,pi:()=>yt,B8:()=>pt,yx:()=>wi,br:()=>Lr,eU:()=>vo,cf:()=>so,jy:()=>io,cm:()=>Xn,qn:()=>No,ss:()=>Pr,pf:()=>To,pZ:()=>lr,l4:()=>sr,f8:()=>Q,Y6:()=>Nt,FS:()=>p,bM:()=>a,ZX:()=>kr,CE:()=>Hn,Sf:()=>br,tp:()=>Qr,Ry:()=>ho,jh:()=>Sr,dp:()=>fo,a2:()=>N,C$:()=>R,J5:()=>C,sc:()=>_,x9:()=>P,Py:()=>d,Xc:()=>T,Ts:()=>Ri,P$:()=>A,xX:()=>w,ae:()=>I,zN:()=>Fe,dU:()=>Cr,mA:()=>h,En:()=>m,eD:()=>L,$Q:()=>Si});var i=r(4040),c=r.n(i);class s{static setNodeCacheUrl(e=""){this.NODE_CACHE_URL=e,this.isNearestCache=!0}static setCacheServers(e=[]){this.CACHE_SERVERS=e.filter((e=>"string"==typeof e&&""!==e.trim())),this.NODE_CACHE_URL=this.CACHE_SERVERS.length>0?this.CACHE_SERVERS[0]:"",this.isNearestCache=!0}static GetReadBaseUrl(){return this.NODE_CACHE_URL&&""!==this.NODE_CACHE_URL.trim()?this.NODE_CACHE_URL:this.BASE_URL}static GetNodeBaseUrl(){return this.NODE_URL&&""!==this.NODE_URL.trim()?this.NODE_URL:this.BASE_URL}static GetReadBaseUrlCandidates(){const e=[this.NODE_CACHE_URL,...this.CACHE_SERVERS,this.GetNodeBaseUrl(),this.BASE_URL].filter((e=>"string"==typeof e&&""!==e.trim())).map((e=>e.trim()));return Array.from(new Set(e))}static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_connection_bulk"}static GetAllConceptsOfUserUrl(){return this.BASE_URL+"/api/get_all_concepts_of_user"}static GetAllConnectionsOfUserUrl(){return this.BASE_URL+"/api/get_all_connections_of_user"}static GetConnectionsBetweenUrl(){return this.BASE_URL+"/api/get-connection-between"}static GetAllConnectionsOfCompositionUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition"}static GetAllConnectionsOfCompositionBulkUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition_bulk"}static GetConceptByCharacterValueUrl(){return this.BASE_URL+"/api/get_concept_by_character_value"}static GetConceptByCharacterAndTypeUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_type"}static GetConceptByCharacterAndCategoryUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category"}static GetConceptByCharacterAndCategoryDirectUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category_direct"}static GetCharacterByCharacterUrl(){return this.BASE_URL+"/api/get_character_by_character"}static GetAllConceptsByTypeUrl(){return this.BASE_URL+"/api/get_all_concepts_by_type"}static GetAllConnectionsOfConceptUrl(){return this.BASE_URL+"/api/get-link-connections"}static GetAllConnectionsToConceptUrl(){return this.BASE_URL+"/api/get-link-reverse-connections"}static GetAllAiData(){return this.BASE_URL+"/api/get-preloaded-concepts"}static GetAllPrefetchConnectionsUrl(){return this.BASE_URL+"/api/get_all_connections_of_user?inpage=500"}static GetAllLinkerConnectionOfConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-from-concept"}static GetAllLinkerConnectionToConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-to-concept"}static DeleteConceptUrl(){return this.BASE_URL+"/api/delete_concept"}static RecursiveSearchUrl(){return this.BASE_URL+"/api/recursivesearch-concept-connection"}static SearchLinkMultipleAllApiUrl(){return this.BASE_URL+"/api/Connection/search-link-multiple-all-ccs"}static MakeTheNameInBackendUrl(){return this.BASE_URL+"/api/make-name-from-frontend"}static LoginUrl(){return this.BASE_URL+"/api/auth/login"}static SignupUrl(){return this.BASE_URL+"/api/auth/signup"}static GetCompositionConnectionBetweenTwoConceptsUrl(){return this.BASE_URL+"/api/get-composition-connection-between-two-concepts"}static SearchCompositionsUrl(){return this.BASE_URL+"/api/search-compositions"}static SearchLinkMultipleAll(){return this.BASE_URL+"/api/Connection/search-link-multiple-all"}static CreateSessionId(){return this.BASE_URL+"/api/create-session-id-remote"}static CreateSessionVisitUrl(){return this.BASE_URL+"/api/create-remote-session-visit"}static ViewInternalDataUrl(){return this.BASE_URL+"/api/view-api-internal-data-ccs-id-bulk"}static SearchInternalWithAuthenticatedCcsUrl(){return this.BASE_URL+"/api/search-composition-internal-authenticated-ccs"}static GetReservedIdUrl(){return this.BASE_URL+"/api/get_reserved_ids"}static GetReservedConnectionIdUrl(){return this.BASE_URL+"/api/get_reserved_connection_ids"}static CreateTheTextDataUrl(){return this.BASE_URL+"/api/create_text_data"}static CreateTheCharacterDataUrl(){return this.BASE_URL+"/api/create_character_data"}static CreateTheConceptUrl(){return this.BASE_URL+"/api/create_the_concept"}static CreateTheConnectionUrl(){return this.BASE_URL+"/api/create_the_connection"}static CreateTheConnectionNewUrl(){return this.BASE_URL+"/api/create_the_connection_new"}static MakeTheTypeConceptUrl(){return this.BASE_URL+"/api/make_the_type_concept"}static CreateTypeConceptUrl(){return this.BASE_URL+"/api/create_type_concept"}static DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static DeleteTheConnectionBulkUrl(){return this.BASE_URL+"/api/delete_connection_bulk"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}static GetConceptConnectionByType(){return this.BASE_URL+"/api/get_type_concept_by_character_bulk"}static OAuthTokenUrl(){return this.BASE_URL+"/api/oauth/token"}static OAuthRefreshUrl(){return this.BASE_URL+"/api/oauth/refresh"}}s.BASE_URL="https://localhost:7053/",s.NODE_CACHE_URL="",s.CACHE_SERVERS=[],s.isNearestCache=!0,s.AI_URL="https://ai.freeschema.com",s.MQTT_URL="192.168.1.249",s.NODE_URL="";class a{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static setToken(e,t){this.BearerAccessToken=e,this.TOKEN_EXPIRY=t&&t>0?Date.now()+1e3*t:Date.now()+36e5}static isTokenExpiredOrNearExpiry(){return!!this.TOKEN_EXPIRY&&Date.now()>=this.TOKEN_EXPIRY-this.EXPIRY_BUFFER_MS}static getTimeUntilExpiry(){if(!this.TOKEN_EXPIRY)return-1;const e=Date.now(),t=this.TOKEN_EXPIRY-e;return t>0?Math.floor(t/1e3):-1}static hasOAuthCredentials(){return!!(this.CLIENT_ID&&this.CLIENT_SECRET&&this.APPLICATION_NAME)}static setOAuthCredentials(e,t,n){this.CLIENT_ID=e,this.CLIENT_SECRET=t,this.APPLICATION_NAME=n}static setDefaultIdentity(e,t,n,r){this.DEFAULT_USER_ID=e,this.DEFAULT_USER_CONCEPT_ID=t,this.DEFAULT_ENTITY_ID=n,this.DEFAULT_SESSION_ID=r}}a.BearerAccessToken="",a.CLIENT_ID="",a.CLIENT_SECRET="",a.APPLICATION_NAME="",a.TOKEN_EXPIRY=0,a.EXPIRY_BUFFER_MS=3e5,a.DEFAULT_USER_ID=0,a.DEFAULT_USER_CONCEPT_ID=0,a.DEFAULT_ENTITY_ID=0,a.DEFAULT_SESSION_ID=0;var l=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function u(e){try{const t=c().decode(e);if(!t)return;a.setDefaultIdentity(Number(t.unique_name)||0,Number(t.upn)||0,Number(t.EntityId)||0,Number(t.primarysid)||0)}catch(e){}}function d(e,t,n){return l(this,arguments,void 0,(function*(e,t,n,r=!0){try{const o=s.OAuthTokenUrl(),i=new URLSearchParams;i.append("client_id",e),i.append("client_secret",t),i.append("application_name",n);const c=yield fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i.toString()});if(c.ok){let e="",t="Bearer",n=0;const o=c.headers.get("content-type");if(o&&o.includes("application/json"))try{const r=yield c.json();e=r.access_token||"",t=r.token_type||"Bearer",n=r.expires_in||0}catch(t){e=yield c.text()}else e=yield c.text();return e?(r&&(a.setToken(e,n),u(e)),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield c.text();return{success:!1,error:`HTTP ${c.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}function h(e,t,n){return l(this,arguments,void 0,(function*(e,t,n,r=!0){try{const o=s.OAuthRefreshUrl(),i=new URLSearchParams;i.append("client_id",e),i.append("client_secret",t),i.append("refresh_token",n),i.append("grant_type","refresh_token");const c=yield fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i.toString()});if(c.ok){let e="",t="Bearer",n=0;const o=c.headers.get("content-type");if(o&&o.includes("application/json"))try{const r=yield c.json();e=r.access_token||"",t=r.token_type||"Bearer",n=r.expires_in||0}catch(t){e=yield c.text()}else e=yield c.text();return e?(r&&(a.setToken(e,n),u(e)),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield c.text();return{success:!1,error:`HTTP ${c.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}var f=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class p extends Error{constructor(e){super(e),this.name="TokenRefreshError"}}class y{constructor(e,t,n){this.status=e,this.body=t,this.headers=n}json(){return f(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return f(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function v(){return f(this,void 0,void 0,(function*(){if(!a.hasOAuthCredentials())return!1;try{return(yield d(a.CLIENT_ID,a.CLIENT_SECRET,a.APPLICATION_NAME,!0)).success}catch(e){return console.error("Token refresh failed:",e),!1}}))}const g=3e4;function m(e,t,n,r){return f(this,arguments,void 0,(function*(e,t,n,r,o=1,i=g){var c,s;const l=Object.assign(Object.assign({},n),a.getAuthHeader()),u=["GET","HEAD","OPTIONS"].includes(e.toUpperCase());for(let n=0;n<=o;n++){const d=new AbortController,h=setTimeout((()=>d.abort()),i);try{const i={method:e,headers:l,signal:d.signal};if(void 0!==r){const e=r instanceof URLSearchParams||"undefined"!=typeof FormData&&r instanceof FormData||"undefined"!=typeof Blob&&r instanceof Blob||r instanceof ArrayBuffer||ArrayBuffer.isView(r);"object"!=typeof r||e?i.body=r:(l["Content-Type"]||l["content-type"]||(l["Content-Type"]="application/json"),(null===(c=l["Content-Type"])||void 0===c?void 0:c.includes("application/json"))||(null===(s=l["content-type"])||void 0===s?void 0:s.includes("application/json"))?i.body=JSON.stringify(r):i.body=r)}i.headers=l;const u=yield fetch(t,i),h=yield u.text(),f={};if(u.headers.forEach(((e,t)=>{f[t]=e})),401!==u.status)return new y(u.status,h,f);if(n<o){if(yield v()){Object.assign(l,a.getAuthHeader());continue}throw new p("Token refresh failed. Please check OAuth credentials.")}return new y(u.status,h,f)}catch(e){if(e instanceof p)throw e;if(n>=o||!u)throw e;console.error(`Request failed (attempt ${n+1}/${o+1}):`,e)}finally{clearTimeout(h)}}throw new Error("Request failed after all retry attempts")}))}function C(e){return f(this,arguments,void 0,(function*(e,t={},n=1){return m(t.method||"GET",e,function(e){if(e){if(e instanceof Headers){const t={};return e.forEach(((e,n)=>{t[n]=e})),t}return Array.isArray(e)?e.reduce(((e,[t,n])=>(e[t]=n,e)),{}):e}}(t.headers),t.body,n)}))}function w(e,t,n){return f(this,void 0,void 0,(function*(){return m("POST",e,t,n)}))}function T(e,t,n){return f(this,void 0,void 0,(function*(){let r=e;if(n){const t=[];for(const e in n)n.hasOwnProperty(e)&&t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n[e]))}`);t.length>0&&(r=`${e}?${t.join("&")}`)}return m("GET",r,t)}))}function I(e,t,n){return f(this,void 0,void 0,(function*(){return m("PUT",e,t,n)}))}function N(e,t){return f(this,void 0,void 0,(function*(){return m("DELETE",e,t)}))}function A(e,t,n){return f(this,void 0,void 0,(function*(){return m("PATCH",e,t,n)}))}var E=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function S(e,t){return`${e.replace(/\/+$/,"")}${t}`}function R(e){return E(this,arguments,void 0,(function*(e,t={},n=1){const r=s.GetReadBaseUrlCandidates();let o;for(const i of r){try{const r=yield C(S(i,e),t,n);if(i.replace(/\/+$/,"")===s.BASE_URL.replace(/\/+$/,""))return r;if(r.ok)return s.NODE_CACHE_URL=i,r;o=new Error(`Cache server ${i} returned status ${r.status}`)}catch(e){o=e}s.isNearestCache=!1}throw o instanceof Error?o:new Error("All cache servers failed")}))}class k{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var x=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const b={};function $(e){return b[e]||(b[e]=[]),b[e]}function L(e,t){const n=$(e);if(t&&"number"==typeof t.id){const e=n.findIndex((e=>e&&e.id===t.id));if(e>=0)return void(n[e]=t)}n.push(t)}function _(e,t,n){return x(this,void 0,void 0,(function*(){return $(e).filter((e=>e&&e[t]===n))}))}function P(e){return x(this,void 0,void 0,(function*(){return $(e).slice()}))}function O(e,t){const n=$(e),r=n.findIndex((e=>e&&e.id===t));r>=0&&n.splice(r,1)}function U(e){return x(this,void 0,void 0,(function*(){return $(e).slice()}))}class B{}B.isTypeLoaded=!1,B.isCharacterLoaded=!1,B.isDataLoaded=!1,B.isLocalDataLoaded=!1,B.isLocalCharacterLoaded=!1,B.isLocalTypeLoaded=!1,B.isConnectionLoaded=!1,B.isConnectionTypeLoaded=!1,B.isLocalConnectionLoaded=!1;class D{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var F=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class G{static waitForDataToLoad(){return F(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isCharacterLoaded)return e("done");setTimeout(G.checkFlag,1e3,e)}static addNodeToTree(e){return F(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=e,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(e,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(e,t){return F(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,e,t)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(e){if(""!=e.characterValue){var t=new D(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(e,t){return F(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return F(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(e,t,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(e){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,e))}}G.characterRoot=null;var j=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class V{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return j(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isDataLoaded)return e("done");setTimeout(V.checkFlag,1e3,e)}static addConceptToTree(e){var t=new D(e.id,e,null,null),n=new D(e.characterValue,e,null,null);G.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return j(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return j(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}V.root=null;class M{constructor(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p,y=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=e,this.userId=t,this.typeId=n,this.typeUserId=r,this.ghostId=e,this.categoryId=o,this.categoryUserId=i,this.referentId=c,this.referentUserId=s,this.characterValue=`${a}`,this.securityId=l,this.securityUserId=u,this.accessId=d,this.accessUserId=h,this.sessionInformationId=f,this.sessionInformationUserId=p,this.x=0,this.y=0,this.type=null,this.isNew=y,this.entryTimeStamp=v,this.updatedTimeStamp=g}getType(){console.log(this.typeId)}}function H(){let e=W(new Date),t=W(new Date);return new M(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function W(e){const t=e.getMonth()+1,n=e.getDate(),r=e.getFullYear();let o=e.getHours();const i=e.getMinutes(),c=e.getSeconds(),s=o>=12?"PM":"AM";o%=12,o=o||12;const a=e=>e.toString().padStart(2,"0");return`${t}/${n}/${r} ${o}:${a(i)}:${a(c)} ${s}`}var K=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class X{static addNodeToTree(e){return K(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=e,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(e,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new D(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,e,t))}static getNodeFromTree(e){return this.typeRoot?this.typeRoot.getFromNode(e,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return K(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isTypeLoaded)return e("done");setTimeout(X.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return K(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)if(r.variants[e].value.userId==t){var o=!1;for(let t=0;t<n.length;t++)n[t].id==r.variants[e].value.id&&(o=!0);o||n.push(r.variants[e].value)}}return n}))}static getTypeVariantsWithCharacterValue(e,t){return K(this,void 0,void 0,(function*(){let n=H();var r=this.getNodeFromTree(t);if(r){r.value.characterValue==e&&(n=r.value);for(let t=0;t<r.variants.length;t++)r.variants[t].value.characterValue==e&&(n=r.variants[t].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}X.typeRoot=null;var q=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class z{constructor(){this.name="conceptsArray"}static RemoveExpiredNpc(e=Date.now()){this.NPC=this.NPC.filter((t=>{const n=this.NPCMeta.get(t);return n&&n.expiresAt>e}))}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){var t;const n=Date.now();this.RemoveExpiredNpc(n),this.NPC.includes(e)||this.NPC.push(e);const r=this.NPCMeta.get(e),o=(null!==(t=null==r?void 0:r.attempts)&&void 0!==t?t:0)+1;this.NPCMeta.set(e,{attempts:o,expiresAt:n+o*this.NPC_BACKOFF_SECONDS*1e3})}static GetNpc(e){const t=Date.now();this.RemoveExpiredNpc(t);const n=this.NPCMeta.get(e);return!!(n&&n.expiresAt>t)}static AddConceptToStorage(e){e.id>0&&L("concept",e)}static AddConcept(e){e.id>0&&(L("concept",e),V.addConceptToTree(e),X.addConceptToTree(e),G.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(V.addConceptToTree(e),X.addConceptToTree(e),G.addConceptToTree(e))}static AddConceptTemporary(e){var t=this.CheckContains(e);this.conceptDictionary[e.id]=e,t&&this.RemoveConcept(e),this.conceptsArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsArray.length;t++)this.conceptsArray[t].id==e.id&&this.conceptsArray.splice(t,1);V.removeNodeFromTree(e.id),O("concept",e.id)}static GetConcept(e){return q(this,void 0,void 0,(function*(){var t=H(),n=yield V.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConceptByCharacter(e){return q(this,void 0,void 0,(function*(){var t=H(),n=G.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return q(this,void 0,void 0,(function*(){var t=H(),n=G.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return q(this,void 0,void 0,(function*(){return H(),yield X.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return q(this,void 0,void 0,(function*(){var n=H(),r=yield G.getCharacterAndCategoryFromTree(e,t);return r&&(n=r.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==e&&t.push(this.conceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return q(this,void 0,void 0,(function*(){let n=[];return n=yield X.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return G.characterRoot}getName(){return this.name}}z.conceptsArray=[],z.NPC=[],z.NPCMeta=new Map,z.NPC_BACKOFF_SECONDS=30,z.conceptDictionary=[];var J=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Y(){return J(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield P("concept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];z.AddConceptToMemory(n)}(new Date).getTime()}))}function Q(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}var Z=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ee(){return Z(this,arguments,void 0,(function*(e="application/json",t="application/json"){if(a.isTokenExpiredOrNearExpiry()&&a.hasOAuthCredentials()){const e=yield d(a.CLIENT_ID,a.CLIENT_SECRET,a.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+a.BearerAccessToken,Accept:t}}))}function te(){return Z(this,arguments,void 0,(function*(e="application/json",t="",n="application/json"){if(""!==t)return{"Content-Type":e,Authorization:"Bearer "+t,Accept:n};if(a.isTokenExpiredOrNearExpiry()&&a.hasOAuthCredentials()){const e=yield d(a.CLIENT_ID,a.CLIENT_SECRET,a.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+a.BearerAccessToken,Accept:n}}))}class ne{constructor(e,t,n,r){this.url=s.BASE_URL,this.message=e,this.ok=t,this.status=n,this.data=r}getMessage(){return this.message}setMessage(e){return this.message=e,this}getStatus(){return this.status}setStatus(e){return this.status=e,this}getData(){return this.data}setData(e){return this.data=e,this}getOk(){return this.ok}setOk(e){return this.ok=e,this}getUrl(){return this.url}setUrl(e){return this.url=e,this}}function re(e){if(!e.ok){const t=e instanceof y,n=t?e.body||`HTTP error ${e.status}`:e.statusText||`HTTP error ${e.status}`;let r=new ne(n,!1,e.status,"");throw r.setUrl(t?e.headers.url||"":e.url),r}}function oe(e){if(!e.ok){const t=e.body||`HTTP error ${e.status}`;let n=new ne(t,!1,e.status,e.body);throw n.setUrl(e.headers.url||""),n}}var ie=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ce(e,t){return ie(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",e),n.append("user_id",t.toString());var r=yield ee("application/x-www-form-urlencoded");const i=yield C(s.GetAllConceptsByTypeUrl(),{method:"POST",headers:r,body:n});if(i.ok){const e=yield i.json();for(var o=0;o<e.length;o++)z.AddConcept(e[o])}console.log("GetAllConceptsByType error",i.status),re(i)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class se{constructor(e=0,t,n,r,o,i,c,s,a,l,u,d,h,f,p,y){this.isTemp=!1,this.toUpdate=!1,this.type=H(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.ofTheConceptUserId=r,this.toTheConceptUserId=o,this.userId=i,this.typeId=c,this.ghostId=e,this.typeUserId=s,this.orderId=a,this.orderUserId=l,this.securityId=u,this.securityUserId=d,this.accessId=h,this.accessUserId=f,this.sessionInformationId=p,this.sessionInformationUserId=y,this.entryTimeStamp=W(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class ae{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;e.value.id==t.value.id&&(n=!0);for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var le=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class ue{static addNodeToTree(e){if(null==this.connectionroot)return this.connectionroot=e,this.connectionroot;this.connectionroot=this.connectionroot.addNode(e,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(e){var t=new ae(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return le(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isConnectionLoaded)return e("done");setTimeout(ue.checkFlag,1e3,e)}static removeNodeFromTree(e){return le(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return le(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}ue.connectionroot=null;var de=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class he{static addNodeToTree(e){return de(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=e,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(e,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return de(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isConnectionTypeLoaded)return e("done");setTimeout(he.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new ae(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,e,t))}static getNodeFromTree(e){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(e){return de(this,void 0,void 0,(function*(){var t=[],n=this.getNodeFromTree(e);if(n){t.push(null==n?void 0:n.value);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value);return t}}))}static getTypeVariantsFromTreeWithUserId(e,t){return de(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)r.variants[e].value.userId==t&&n.push(r.variants[e].value)}return n}))}}he.connectionTypeRoot=null;var fe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class pe{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){L("connection",e)}static AddConnection(e){e.isTemp||(L("connection",e),ue.addConnectionToTree(e),he.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(ue.addConnectionToTree(e),he.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(O("connection",e.id),ue.removeNodeFromTree(e.id),he.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return ue.connectionroot}static GetConnectionTypeTree(){return he.connectionTypeRoot}static GetConnection(e){return fe(this,void 0,void 0,(function*(){var t=new se(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield ue.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConnectionsOfCompositionLocal(e){return fe(this,void 0,void 0,(function*(){var t=[],n=yield he.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;if(r){let e=r;t.push(e);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value)}}return t}))}getName(){return this.name}}pe.connectionArray=[],pe.connectionDictionary=[];var ye=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ve(e){return ye(this,void 0,void 0,(function*(){let t=[];try{var n=[];for(let r=0;r<e.length;r++){let o=yield z.GetConcept(e[r]);0==o.id?n.push(e[r]):t.push(o)}if(0==n.length)return t;{const e=JSON.stringify(n);var r=yield ee();const o=yield R("/api/get_concept_bulk",{method:"POST",headers:r,body:e});if(o.ok){let e=yield o.json();if(e.length>0)for(let n=0;n<e.length;n++){let r=e[n];t.push(r),z.AddConcept(r)}}else console.log("Get Concept Bulk error",o.status),re(o);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var ge=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function me(){return ge(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length>0){for(let n=0;n<e.length;n++)t.includes(e[n].ofTheConceptId)||t.push(e[n].ofTheConceptId),t.includes(e[n].toTheConceptId)||t.push(e[n].toTheConceptId);yield ve(t)}}))}var Ce=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function we(){return Ce(this,arguments,void 0,(function*(e=[]){var t=[];for(let r=0;r<e.length;r++){var n=yield pe.GetConnectionsOfCompositionLocal(e[r]);t.push(...n)}return t}))}function Te(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||pe.RemoveConnection(t[n]))}var Ie=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ne(){return Ie(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var n=yield we(e),r=yield function(){return Ie(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=yield ee();const o=yield C(s.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(o.ok){const e=yield o.json();for(var r=0;r<e.length;r++)pe.AddConnection(e[r]),t.push(e[r])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),re(o);return t}catch(e){throw e instanceof Error?console.log("Get all connections of composition bulk error message: ",e.message):console.log("Get all connections of composition bulk unexpected error: ",e),e}}))}(e);return Te(t=r,n),yield me(t),t}))}var Ae=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Ee=new Map;function Se(e){return Ae(this,void 0,void 0,(function*(){let t=H();if(Ee.has(e))return Ee.get(e)||t;const n=(()=>Ae(this,void 0,void 0,(function*(){try{var n=yield z.GetConcept(e);let o=z.GetNpc(e);if(0!=n.id||o)return n;{var r=yield ee("application/x-www-form-urlencoded");const n=yield C(s.GetConceptUrl(),{method:"POST",headers:r,body:`id=${e}`});return n.ok?(t=yield n.json(),t.id>0?z.AddConcept(t):z.AddNpc(e)):(console.log("Get the concept error",n.status,e),re(n)),t}}catch(t){throw t instanceof Error?console.log("Get the concept error message: ",t.message,e):console.log("Get the concept unexpected error: ",t,e),t}finally{Ee.delete(e)}})))();return Ee.set(e,n),n}))}var Re=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ke(e){return Re(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield pe.GetConnectionsOfCompositionLocal(e)).length)t=yield xe(e);else{var n=yield xe(e);Te(n,t),t=n}return t}))}function xe(e){return Re(this,void 0,void 0,(function*(){var t=[];try{var n=yield ee("application/x-www-form-urlencoded");const o=yield C(s.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${e}`});if(!o.ok)throw re(o),new Error(`Error! status: ${o.status}`);const i=yield o.json();for(var r=0;r<i.length;r++)pe.AddConnection(i[r]),t.push(i[r]);return t}catch(e){throw e instanceof Error?console.log("Get all connection of composition error : ",e.message):console.log("Get all connection of composition error : ",e),e}}))}var be=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function $e(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield ke(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function Le(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield ke(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Ge(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function _e(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield pe.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function Pe(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield pe.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=o,l.id=e,l}))}function Oe(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield pe.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=o,l.id=e,l.created_at=s.entryTimeStamp,l}))}function Ue(e,t){return be(this,void 0,void 0,(function*(){for(var n,r,o={},i=[],c=0;c<t.length;c++)i.includes(t[c].ofTheConceptId)||i.push(t[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,t,i);o[null!==(r=null===(n=null==s?void 0:s.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=o,l.id=e,l}))}function Be(e,t){return be(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i={},c=yield z.GetConcept(e);0==c.id&&null!=e&&null!=e&&(c=yield Se(e));var s=yield Fe(e,t,n);i[null!==(o=null===(r=null==c?void 0:c.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:""]=s;var a={};return a.created_at=c.entryTimeStamp,a.data=i,a.id=e,a}))}function De(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield ke(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=o,l.id=e,l}))}function Fe(e,t,n){return be(this,arguments,void 0,(function*(e,t,n,r=[]){var o,i,c,s={},a=[];if(0==e)return null;var l=yield z.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Se(e)),0!=l.id&&null==l.type){var u=l.typeId,d=yield z.GetConcept(u);l.type=d,null==d&&null!=u&&null!=u&&(d=yield Se(u),l.type=d)}if(null===(o=null==l?void 0:l.type)||void 0===o?void 0:o.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(r.includes(e))return"";r.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,p=yield z.GetConcept(f);null!=p&&0!=p.id||null==f||null==f||(p=yield Se(f)),p&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield z.GetConcept(u),p.type=d,null==d&&null!=u&&null!=u&&(d=yield Se(u),p.type=d));var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield Fe(f,t,n,r);s[y]=e}}else{const e=yield Fe(f,t,n,r);a[y]=e,s=a}}return s}))}function Ge(e,t,n){return be(this,arguments,void 0,(function*(e,t,n,r=[]){var o,i,c,s={},a=[];if(0==e)return null;var l=yield z.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Se(e)),0!=l.id&&null==l.type){var u=l.typeId,d=yield z.GetConcept(u);l.type=d,null==d&&null!=u&&null!=u&&(d=yield Se(u),l.type=d)}if(null===(o=null==l?void 0:l.type)||void 0===o?void 0:o.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(r.includes(e))return"";r.push(e),s.id=e;for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,p=yield z.GetConcept(f);null!=p&&0!=p.id||null==f||null==f||(p=yield Se(f)),p&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield z.GetConcept(u),p.type=d,null==d&&null!=u&&null!=u&&(d=yield Se(u),p.type=d));var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield Ge(f,t,n);s[y]=e}}else{const e=yield Ge(f,t,n);a[y]=e,s=a}}return s}))}var je=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ve(e){return je(this,void 0,void 0,(function*(){let t=H();try{var n=yield ee("application/x-www-form-urlencoded");const r=yield C(s.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${e}`});return r.ok?(t=yield r.json(),t.id>0&&z.AddConcept(t)):(console.log("Error in Getting concept by character value Error",r.status),re(r)),t}catch(e){throw e instanceof Error?console.log("Error in Getting concept by character value error message: ",e):console.log("Error in Getting concept by character value unexpected error: ",e),e}}))}var Me=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function He(e){return Me(this,void 0,void 0,(function*(){var t=yield z.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield Ve(e),t=yield z.GetConceptByCharacter(e)),t}))}var We=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ke(e,t){return We(this,arguments,void 0,(function*(e,t,n=10,r=1){var o=yield He(e),i=[];if(o){yield ce(e,t);for(var c=yield z.GetConceptsByTypeIdAndUser(o.id,t),s=n*(r-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield Ne(a),l=s;l<s+n;l++)if(c[l]){var u=yield _e(c[l].id);i.push(u)}}return i}))}function Xe(e,t){return We(this,arguments,void 0,(function*(e,t,n=10,r=1){var o=yield He(e),i=[];if(o){yield ce(e,t);for(var c=yield z.GetConceptsByTypeIdAndUser(o.id,t),s=n*(r-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield Ne(a),l=s;l<s+n;l++)if(c[l]){var u=yield Pe(c[l].id);i.push(u)}}return i}))}var qe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const ze=new Map;function Je(e,t){return qe(this,void 0,void 0,(function*(){let n=H();if(ze.has(e+t))return ze.get(e+t)||n;const r=(()=>qe(this,void 0,void 0,(function*(){try{var r=yield ee("application/x-www-form-urlencoded");const o=yield C(s.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:r,body:`character_value=${e}&category_id=${t}`});if(o.ok){let e=yield o.json();n=e,z.AddConcept(n)}else console.log("This is the concept by category and character direct api error",o.status),re(o);return n}catch(n){throw n instanceof Error?console.log(" This is the concept by category and character direct api error message: ",n.message,e,t,s.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",n,e,t,s.GetConceptByCharacterAndCategoryDirectUrl()),n}finally{ze.delete(e+t)}})))();return ze.set(e+t,r),r}))}var Ye=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Qe(e){return Ye(this,void 0,void 0,(function*(){let t=H();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var r=Q(e);if(r.length>1){let n=1,o=yield Qe(r[0]);0!=o.id&&(n=o.id),t=yield function(e,t){return Ye(this,void 0,void 0,(function*(){let n=yield z.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield Je(e,t)),n}))}(e,n)}else r[0]==e&&1==n?t=yield function(e){return Ye(this,void 0,void 0,(function*(){var t=yield z.GetConceptByCharacterAndTypeLocal(e,49);return 0==t.id&&(t=yield Ve(e)),t}))}(e):r[0]==e&&(t=yield function(e){return Ye(this,void 0,void 0,(function*(){var t=yield z.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield Ve(e)),t}))}(e));return t}))}var Ze=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const et=new Map,tt=new Map;function nt(e,t){return Ze(this,void 0,void 0,(function*(){let t=H();if(tt.has(e))return tt.get(e);if(et.has(e))return et.get(e)||t;const n=(()=>Ze(this,void 0,void 0,(function*(){try{if(t=yield Qe(e),0==t.id||4==t.typeId){var n=yield ee("application/x-www-form-urlencoded");const r=yield C(s.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${e}`});if(!r.ok)throw re(r),new Error(`Error! status: ${r.status}`);let o=yield r.json();t=o,t.id>0&&z.AddConcept(t)}return t.id>0&&tt.set(e,t),t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{et.delete(e)}})))();return et.set(e,n),n}))}var rt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};let ot=!1,it=[];const ct=()=>{it.length>0&&!ot&&it.shift()()};function st(e){return rt(this,void 0,void 0,(function*(){return new Promise(((t,n)=>{it.push((()=>rt(this,void 0,void 0,(function*(){try{if(ot)return;if(ot=!0,!e&&yt.connectionIds.length>10)return ot=!1,ct(),t();const n=e?`${s.GetReservedConnectionIdUrl()}?${new URLSearchParams({count:String(e)}).toString()}`:s.GetReservedConnectionIdUrl();var r=yield ee("application/x-www-form-urlencoded");const i=yield C(n,{method:"GET",headers:r});if(!i.ok)throw re(i),new Error(`Error! status: ${i.status}`);const c=yield i.json();for(var o=0;o<c.length;o++)yt.AddId(c[o]);t()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),n(e)}finally{ot=!1,ct()}})))),ct()}))}))}var at=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};let lt=!1,ut=[];const dt=()=>{ut.length>0&&!lt&&ut.shift()()};function ht(){return at(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{ut.push((()=>at(this,void 0,void 0,(function*(){try{if(lt)return;if(lt=!0,pt.ids.length>10)return lt=!1,dt(),e();var n=yield ee("application/x-www-form-urlencoded");const t=yield C(s.GetReservedIdUrl(),{method:"GET",headers:n});if(!t.ok)throw re(t),new Error(`Error! status: ${t.status}`);const o=yield t.json();for(var r=0;r<o.length;r++)pt.AddId(o[r]);e()}catch(e){t(e)}finally{lt=!1,dt()}})))),dt()}))}))}var ft=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class pt{static getId(){return ft(this,void 0,void 0,(function*(){for(this.ids.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ft(this,void 0,void 0,(function*(){try{yield ht()}finally{this.pendingFetch=null}})))(),this.ids.length>0&&this.pendingFetch.catch((e=>console.error("Reserved ID refill failed:",e))));0===this.ids.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ft(this,void 0,void 0,(function*(){try{yield ht()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.ids.length)throw new Error("No reserved concept IDs were returned by the backend.");return this.ids.shift()}))}static AddId(e){Number.isFinite(e)&&e>0&&!this.ids.includes(e)&&this.ids.push(e)}}pt.ids=[],pt.pendingFetch=null;class yt{static getId(){return ft(this,void 0,void 0,(function*(){for(this.connectionIds.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>ft(this,void 0,void 0,(function*(){try{yield st()}finally{this.pendingFetch=null}})))());0===this.connectionIds.length;)if(this.pendingFetch||(this.pendingFetch=(()=>ft(this,void 0,void 0,(function*(){try{yield st()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.connectionIds.length)throw new Error("No reserved connection IDs were returned by the backend.");return this.connectionIds.shift()}))}static AddId(e){Number.isFinite(e)&&e>0&&!this.connectionIds.includes(e)&&this.connectionIds.push(e)}static warmUp(e){return ft(this,void 0,void 0,(function*(){const t=e-this.connectionIds.length;t<=0||(this.pendingFetch||(this.pendingFetch=(()=>ft(this,void 0,void 0,(function*(){try{yield st(t)}finally{this.pendingFetch=null}})))()),yield this.pendingFetch)}))}}yt.connectionIds=[],yt.pendingFetch=null;function vt(e){return{id:e.id,userId:e.userId,characterValue:e.characterValue,typeId:e.typeId,categoryId:e.categoryId,accessId:e.accessId,referentId:e.referentId,sessionInformationId:e.sessionInformationId}}function gt(e){return t=this,n=void 0,o=function*(){let t=H();try{var n=yield ee();const r=function(e){return Array.isArray(e)?e.map((e=>vt(e))):vt(e)}(e),o=yield w(s.CreateTheConceptUrl(),n,r);if(!o.ok)throw oe(o),new Error(`Error! status: ${o.status}`);return t=yield o.json(),t}catch(e){throw e instanceof Error?console.log("Create the concept api error message: ",e):console.log("Create the concept api unexpected error: ",e),e}},new((r=void 0)||(r=Promise))((function(e,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(c,s)}a((o=o.apply(t,n||[])).next())}));var t,n,r,o}function mt(e){return t=this,n=void 0,o=function*(){let t=new se(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var n=yield ee();const r=function(e){return e.map((e=>function(e){return{id:e.id,ofTheConceptId:e.ofTheConceptId,toTheConceptId:e.toTheConceptId,ofTheConceptUserId:e.ofTheConceptUserId,toTheConceptUserId:e.toTheConceptUserId,typeId:e.typeId,userId:e.userId,orderId:e.orderId,accessId:e.accessId,sessionInformationId:e.sessionInformationId}}(e)))}(e),o=yield w(s.CreateTheConnectionUrl(),n,r);if(!o.ok)throw console.log("Create the connection error message: ",o),oe(o),new Error(`Error! status: ${o.status}`);return t=yield o.json(),t}catch(e){throw e instanceof Error?console.log("Create the connection error message: ",e.message):console.log(" Create the connection unexpected error: ",e),e}},new((r=void 0)||(r=Promise))((function(e,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(c,s)}a((o=o.apply(t,n||[])).next())}));var t,n,r,o}var Ct=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function wt(e){return e?`[SyncData:${e}]`:"[SyncData]"}function Tt(e,t){console.log(`${wt(t)} ${e}`)}function It(e,t,n,r,o){r<100&&n!==r||n!==r&&1!==n&&n%100!=0||console.log(`${wt(o)} ${e} ${t}: ${n}/${r} done, ${r-n} remaining`)}class Nt{static CheckContains(e){for(var t=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==e.id&&(t=!0);return t}static SyncDataDelete(e){for(var t=0;t<this.conceptsSyncArray.length;t++)e==this.conceptsSyncArray[t].id&&this.conceptsSyncArray.splice(t,1);for(t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].ofTheConceptId!=e&&this.connectionSyncArray[t].toTheConceptId!=e&&this.connectionSyncArray[t].typeId!=e||this.connectionSyncArray.splice(t,1)}static CheckContainsConnection(e){for(var t=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==e.id&&(t=!0);return t}static AddConcept(e){this.conceptsSyncArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsSyncArray.length;t++)this.conceptsSyncArray[t].id==e.id&&this.conceptsSyncArray.splice(t,1)}static AddConnection(e){this.connectionSyncArray.push(e)}static RemoveConnection(e){for(var t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].id==e.id&&this.connectionSyncArray.splice(t,1)}static SyncDataOnline(e){return Ct(this,void 0,void 0,(function*(){try{let t=[],n=[];if(e&&this.transactionCollections.some((t=>t.id==e))){const r=this.transactionCollections.find((t=>t.id==e));if(this.transactionCollections=this.transactionCollections.filter((t=>t.id==e||new Date(t.createdDate).getTime()>(new Date).getTime()-6048e5)),!r)return;t=r.data.concepts.slice(),n=r.data.connections.slice(),Tt(`starting online sync with ${t.length} concepts and ${n.length} connections`,e),t.length>0&&(Tt(`sending ${t.length} concepts to backend`,e),yield gt(t),It("synced","concepts",t.length,t.length,e)),n.length>0&&(Tt(`sending ${n.length} connections to backend`,e),yield mt(n),It("synced","connections",n.length,n.length,e)),this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e)),Tt("online sync complete",e)}else{const e=this.conceptsSyncArray.length,r=this.connectionSyncArray.length;Tt(`starting online sync with ${e} queued concepts and ${r} queued connections`);for(let t=0;t<this.conceptsSyncArray.length;t++)z.AddConcept(this.conceptsSyncArray[t]),It("prepared local cache for","concepts",t+1,e);for(let e=0;e<this.connectionSyncArray.length;e++)pe.AddConnection(this.connectionSyncArray[e]),It("prepared local cache for","connections",e+1,r);this.conceptsSyncArray.length>0&&(t=this.conceptsSyncArray.slice(),Tt(`sending ${t.length} concepts to backend`),yield gt(t),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.some((t=>t.id===e.id)))),It("synced","concepts",t.length,t.length)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),Tt(`sending ${n.length} connections to backend`),yield mt(n),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!n.some((t=>t.id===e.id)))),It("synced","connections",n.length,n.length)),Tt(`online sync complete; ${this.conceptsSyncArray.length} concepts and ${this.connectionSyncArray.length} connections remain queued`)}return"done"}catch(e){throw e}}))}static initializeTransaction(e){return Ct(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections.push({id:e,data:{concepts:[],connections:[]},createdDate:(new Date).toISOString()})}catch(e){console.log("error in initializeTransaction",e)}}))}static markTransactionActions(e,t){return Ct(this,void 0,void 0,(function*(){try{this.transactionCollections=this.transactionCollections.map((n=>n.id==e?Object.assign(Object.assign({},n),{data:JSON.parse(JSON.stringify(t))}):n)),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.concepts.some((t=>t.id==e.id||t.ghostId==e.id)))),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!t.connections.some((t=>t.id==e.id||t.ghostId==e.id))))}catch(e){console.log("error in markTransactionActions",e)}}))}static rollbackTransaction(e,t){return Ct(this,void 0,void 0,(function*(){try{if(!this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e))}catch(e){console.log("LocalSyncData, roll",e)}}))}static syncDataLocalDb(){return Ct(this,void 0,void 0,(function*(){if(Tt(`starting local sync with ${this.conceptsSyncArray.length} queued concepts and ${this.connectionSyncArray.length} queued connections`),this.conceptsSyncArray.length>0){const e=this.conceptsSyncArray.length;for(let t=0;t<this.conceptsSyncArray.length;t++)L("localconcept",this.conceptsSyncArray[t]),It("stored locally","concepts",t+1,e);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){const e=this.connectionSyncArray.length;for(let t=0;t<this.connectionSyncArray.length;t++)L("localconnection",this.connectionSyncArray[t]),It("stored locally","connections",t+1,e);this.connectionSyncArray=[]}return Tt("local sync complete"),"done"}))}}function At(e,t){const n=Number(e);if(!Number.isFinite(n)||n<=0)throw new Error(`Cannot create a connection: ${t} must be a positive finite number. Received ${JSON.stringify(e)}.`);return n}function Et(e){return e||(a.DEFAULT_USER_ID?a.DEFAULT_USER_ID:999)}Nt.conceptsSyncArray=[],Nt.connectionSyncArray=[],Nt.transactionCollections=[];var St=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Rt(e,t,n,r,o,i,c){return St(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s=1,a=4,l=999,u={concepts:[],connections:[]}){const d=function(e,t){const n=At(e,"ofTheConceptId"),r=At(t,"toTheConceptId");if(n===r)throw new Error(`Cannot create a self-connection for concept ${n}.`);return{ofTheConceptId:n,toTheConceptId:r}}(e,n);e=d.ofTheConceptId,n=d.toTheConceptId;let h=t,f=t,p=t;999!=l&&(p=l);let y=t,v=t,g=yield yt.getId(),m=new se(g,e,n,t,r,p,o,f,s,h,0,y,a,v,i,c);return m.toUpdate=!0,m.isTemp=!1,Nt.AddConnection(m),u.connections.push(m),m}))}function kt(e,t,n){return St(this,arguments,void 0,(function*(e,t,n,r={concepts:[],connections:[]}){let o=Et(e.userId),i=yield nt(n);return yield Rt(e.id,e.userId,t.id,t.userId,i.id,999,999,1e3,4,o,r)}))}var xt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const bt=new Map;function $t(e,t){return xt(this,void 0,void 0,(function*(){let n=yield z.GetConceptByCharacterAndTypeLocal(e,t),r=e+t;if(bt.has(r))return bt.get(r)||n;const o=(()=>xt(this,void 0,void 0,(function*(){try{if(null==n||0==n.id){var o={character_value:`${e}`,type_id:t},i=JSON.stringify(o),c=yield ee();const r=yield C(s.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:i});if(r.ok){let e=yield r.json();n=e,z.AddConcept(n)}else console.log("This is the concept by type and character error",r.status),re(r)}return n}catch(e){throw e instanceof Error?console.log(" This is the concept by type and character error message: ",e.message):console.log(" This is the concept by type and character unexpected error: ",e),e}finally{bt.delete(r)}})))();return bt.set(r,o),o}))}function Lt(e){return xt(this,void 0,void 0,(function*(){let t=[],n=JSON.stringify(e);var r=yield ee();const o=yield C(s.GetConceptConnectionByType(),{method:"POST",headers:r,body:n});if(o.ok){let e=yield o.json();t=yield ve(e)}else console.log("This is the concept by type and character error",o.status),re(o);return t}))}var _t=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Pt(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return _t(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p={concepts:[],connections:[]}){var y=yield pt.getId();let v=new Date,g=new Date;var m=new M(y,t,o,i,n,r,c,s,e,a,l,u,d,h,f,!0,v,g);return m.isTemp=!1,Nt.AddConcept(m),p.concepts.push(m),m}))}function Ot(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return _t(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p={concepts:[],connections:[]}){var y=yield pt.getId();let v=new Date,g=new Date;var m=new M(y,t,o,i,n,r,c,s,e,a,l,u,d,h,f,!1,v,g);return z.AddConcept(m),m.updateRecursion=!0,Nt.AddConcept(m),p.concepts.push(m),m}))}var Ut=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Bt(e,t){return Ut(this,arguments,void 0,(function*(e,t,n=!1,r,o,i=999,c=0,s={concepts:[],connections:[]}){let a,l=i,u=r=Et(r),d=r,h=o,f=r,p=e.startsWith("the_")?e:"the_"+e,y=H();return n?(y=yield nt(e),a=yield Pt(t,r,4,r,y.id,y.userId,c,999,999,u,h,f,l,d,s)):(y=yield nt(p),a=yield $t(t,y.id),0==a.id&&0==a.userId&&(a=yield Ot(t,r,4,r,y.id,y.userId,c,999,999,u,h,f,l,d,s))),a.type=y,a}))}var Dt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ft(e){return Dt(this,arguments,void 0,(function*(e,t=null,n=null,r=null,o=null,i=null,c=null){var s=null!=o?o:999,a=null!=i?i:4,l=null!=c?c:999,u=null!=r?r:0,d=H();for(const r in e)if("string"!=typeof e[r]&&"number"!=typeof e[r])if(null==t&&null==n){var h=u;d=y=yield Bt(r,"",!0,s,a,l),h=y.id,u=y.id,yield Ft(e[r],y.id,y.userId,h,o,i,c)}else{var f=null!=t?t:999,p=null!=n?n:999;h=u,d=y=yield Bt(r,"",!0,s,a,l),yield Rt(f,p,y.id,y.userId,h,l,y.userId),yield Ft(e[r],y.id,y.userId,h,o,i,c)}else{f=null!=t?t:999,p=null!=n?n:10267,h=u;var y=yield Bt(r,e[r].toString(),!1,s,a,l);yield Rt(f,p,y.id,y.userId,h,l,y.userId)}return d}))}var Gt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function jt(e,t,n){return Gt(this,arguments,void 0,(function*(e,t,n,r=10,o=1){let i=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("ofTheConceptId",`${t}`),c.append("userId",`${n}`),c.append("inpage",`${r}`),c.append("page",`${o}`);var a=yield ee("application/x-www-form-urlencoded");const l=yield C(s.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:c});return l.ok?i=yield l.json():(console.log("Get connection of concept error",l.status),re(l)),i}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Vt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Mt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Ht=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Wt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Kt(e){return Wt(this,void 0,void 0,(function*(){var t=yield pe.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var n=yield function(e){return Ht(this,void 0,void 0,(function*(){var t=yield pe.GetConnection(e);try{if(0!=t.id)return t;{var n=yield ee("application/x-www-form-urlencoded");const r=yield C(s.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${e}`});return r.ok?(t=yield r.json(),pe.AddConnection(t)):(console.log("Get Connection Error",r.status),re(r)),t}}catch(e){throw e instanceof Error?console.log("Get Connection error message: ",e.message):console.log("Get Connection unexpected error: ",e),e}}))}(e);t=n}return t}))}var Xt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function qt(e){return Xt(this,arguments,void 0,(function*(e,t=""){let n=!1;var r=yield Kt(e);return n=yield function(e){return Mt(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let r=yield yield te("",t),o=yield{Authorization:r.Authorization,Accept:"application/json"};const i=new URLSearchParams;i.append("id",e.toString()),i.append("apiKey","nodeserver");const c=yield C(s.DeleteTheConnectionUrl(),{method:"POST",headers:o,body:i,redirect:"follow"});c.ok?n=(yield c.json()).success:(console.log("Delete connection error status: ",c.status),re(c))}catch(e){throw e instanceof Error?console.log("Delete connection error message: ",e.message):console.log("Delete connection unexpected error: ",e),e}return n}))}(e,t),O("connection",e),ue.removeNodeFromTree(e),he.removeTypeConcept(r.typeId,e),n}))}function zt(e){return Xt(this,void 0,void 0,(function*(){let t=yield function(e){return Vt(this,void 0,void 0,(function*(){let t=!1;try{let n=yield te();const r=yield C(s.DeleteTheConnectionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});r.ok?t=(yield r.json()).success:(console.log("Delete connection Bulk Api error status: ",r.status),re(r))}catch(e){e instanceof Error?console.log("Delete connection Bulk Api error message: ",e.message):console.log("Delete connection Bulk Api unexpected error: ",e)}return t}))}(e);if(t)for(let t=0;t<e.length;t++){let n=e[t];n>0&&ue.removeNodeFromTree(n)}return t}))}var Jt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Yt(e){return Jt(this,arguments,void 0,(function*(e,t=999){var n=H();if(e<0)return fo(yield eo(t,e));if(null!=(n=yield z.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield Se(e)),0!=n.id&&null==n.type&&null!=n.typeId&&null!=n.typeId){var r=yield z.GetConcept(n.typeId);if(0!=r.id)n.type=r;else{var o=yield Se(n.typeId);0!=o.id&&(n.type=o)}}return n}))}var Qt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Zt=999,en=4,tn=999,nn=999,rn=1e3;function on(e){const t=`${null!=e?e:""}`.trim();if(0===t.length)throw new Error("Cannot create a typed connection without a linker name.");return t}function cn(e,t){return Qt(this,void 0,void 0,(function*(){var n,r,o;if(null==e||null==e.id||0===e.id)throw new Error(`Cannot create a typed connection: ${t} must be a persisted concept.`);const i=e.type;if(null===(n=null==i?void 0:i.characterValue)||void 0===n?void 0:n.trim())return i.characterValue.trim();const c=(yield Yt(e.id,e.userId)).type;if(null===(r=null==c?void 0:c.characterValue)||void 0===r?void 0:r.trim())return e.type=c,c.characterValue.trim();if(null!=e.typeId&&0!==e.typeId){const t=yield Yt(e.typeId,e.typeUserId);if(0!==t.id&&(null===(o=t.characterValue)||void 0===o?void 0:o.trim()))return e.type=t,t.characterValue.trim()}throw new Error(`Cannot create a typed connection: ${t} concept ${e.id} has no resolvable type.`)}))}function sn(e){return Qt(this,void 0,void 0,(function*(){return yield Bt("connection",e,!1,Zt,Zt,tn)}))}function an(e,t,n){return Qt(this,void 0,void 0,(function*(){return yield Rt(e.id,e.userId,t.id,t.userId,n.id,tn,nn,rn,en)}))}function ln(e,t,n){return Qt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){const i=on(n),c=e.userId;if(r){const n=yield function(e,t){return Qt(this,void 0,void 0,(function*(){return`${yield cn(e,"toTheConcept")}_s_${t}_by`}))}(t,i);o&&(yield dn(`${i}_by`,t,c));const r=yield sn(n);yield an(t,e,r)}const s=yield function(e,t){return Qt(this,void 0,void 0,(function*(){return`${yield cn(e,"ofTheConcept")}_s_${t}_s`}))}(e,i);o&&(yield dn(`${i}_s`,e,c));const a=yield sn(s);return yield an(e,t,a)}))}function un(e,t,n){return Qt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){return yield ln(e,t,n,r,o)}))}function dn(e,t){return Qt(this,arguments,void 0,(function*(e,t,n=null){for(var r=t,o=null!=n?n:t.userId,i=999,c=on(e)+"_count",s=(yield cn(t,"concept"))+"_s_"+c,a=yield Bt("connection",s,!1,o,4,i),l=yield jt(a.id,t.id,o,10,1),u=[],d=H(),h=0;h<l.length;h++){let e=yield Yt(l[h].toTheConceptId);u.push(e)}if(u.length<1)d=yield Bt("count","1",!1,o,4,i);else{var f=u[0];let e=Number(f.characterValue),t=Number.isFinite(e)?e+1:1;d=yield Bt("count",t.toString(),!1,o,4,i);for(let e=0;e<l.length;e++)yield qt(l[e].id)}yield Rt(r.id,r.userId,d.id,d.userId,a.id,i,nn,rn,4,o)}))}function hn(e,t,n){return Qt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){return yield ln(e,t,n,r,o)}))}var fn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function pn(e){return encodeURIComponent(String(e))}function yn(e,t){return fn(this,arguments,void 0,(function*(e,t,n=("number"==typeof e?999:e.userId),r=("number"==typeof e?4:e.accessId),o=999){const i="number"==typeof e?e:e.id,c="number"==typeof e?n:e.userId,a=yield ee("application/x-www-form-urlencoded"),l=[`character_value=${pn(t)}`,`type_id=${pn(i)}`,`type_user_id=${pn(c)}`,`access_id=${pn(r)}`,`session_information_id=${pn(o)}`].join("&"),u=yield C(s.CreateTypeConceptUrl(),{method:"POST",headers:a,body:l});if(!u.ok)throw re(u),new Error(`Error! status: ${u.status}`);const d=yield u.json();return"number"!=typeof e&&(d.type=e),z.AddConcept(d),d}))}var vn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function gn(e,t){return vn(this,arguments,void 0,(function*(e,t,n=10,r=1){var o,i=[],c=yield Yt(e),s=(null===(o=c.type)||void 0===o?void 0:o.characterValue)+"_s_"+t,a=yield $t(s,16);if(a.id>0){for(var l=yield jt(a.id,c.id,c.userId,n,r),u=[],d=0;d<l.length;d++)u.push(l[d].toTheConceptId);for(yield Ne(u),d=0;d<l.length;d++){let e=l[d].toTheConceptId,t=yield Yt(e),n=yield Oe(t.id);i.push(n)}}return i}))}function mn(e,t){return vn(this,arguments,void 0,(function*(e,t,n=10,r=1){var o,i=[],c=yield Yt(e),s=(null===(o=c.type)||void 0===o?void 0:o.characterValue)+"_s_"+t,a=yield $t(s,16);if(a.id>0){for(var l=yield jt(a.id,c.id,c.userId,n,r),u=[],d=0;d<l.length;d++)u.push(l[d].toTheConceptId);for(d=0;d<l.length;d++){let e=l[d].toTheConceptId,t=yield Yt(e);i.push(t)}}return i}))}class Cn{constructor(e,t,n,r,o,i,c,s=!1,a,l,u,d=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=e,this.userId=t,this.typeId=n,this.ghostId=e,this.categoryId=r,this.characterValue=i,this.accessId=o,this.type=null,this.isNew=s,this.typeCharacter=c,this.entryTimeStamp=a,this.updatedTimeStamp=l,this.referentId=u,this.applicationId=d}getType(){console.log(this.typeId)}}function wn(){let e=new Date,t=new Date;return new Cn(0,0,0,0,0,"0","0",!1,e,t,0)}class Tn{constructor(e,t,n,r,o,i,c,s,a,l){this.id=0,this.isNew=!1,this.userId=e,this.data=`${t}`,this.securityId=n,this.securityUserId=r,this.accessId=o,this.accessUserId=i,this.sessionId=c,this.sessionUserId=s,this.isNew=l}}class In{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new Tn(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==e&&(t=this.characterData[n]);return t}}In.characterData=[];class Nn{constructor(e,t,n,r){this.id=e,this.userId=t,this.referentId=n,this.isNew=r}}var An=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},En=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Sn(e,t,n,r,o){return En(this,void 0,void 0,(function*(){return new Tn(t,e,n,t,r,t,o,t,"",!1),yield function(){return An(this,void 0,void 0,(function*(){var e;try{if(0==(e=In.GetCharacter(e.data)).id){var t=yield ee();const r=yield C(s.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!r.ok)throw re(r),new Error(`Error! status: ${r.status}`);const o=yield r.json();var n=new Tn(o.userId,e.data,0,0,4,4,999,999,"",!1);return n.id=o.id,In.AddCharacter(n),o}return new Nn(e.id,e.userId,0,!1)}catch(e){throw e instanceof Error?console.log("create the character error message: ",e.message):console.log("create the character unexpected error: ",e),e}}))}()}))}var Rn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function kn(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return Rn(this,void 0,void 0,(function*(){var p=yield $t(e,o),y=p;return 0==y.id&&(y=p=yield Pt(e,t,n,r,o,i,c,s,a,l,u,d,h,f)),y}))}var xn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},bn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function $n(e,t,n,r){return bn(this,arguments,void 0,(function*(e,t,n,r,o={concepts:[],connections:[]}){var i=yield He(e);if(i&&(0==i.id||0==i.userId)){var c=Q(e);if(c.length>0)if(c[0]==e){var s=yield function(e,t,n,r,o,i){return xn(this,void 0,void 0,(function*(){var o,c=t,s=t;o=t;var a,l=t,u=t,d=t;if(1==e.length){var h=e.charCodeAt(0);yield Sn(e,t,n,r,i),a=yield kn(e,t,4,c,49,l,h,d,n,s,r,o,i,u)}else{var f=yield Sn(e,t,n,r,i);f.isNew,a=yield kn(e,t,4,c,51,l,f.id,f.userId,n,s,r,o,i,u)}return a}))}(e,r,999,999,0,t);i=s}else{var a=yield $n(c[0],t,n,r,o),l=yield $n(c[1],t,n,r,o);l&&(i=yield Ot(e,r,a.id,r,l.id,r,999,r,999,r,999,r,t,r,o))}}return i}))}var Ln=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function _n(e){return Ln(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=yield ee("application/x-www-form-urlencoded");const i=new URLSearchParams({conceptId:String(e)}),c=yield C(`${s.GetAllLinkerConnectionOfConceptUrl()}?${i.toString()}`,{method:"GET",headers:n});if(c.ok){const e=yield c.json();for(var r=0;r<e.length;r++){var o=e[r];t.push(o)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),re(c);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection from the concepts error: ",e.message):console.log("Get all linker connection from the concepts error(Unexpected): ",e),e}}))}var Pn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function On(e){return Pn(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=yield ee("application/x-www-form-urlencoded");const i=new URLSearchParams({conceptId:String(e)}),c=yield C(`${s.GetAllLinkerConnectionToConceptUrl()}?${i.toString()}`,{method:"GET",headers:n});if(c.ok){const e=yield c.json();for(var r=0;r<e.length;r++){var o=e[r];t.push(o)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),re(c);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection To the concepts error: ",e.message):console.log("Get all linker connection To the concepts error(Unexpected): ",e),e}}))}var Un=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Bn(e){return Un(this,void 0,void 0,(function*(){for(var t=yield _n(e),n=0;n<t.length;n++){let e=t[n];var r=e.typeId;let o=yield Yt(r);e.type=o}return t}))}function Dn(e){return Un(this,void 0,void 0,(function*(){for(var t=yield On(e),n=0;n<t.length;n++){let e=t[n];var r=e.typeId;let o=yield Yt(r);e.type=o}return t}))}var Fn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Gn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},jn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Vn(e){return jn(this,arguments,void 0,(function*(e,t=""){var n=yield Yt(e);yield V.removeNodeFromTree(e);var r=n.typeId,o=n.characterValue;yield X.removeTypeConcept(r,e),yield G.removeNodeByCharacter(o,e),O("concept",e);let i=yield function(e){return Fn(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let r=yield yield yield te("application/x-www-form-urlencoded",t);const o=new FormData;o.append("id",e.toString()),o.append("apiKey","nodeserver");const{"Content-Type":i}=r,c=Gn(r,["Content-Type"]),a=yield C(s.DeleteConceptUrl(),{method:"POST",headers:c,body:o});if(!a.ok)throw re(a),new Error(`Error! status: ${a.status}`);n=(yield a.json()).success}catch(e){throw e instanceof Error?console.log("Delete concept error message: ",e.message):console.log("Delete concept unexpected error: ",e),e}return n}))}(e,t);return i}))}var Mn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Hn(e,t){return Mn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+t);const r=new FormData;r.append("id",e.toString());const o=yield C(s.DeleteConceptUrl(),{method:"POST",body:r,headers:n});if(!o.ok)throw re(o),new Error(`Delete composition Error! status: ${o.status}`)}catch(e){throw e instanceof Error?console.log("Delete composition error message: ",e.message):console.log("Delete composition unexpected error: ",e),e}}))}var Wn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Kn(e,t,n,r){return Wn(this,arguments,void 0,(function*(e,t,n,r,o=999){var i,c=n,s=n,a=n,l=e.startsWith("the_"),u=H();return i=l?e:"the_"+e,u=yield nt(i),yield kn(t,n,4,n,u.id,u.userId,0,999,999,c,r,a,o,s)}))}class Xn{constructor(){this.composition=0,this.type="",this.linker="",this.inpage=10,this.page=1,this.listLinkers=[],this.fullLinkers=[],this.textSearch="",this.logic="or",this.reverse=!1,this.doFilter=!1,this.filterSearches=[],this.selectors=[]}}var qn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function zn(){return qn(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=[];for(let r=0;r<e.length;r++){let o=yield pe.GetConnection(e[r]);0==o.id?n.push(e[r]):t.push(o)}if(0==n.length)return t;{var r=yield ee();const e=yield R("/api/get_connection_bulk",{method:"POST",headers:r,body:JSON.stringify(n)});if(e.ok){const n=yield e.json();if(n.length>0){for(let e=0;e<n.length;e++){let r=n[e];t.push(r),pe.AddConnection(r)}yield me(t)}}else console.log("Get Connection Bulk error",e.status),re(e);return t}}catch(e){throw e instanceof Error?console.log("Get Connection Bulk error message: ",e.message):console.log("Get Connection Bulk unexpected error: ",e),e}}))}var Jn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Yn(){return Jn(this,arguments,void 0,(function*(e=[]){yield Ne(e);var t=[];for(let r=0;r<e.length;r++){var n=yield _e(e[r]);t.push(n)}return t}))}function Qn(){return Jn(this,arguments,void 0,(function*(e=[]){yield Ne(e);var t=[];for(let r=0;r<e.length;r++){var n=yield Pe(e[r]);t.push(n)}return t}))}function Zn(){return Jn(this,arguments,void 0,(function*(e=[],t=[]){yield zn(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||pe.RemoveConnection(t[n])}(t,yield we(e));var n=[];for(let t=0;t<e.length;t++){var r=yield Pe(e[t]);n.push(r)}return n}))}function er(){return Jn(this,arguments,void 0,(function*(e=[]){let t=[],n=[],r={};for(let r=0;r<(null==e?void 0:e.length);r++){let o=yield pe.GetConnection(e[r]);0==o.id?t.push(e[r]):n.push(o)}for(let n=0;n<t.length;n++)r[e[n]]=!1;let o=[],i=yield zn(t);n=[...n,...i];for(let e=0;e<n.length;e++)o.push(n[e].ofTheConceptId),o.push(n[e].toTheConceptId),o.push(n[e].typeId);return yield ve(o),n}))}function tr(){return Jn(this,arguments,void 0,(function*(e=[],t=[]){let n=[],r=[];for(let e=0;e<t.length;e++){let o=yield pe.GetConnection(t[e]);0==o.id?n.push(t[e]):r.push(o)}let o=yield zn(n);for(let e=0;e<o.length;e++)r.push(o[e]);let i={},c=[];for(var s=0;s<r.length;s++)c.includes(r[s].ofTheConceptId)||c.push(r[s].ofTheConceptId);for(let t=0;t<e.length;t++){let n=yield Be(e[t],r,c);i[e[t]]=n}return i}))}var nr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function rr(){return nr(this,arguments,void 0,(function*(e=0,t=[],n="",r=[]){var o=[];try{var i=new Xn;i.composition=e,i.listLinkers=t,i.textSearch=n,i.fullLinkers=r;var c=JSON.stringify(i),a=yield ee();const d=yield C(s.RecursiveSearchUrl(),{method:"POST",headers:a,body:c});if(d.ok){const e=yield d.json();var l=e.compositionIds,u=e.internalConnections;e.externalConnections,o=yield Zn(l,u)}else console.log("recursive search error ",d.status),re(d);return o}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}var or=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ir(e,t){return or(this,void 0,void 0,(function*(){try{var n={email:e,password:t},r=new Headers;r.append("Content-Type","application/json");var o=JSON.stringify(n);const i=yield C(s.LoginUrl(),{method:"POST",headers:r,body:o});if(i.ok){const e=yield i.json();return a.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",i.status),re(i)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var cr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function sr(e){return cr(this,void 0,void 0,(function*(){const t=yield function(){return cr(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const r=yield C(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),o=yield r.json();return r.ok?n={message:"success",status:!0,statusCode:200,data:o}:re(r),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(s.SignupUrl(),e);return t}))}var ar=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function lr(e){return ar(this,void 0,void 0,(function*(){const t=JSON.stringify({email:e.email,password:e.password});let n={message:"success",status:!1,statusCode:200,data:""};const r=new Headers;r.append("Content-Type","application/json");const o=s.LoginUrl();try{const e=yield C(o,{method:"POST",headers:r,body:t,redirect:"follow"}),i=yield e.json();return e.ok?n={message:"success",status:!0,statusCode:200,data:null==i?void 0:i.data}:re(e),n}catch(e){throw console.log("Sign in api error",e),e}}))}function ur(e,t){return-1===e.indexOf(t)&&e.push(t),e}function dr(e=[],t){var n,r;let o=[],i=null===(n=t.type)||void 0===n?void 0:n.characterValue;if((null==i?void 0:i.startsWith("the_"))||(i="the_"+i),Array.isArray(e))for(let n=0;n<e.length;n++){let c=null===(r=e[n].type)||void 0===r?void 0:r.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),t.typeId!=e[n].typeId&&i!=c||o.push(e[n])}return o}function hr(e=[],t){let n=[];if(Array.isArray(e)){const r=e.find((e=>e.toTheConceptId==t));r&&n.push(r);const o=e.find((e=>e.ofTheConceptId==t));o&&n.push(o)}return n}function fr(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function pr(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class yr{constructor(e,t,n,r){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r}isValid(){const e=new Date(Date.now());return!(this.expiryTime<e&&(gr.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return this.isValid(),e;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var vr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class gr{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addCompositionToTree(e){const t=new yr(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return vr(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return vr(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}gr.root=null;var mr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Cr(e,t,n,r){return mr(this,arguments,void 0,(function*(e,t,n,r,o=[]){var i,c;let s={};const a=[];if(0==e)return"";let l=wr(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Yt(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=wr(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield Yt(e),l.type=t)}if(!r.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e);for(let l=0;l<t.length;l++)if(t[l].ofTheConceptId==e){const u=t[l].toTheConceptId;if(r.includes(e)){let e=wr(n,u);if(null!=e&&0!=e.id||null==u||null==u||(e=yield Yt(u)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield z.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield Yt(t),e.type=n)}const l="the_",d=(null!==(c=null===(i=null==e?void 0:e.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(d))){if(d){const e=yield Cr(u,t,n,r,o);s[d]=e}}else{const e=yield Cr(u,t,n,r,o);a[d]=e,s=a}}}return s}))}function wr(e,t){let n=H();for(let r=0;r<e.length;r++)if(t==e[r].id)return n=e[r],n;return n}class Tr{constructor(){this.id=0,this.mainConcept=H(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return e=this,t=void 0,r=function*(){if(0==this.mainConcept.id)for(let e=0;e<this.concepts.length;e++)this.concepts[e].id==this.id&&(this.mainConcept=this.concepts[e]);this.cached=yield Cr(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}));var e,t,n,r}UpdateAcrossDistributedSystem(){var e,t;try{0!=this.id&&(t=null===(e=this.id)||void 0===e?void 0:e.toString(),s.MQTT_CONNECTION&&s.MQTT_CONNECTION.publish("compositionUpdate",t))}catch(e){console.log("Error while publishing message",e)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var e,t,n;const r={};r[null!==(n=null===(t=null===(e=this.mainConcept)||void 0===e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=this.cached;const o={};return o.data=r,o.id=this.id,o}}var Ir=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Nr(e){return Ir(this,arguments,void 0,(function*(e,t=null,n=null,r=null,o=null,i=null,c=null,s=null){const a=null!=o?o:999,l=null!=i?i:4,u=null!=c?c:999;let d=null!=r?r:0,h=H();null==s&&(s=new Tr);for(const r in e)if("object"==typeof e[r]||Array.isArray(e[r])){const f=yield Bt(r,"",!0,a,l,u);if(null==t&&null==n){let t=d;h=f,t=f.id,d=f.id,s.concepts.push(f),s.id=f.id,yield Nr(e[r],f.id,f.userId,t,o,i,c,s)}else{const a=null!=t?t:999,l=null!=n?n:999,p=d;h=f,s.concepts.push(f);const y=yield Rt(a,l,f.id,f.userId,p,u,f.userId);s.connections.push(y),yield Nr(e[r],f.id,f.userId,p,o,i,c,s)}null!=e[r]&&null!=e[r]&&s.subcompositions.push(f.id)}else{const o=null!=t?t:999,i=null!=n?n:999,c=d,h=yield Bt(r,e[r],!1,a,l,u);s.concepts.push(h);const f=yield Rt(o,i,h.id,h.userId,c,u,h.userId);s.connections.push(f)}return h}))}var Ar=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Er(e){return Ar(this,void 0,void 0,(function*(){try{const t=yield ee(),n=yield C(s.GetConnectionsBetweenUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!n.ok)throw console.log("GetConnectionsBetweenApi error status: ",n.status),re(n),new Error(`GetConnectionsBetweenApi error: ${n.status}`);return yield n.json()}catch(e){throw e instanceof Error?console.log("GetConnectionsBetweenApi error message: ",e.message):console.log("GetConnectionsBetweenApi unexpected error: ",e),e}}))}function Sr(e){var t,n,r,o,i,c,s;return{ofTheConceptId:null!==(t=e.ofTheConceptId)&&void 0!==t?t:0,toTheConceptId:null!==(n=e.toTheConceptId)&&void 0!==n?n:0,typeId:null!==(r=e.typeId)&&void 0!==r?r:0,type:null!==(o=e.type)&&void 0!==o?o:"",oldType:null!==(i=e.oldType)&&void 0!==i?i:"",reverse:null!==(c=e.reverse)&&void 0!==c&&c,isComposition:null!==(s=e.isComposition)&&void 0!==s&&s,connectionIds:[]}}var Rr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class kr{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return Rr(this,void 0,void 0,(function*(){yield Nt.initializeTransaction(this.transactionId)}))}markAction(){return Rr(this,void 0,void 0,(function*(){yield Nt.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return Rr(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield Nt.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return Rr(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield Nt.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield zt(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(e){return Rr(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([e])}))}DeleteConnectionsBetweenBulk(e){return Rr(this,arguments,void 0,(function*(e,t=[]){try{if(!this.success)throw Error("Query Transaction Expired");const n=[...t];if(e.length>0){const t=e.map(Sr),r=yield Er(t);for(const e of r)n.push(...e.connectionIds)}return this.pendingConnectionDeletions.push(...n),n}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheInstanceConcept(e,t){return Rr(this,arguments,void 0,(function*(e,t,n=!1,r,o,i=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const s=yield Bt(e,t,n,r,o,i,c,this.actions);return yield this.markAction(),s}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTypeConcept(e,t){return Rr(this,arguments,void 0,(function*(e,t,n=("number"==typeof e?999:e.userId),r=("number"==typeof e?4:e.accessId),o=999){try{if(!this.success)throw Error("Query Transaction Expired");return yield yn(e,t,n,r,o)}catch(e){throw console.log(e),this.success=!1,e}}))}CreateConnection(e,t,n){return Rr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const r=yield kt(e,t,n,this.actions);return yield this.markAction(),r}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheTypeConcept(e,t,n,r){return Rr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield $n(e,t,n,r,this.actions);return yield this.markAction(),o}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTheConnectionGeneral(e,t,n,r,o,i,c){return Rr(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s=1,a=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const u=yield Rt(e,t,n,r,o,i,c,s,a,l,this.actions);return yield this.markAction(),u}catch(e){throw console.log(e),this.success=!1,e}}))}}var xr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function br(e){return xr(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,r=e.accessId;let o=[];const i=[];let c=H(),s=H();const a=[];let l=e.compositionId;const u=e.ofTheCompositionId;let d=[];if(l<0){let e=yield Yt(l,t);if(!(e.id>0))return null;l=e.id}const h=new kr;yield h.initialize();try{o=yield ke(l);const f=[],p=new Tr,y=[];p.id=l,p.isUpdating();let v=[];for(let e=0;e<o.length;e++)ur(y,o[e].ofTheConceptId),ur(f,o[e].ofTheConceptId),ur(f,o[e].toTheConceptId),v.push(o[e].ofTheConceptId);p.subcompositions=y,p.connections=o;for(let e=0;e<f.length;e++){const t=yield Yt(f[e]);l==f[e]&&(c=t),u==f[e]&&(s=t),i.push(t)}const g=e.patchObject;for(const e in g){let o=H();const l=g[e];let u=c;if(s.id>0&&(u=s),Array.isArray(l)||"object"==typeof l){o=yield h.MakeTheInstanceConcept(e,"",!0,c.userId,4,999),p.subcompositions.push(o.id);const t=dr(i,o);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=hr(p.connections,t[e].id);d=d.concat(n),a.push(t[e])}yield Nr(g[e],o.id,o.userId,c.id,c.userId,4,999,p)}else{o=yield h.MakeTheInstanceConcept(e,l,!1,t,r,n);const c=dr(i,o);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=hr(p.connections,c[e].id);d=d.concat(t),a.push(c[e])}}const f=yield h.CreateTheConnectionGeneral(u.id,u.userId,o.id,o.userId,c.id,n,t);i.push(o),p.connections.push(f)}for(let e=0;e<d.length;e++)pr(p.connections,d[e]);d.length>0&&(yield h.DeleteConnectionsBetweenBulk([],d.map((e=>e.id))));for(let e=0;e<a.length;e++)fr(i,a[e]);return p.concepts=p.concepts.concat(i),p.mainConcept=c,p.id=c.id,yield h.commitTransaction(),yield p.updateCache(),gr.addCompositionToTree(p),p.GetDataCache()}catch(e){throw yield h.rollbackTransaction(),e}}))}var $r=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Lr(e,t,n,r){return $r(this,arguments,void 0,(function*(e,t,n,r,o=10,i=1){var c=yield te("application/x-www-form-urlencoded",r),a=new URLSearchParams;a.append("type",e),a.append("search",t),a.append("composition",n),a.append("inpage",o.toString()),a.append("page",i.toString());const l=s.SearchCompositionsUrl()+"?"+a.toString();try{const e=yield C(l,{method:"GET",headers:c});if(e.ok)return yield e.json();re(e)}catch(e){throw e}}))}var _r=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Pr(e){return _r(this,arguments,void 0,(function*(e,t=""){var n=yield te("application/json",t);const r=s.SearchLinkMultipleAll(),o=JSON.stringify(e);try{const e=yield C(r,{method:"POST",headers:n,body:o});if(e.ok)return yield e.json();re(e)}catch(e){throw e}}))}var Or=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ur(e){return Or(this,arguments,void 0,(function*(e,t=[]){var n,r;let o=[];const i=[];let c={},s={};const a=[];let l=yield z.GetConcept(e);0==l.id&&null!=e&&null!=e&&(l=yield Se(e));let u=[];u=t.length>0?Br(e,t):yield ke(e),o=u;for(let e=0;e<o.length;e++)a.includes(o[e].ofTheConceptId)||(a.push(o[e].ofTheConceptId),i.push(o[e].ofTheConceptId)),i.includes(o[e].toTheConceptId)||i.push(o[e].toTheConceptId);return s=yield Fe(e,o,a,[]),c[null!==(r=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=s,0==l.id?"":c}))}function Br(e,t){const n=[];for(let r=0;r<t.length;r++)t[r].typeId==e&&n.push(t[r]);return n}function Dr(e){return Or(this,arguments,void 0,(function*(e,t=[]){var n,r;let o={},i=[];const c=[];let s;const a={},l=[];let u=yield z.GetConcept(e);0==u.id&&null!=e&&null!=e&&(u=yield Se(e));let d=[];d=t.length>0?Br(e,t):yield ke(e),i=d;for(let e=0;e<i.length;e++)l.includes(i[e].ofTheConceptId)||(l.push(i[e].ofTheConceptId),c.push(i[e].ofTheConceptId)),c.includes(i[e].toTheConceptId)||c.push(i[e].toTheConceptId);return s=yield Fe(e,i,l),a[null!==(r=null===(n=null==u?void 0:u.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=s,o.created_at=u.entryTimeStamp,o.data=a,o.id=e,0==u.id?"":o}))}function Fr(e,t){return Or(this,void 0,void 0,(function*(){let n=[];const r=[];n=yield zn(t);for(let t=0;t<e.length;t++){const o=yield Dr(e[t],n);o&&r.push(o)}return r}))}var Gr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function jr(e){return Gr(this,void 0,void 0,(function*(){try{var t=yield ee();const n=JSON.stringify(e),r=yield C(s.CreateSessionId(),{method:"POST",headers:t,body:n});return r.ok?r.json():(console.log("Creating session failed",yield r.json()),re(r),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var Vr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Mr(e,t){return Vr(this,void 0,void 0,(function*(){try{var n=yield ee("application/x-www-form-urlencoded");const r=new URLSearchParams;r.append("sessionId",e.toString()),r.append("url",t);const o=yield C(s.CreateSessionVisitUrl(),{method:"POST",headers:n,body:r});return o.ok?o.json():(console.log("Creating session url failed",yield o.json()),re(o),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var Hr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Wr(e,t,n){return Hr(this,arguments,void 0,(function*(e,t,n,r=10,o=1){let i=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("toTheConceptId",`${t}`),c.append("userId",`${n}`),c.append("inpage",`${r}`),c.append("page",`${o}`);var a=yield ee("application/x-www-form-urlencoded");const l=yield C(s.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:c});return l.ok?i=yield l.json():(console.log("Get connection of concept error",l.status),re(l)),i}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Kr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Xr(e,t){return Kr(this,arguments,void 0,(function*(e,t,n=10,r=1,o=!1){let i=[],c=yield Yt(e),s=yield Qe(t);if(s.id>0){let e=[],t=[];if(o){t=yield Wr(s.id,c.id,c.userId,n,r);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield Ne(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,r=yield Yt(n),o=yield Oe(r.id);i.push(o)}}else{t=yield jt(s.id,c.id,c.userId,n,r);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield Ne(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,r=yield Yt(n),o=yield Oe(r.id);i.push(o)}}}return i}))}function qr(e,t){return Kr(this,arguments,void 0,(function*(e,t,n=10,r=1,o=!1){let i=[],c=yield Yt(e),s=yield Qe(t),a=[],l=[];if(s.id>0){if(o){a=yield Wr(s.id,c.id,c.userId,n,r);for(let e=0;e<a.length;e++)l.push(a[e].ofTheConceptId)}else{a=yield jt(s.id,c.id,c.userId,n,r);for(let e=0;e<a.length;e++)l.push(a[e].toTheConceptId)}i=yield ve(l)}return i}))}class zr{constructor(e,t,n){this.value=new Map,this.connectionValue=new Map,this.key=e,t.id>0&&this.value.set(t.ghostId,t),n.id>0&&this.connectionValue.set(n.ghostId,n)}}class Jr{constructor(e=0,t,n,r,o,i,c=999){this.isTemp=!1,this.applicationId=999,this.type=wn(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.typeId=r,this.ghostId=e,this.orderId=o,this.typeCharacter="",this.accessId=i,this.entryTimeStamp=W(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}var Yr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Qr{static compositeKey(e,t,n=999){return("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static waitForDataToLoad(){return Yr(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isDataLoaded)return e("done");setTimeout(Qr.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){const r=this.compositeKey(t,n,e.applicationId),o=this.nodeMap.get(r);o?e.id>0&&o.value.set(e.ghostId,e):this.nodeMap.set(r,new zr(r,e,new Jr(0,0,0,0,0,0)))}static addConnectionToTree(e,t,n=999){const r=this.compositeKey(t,n,e.applicationId),o=this.nodeMap.get(r);o?e.id>0&&o.connectionValue.set(e.ghostId,e):this.nodeMap.set(r,new zr(r,wn(),e))}static getNodeFromTree(e,t){return Yr(this,arguments,void 0,(function*(e,t,n=999){var r;const o=this.compositeKey(e,t,n);return null!==(r=this.nodeMap.get(o))&&void 0!==r?r:null}))}static removeNodeFromTree(e){return Yr(this,arguments,void 0,(function*(e,t=999,n=999){const r=this.compositeKey(e,t,n);this.nodeMap.delete(r)}))}static countNumberOfNodes(){return this.nodeMap.size}}Qr.nodeMap=new Map;var Zr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function eo(e,t){return Zr(this,arguments,void 0,(function*(e,t,n=999,r=999){var o;let i=yield Qr.getNodeFromTree(e,n,r),c=wn();return i&&(c=null!==(o=i.value.get(t))&&void 0!==o?o:c),c}))}function to(e,t){return Zr(this,arguments,void 0,(function*(e,t,n=999,r=999){var o;let i=yield Qr.getNodeFromTree(e,n,r),c=new Jr(0,0,0,0,0,0);return i&&(c=null!==(o=i.connectionValue.get(t))&&void 0!==o?o:c),c}))}function no(e,t){return Zr(this,arguments,void 0,(function*(e,t,n=999){Qr.addConceptToTree(e,t,n)}))}function ro(e,t){return Zr(this,arguments,void 0,(function*(e,t,n=999){Qr.addConnectionToTree(e,t,n)}))}var oo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function io(e){return oo(this,arguments,void 0,(function*(e,t=""){var n=yield te("application/json",t);const r=s.SearchLinkMultipleAllApiUrl(),o=JSON.stringify(e);try{const e=yield C(r,{method:"POST",headers:n,body:o});if(e.ok)return yield e.json();re(e)}catch(e){throw e}}))}var co=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function so(e){return co(this,arguments,void 0,(function*(e,t=""){let n=[],r=yield io(e,t),o=e[0].composition;const i=r;let c=i.compositionIds,s=i.internalConnections,a=i.linkers,l=i.reverse;return n=yield tr(c,s),yield ao(a,n,o,l)}))}function ao(e,t,n){return co(this,arguments,void 0,(function*(e,t,n,r=[]){let o={},i=yield zn(e);for(let e=0;e<i.length;e++){let n=!1;if(r.includes(i[e].id)&&(n=!0),1==n){if(t[i[e].ofTheConceptId]&&t[i[e].toTheConceptId]){let n=t[i[e].toTheConceptId],r=yield Yt(i[e].typeId),o=null==n?void 0:n.data,c=Object.keys(o)[0];try{let n=r.characterValue+"_reverse";"string"==typeof o&&(o={}),Array.isArray(o[c][n])||("string"==typeof o[c]&&(o[c]={}),o[c][n]=[]),o[c][n].push(t[i[e].ofTheConceptId])}catch(e){}}}else if(t[i[e].ofTheConceptId]&&t[i[e].toTheConceptId]){let n=t[i[e].ofTheConceptId],r=yield Yt(i[e].typeId),o=null==n?void 0:n.data,c=Object.keys(o)[0];try{"string"==typeof o&&(o={}),Array.isArray(o[c][r.characterValue])||("string"==typeof o[c]&&(o[c]={}),o[c][r.characterValue]=[]),o[c][r.characterValue].push(t[i[e].toTheConceptId])}catch(e){}}}return o=t[n],o}))}var lo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},uo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ho(e){return uo(this,void 0,void 0,(function*(){var t;let n=yield function(e){return lo(this,void 0,void 0,(function*(){let t=[];try{var n=yield ee();const r=yield C(s.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(r.ok){let e=yield r.json(),n={};for(let r=0;r<e.length;r++){let o=e[r].concepts;t=e[r].connections;let i=e[r].id;yield ve(o),n[i]=t}return n}return console.log("View Internal Data error",r.status),re(r),t}catch(e){throw e instanceof Error?console.log(" This is the view internal data error message: ",e.message):console.log(" This is the view internal data unexpected error: ",e),e}}))}(e),r=[];for(let o=0;o<e.length;o++){let i=e[o],c=n[i];if(i&&c){let e=[],t={};for(let t=0;t<c.length;t++)e.includes(c[t].ofTheConceptId)||e.push(c[t].ofTheConceptId);let n=yield Fe(i,c,e);t.data=n,t.id=i,r.push(t)}else{let e={};e.id=i;let n=yield Yt(i),o={};n.type&&(o[null===(t=null==n?void 0:n.type)||void 0===t?void 0:t.characterValue]=n.characterValue,e.data=o,r.push(e))}}return r}))}function fo(e){const t=H();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}var po=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},yo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function vo(e){return yo(this,arguments,void 0,(function*(e,t=""){var n=yield function(e){return po(this,arguments,void 0,(function*(e,t=""){var n,r,o,i,c,a,l=yield te("application/json",t);const u=new URLSearchParams({composition:String(null!==(n=e.composition)&&void 0!==n?n:""),search:String(null!==(r=e.search)&&void 0!==r?r:""),internalComposition:String(null!==(o=e.internalComposition)&&void 0!==o?o:""),type:String(null!==(i=e.type)&&void 0!==i?i:""),inpage:String(null!==(c=e.inpage)&&void 0!==c?c:""),page:String(null!==(a=e.page)&&void 0!==a?a:"")}),d=`${s.SearchInternalWithAuthenticatedCcsUrl()}?${u.toString()}`;try{const e=yield C(d,{method:"GET",headers:l});if(e.ok)return yield e.json();re(e)}catch(e){throw e}}))}(e,t);return yield ho(n)}))}var go=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function mo(e,t){return go(this,void 0,void 0,(function*(){let n=!0,r=yield _n(e),o=yield Lt(t),i=[];for(let e=0;e<r.length;e++)for(let t=0;t<o.length;t++)r[e].typeId==o[t].id&&i.push(r[e].id);for(let e=0;e<i.length;e++){let t=yield qt(i[e]);n=n&&t}return n}))}function Co(e,t){return go(this,void 0,void 0,(function*(){let n=yield _n(e),r=yield Lt(t),o=[];for(let e=0;e<n.length;e++)for(let t=0;t<r.length;t++)n[e].typeId==r[t].id&&o.push(n[e].id);return o}))}class wo{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class To{constructor(){this.id="0",this.remote_address="",this.server_port="",this.server_address="",this.server_name="",this.server_software="",this.http_user_agent="",this.self="",this.port="",this.userId="",this.email=""}}class Io{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class No{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}function Ao(e){if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()));if("string"!=typeof e)return[];const t=e.trim();if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()))}catch(e){}return t.split(",").map((e=>e.trim())).filter(Boolean)}class Eo{constructor(e){var t;this.aiUrl="https://ai.freeschema.com",this.cacheServerUrl="",this.cacheServers=[],this.accessToken="",this.enableAi=!0,this.enableAccessControl=!1,e&&(Object.assign(this,e),this.cacheServers=Ao(null!==(t=e.cacheServers)&&void 0!==t?t:e.cache_servers),this.cacheServerUrl=e.cacheServerUrl||e.cacheServer||this.cacheServerUrl)}hasOAuthCredentials(){return!(!this.clientId||!this.clientSecret)}hasAccessToken(){return""!==this.accessToken}getFlag(e,t=!1){var n,r;return null!==(r=null===(n=this.flags)||void 0===n?void 0:n[e])&&void 0!==r?r:t}getParameter(e,t=""){var n,r;return null!==(r=null===(n=this.parameters)||void 0===n?void 0:n[e])&&void 0!==r?r:t}setFlag(e,t){this.flags||(this.flags={}),this.flags[e]=t}setParameter(e,t){this.parameters||(this.parameters={}),this.parameters[e]=t}}var So=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Ro{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),(0!=e.id||e.isTemp)&&L("localconnection",e),this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return So(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isLocalConnectionLoaded)return e("done");setTimeout(Ro.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return So(this,void 0,void 0,(function*(){var t=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==e&&t.push(this.connectionArray[n]);return t}catch(e){return t}}))}getName(){return this.name}}Ro.connectionArray=[],Ro.connectionDictionary=[];var ko=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function xo(){return ko(this,void 0,void 0,(function*(){yield function(){return ko(this,void 0,void 0,(function*(){var e=yield P("connection");if(Array.isArray(e))for(var t=0;t<e.length;t++)pe.AddConnectionToMemory(e[t])}))}()}))}function bo(){return ko(this,void 0,void 0,(function*(){yield function(){return ko(this,void 0,void 0,(function*(){var e=yield U("localconnection");if(Array.isArray(e))for(var t=0;t<e.length;t++)Ro.AddConnection(e[t])}))}()}))}class $o{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var Lo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class _o{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addConceptToTree(e){var t=new $o(e.id,e,null,null);new $o(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return Lo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isLocalDataLoaded)return e("done");setTimeout(_o.checkFlag,1e3,e)}static getNodeFromTree(e){return Lo(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static getCharacterAndTypeFromTree(e,t){return this.root?this.root.getFromNodeWithCharacterAndType(e,t,this.root):this.root}static removeNodeFromTree(e){return Lo(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}_o.root=null;var Po=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Oo{static waitForDataToLoad(){return Po(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isLocalCharacterLoaded)return e("done");setTimeout(Oo.checkFlag,1e3,e)}static addNodeToTree(e){return Po(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=e,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(e,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(e){if(""!=e.characterValue){var t=new $o(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(e,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(e,t){return Po(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(e,t,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(e,t){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,e,t))}}Oo.LocalCharacterRoot=null;var Uo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Bo{static addNodeToTree(e){return Uo(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=e,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(e,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new $o(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeConceptType(e,t){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,e,t))}static getNodeFromTree(e){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(e,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return Uo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isLocalTypeLoaded)return e("done");setTimeout(Bo.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return Uo(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)r.variants[e].value.userId==t&&n.push(r.variants[e].value)}return n}))}}Bo.LocalTypeRoot=null;var Do=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Fo{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(L("localconcept",e),_o.addConceptToTree(e),Oo.addConceptToTree(e),Bo.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(_o.addConceptToTree(e),Oo.addConceptToTree(e),Bo.addConceptToTree(e))}static GetConcept(e){return Do(this,void 0,void 0,(function*(){var t=wn(),n=yield _o.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConceptByCharacter(e){return Do(this,void 0,void 0,(function*(){var t=wn(),n=Oo.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return Do(this,void 0,void 0,(function*(){var n=wn(),r=yield Oo.getCharacterAndTypeFromTree(e,t);return r&&(n=r.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==e&&t.push(this.localconceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return Do(this,void 0,void 0,(function*(){let n=[];return n=yield Bo.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}Fo.localconceptsArray=[];var Go=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function jo(){return Go(this,void 0,void 0,(function*(){var e=yield U("localconcept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];Fo.AddConceptToMemory(n)}}))}var Vo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Mo{}Mo.isUpdated=!1,Mo.isOnlineSync=!1;var Ho=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Wo{constructor(){this.accessCache=new Map,this.accessIndex=new Map,this.entityIndex=new Map,this.setCounter=0}generateKey(e,t,n){return`${e}:${t.toLowerCase()}:${null!=n?n:0}`}get(e,t,n){const r=this.generateKey(e,t,n),o=this.accessCache.get(r);return void 0===o?null:Date.now()>o.expiresAt?(this.accessCache.delete(r),null):o.value}set(e,t,n,r){const o=this.generateKey(e,t,n);this.accessCache.set(o,{value:r,expiresAt:Date.now()+3e5}),this.accessIndex.has(e)||this.accessIndex.set(e,new Set),this.accessIndex.get(e).add(o);const i=null!=n?n:0;this.entityIndex.has(i)||this.entityIndex.set(i,new Set),this.entityIndex.get(i).add(o),this.setCounter++,this.setCounter>=100&&(this.setCounter=0,this.sweepExpired())}remove(e,t,n){const r=this.generateKey(e,t,n);this.accessCache.delete(r);const o=this.accessIndex.get(e);o&&o.delete(r);const i=null!=n?n:0,c=this.entityIndex.get(i);c&&c.delete(r)}clear(){this.accessCache.clear(),this.accessIndex.clear(),this.entityIndex.clear(),this.setCounter=0}sweepExpired(){const e=Date.now();for(const[t,n]of this.accessCache)if(e>n.expiresAt){this.accessCache.delete(t);const e=t.split(":"),n=parseInt(e[0]),r=parseInt(e[2]),o=this.accessIndex.get(n);o&&(o.delete(t),0===o.size&&this.accessIndex.delete(n));const i=this.entityIndex.get(r);i&&(i.delete(t),0===i.size&&this.entityIndex.delete(r))}for(const[t,n]of Wo.superAdminCache)e>n.expiresAt&&Wo.superAdminCache.delete(t)}getPermissionsByAccessAndEntity(e,t){const n=new Map,r=this.accessIndex.get(e),o=Date.now();if(r){const e=null!=t?t:0;for(const t of r){const r=this.accessCache.get(t);if(r&&o<=r.expiresAt){const o=t.split(":");parseInt(o[2])===e&&n.set(o[1],r.value)}}}return n}getPermissionsByAccess(e){const t=new Map,n=this.accessIndex.get(e),r=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&r<=n.expiresAt){const r=e.split(":"),o=parseInt(r[2]),i=r[1];t.set(`${o}:${i}`,n.value)}}return t}getPermissionsByEntity(e){const t=new Map,n=this.entityIndex.get(e),r=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&r<=n.expiresAt){const r=e.split(":"),o=parseInt(r[0]),i=r[1];t.set(`${o}:${i}`,n.value)}}return t}getSuperAdmin(e){const t=Wo.superAdminCache.get(e);return void 0===t?null:Date.now()>t.expiresAt?(Wo.superAdminCache.delete(e),null):t.value}setSuperAdmin(e,t){Wo.superAdminCache.set(e,{value:t,expiresAt:Date.now()+6e5})}clearSuperAdminCache(){Wo.superAdminCache.clear()}}Wo.superAdminCache=new Map;var Ko,Xo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class qo{constructor(e){if(this.baseUrl=e||process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("Access Control base URL is not configured")}getAsync(e){return Xo(this,void 0,void 0,(function*(){const t=yield fetch(`${this.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`GET '${e}' failed with status ${t.status}`);const n=yield t.json();if(null==n)throw new Error(`The response for GET '${e}' returned null.`);return n}))}postAsync(e,t){return Xo(this,void 0,void 0,(function*(){const n=yield fetch(`${this.baseUrl}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`POST '${e}' failed with status ${n.status}`);const r=yield n.json();if(null==r)throw new Error(`The response for POST '${e}' returned null.`);return r}))}deleteAsync(e,t){return Xo(this,void 0,void 0,(function*(){const n={method:"DELETE",headers:{"Content-Type":"application/json"}};null!=t&&(n.body=JSON.stringify(t));const r=yield fetch(`${this.baseUrl}/${e}`,n);if(!r.ok)throw new Error(`DELETE '${e}' failed with status ${r.status}`);const o=yield r.json();if(null==o)throw new Error(`The response for DELETE '${e}' returned null.`);return o}))}assignAccessAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/assign",e)}))}checkAccessAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/check",e)}))}revokeAccessAsync(e){return Xo(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke",e)}))}assignAccessBulkAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/assign/bulk",e)}))}revokeAccessBulkAsync(e){return Xo(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke/bulk",e)}))}checkAccessBulkAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/check/bulk",e)}))}getAccessByIdAsync(e){return Xo(this,void 0,void 0,(function*(){return this.getAsync(`access/${e}`)}))}setAccessInheritanceAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance",e)}))}getAccessInheritanceStatusAsync(e){return Xo(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/status?accessId=${e}&connectionTypeId=${t}`)}))}assignSuperAdminAccessAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin",e)}))}revokeSuperAdminAccessAsync(e){return Xo(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin",e)}))}checkSuperAdminStatusAsync(e){return Xo(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin?accessId=${e}`)}))}setParentAccessInheritanceAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent",e)}))}removeParentAccessInheritanceAsync(e,t){return Xo(this,void 0,void 0,(function*(){let n=`access/inheritance/parent?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.deleteAsync(n)}))}hasParentAccessInheritanceAsync(e,t){return Xo(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/status?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.getAsync(n)}))}getParentAccessIdAsync(e){return Xo(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent?accessId=${e}`)}))}setParentAccessInheritanceByConceptAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept",e)}))}setParentAccessInheritanceBulkByConceptAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept/bulk",e)}))}removeParentAccessInheritanceByConceptAsync(e,t){return Xo(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.deleteAsync(n)}))}removeParentAccessInheritanceBulkByConceptAsync(e){return Xo(this,void 0,void 0,(function*(){return this.deleteAsync("access/inheritance/parent/concept/bulk",e)}))}hasParentAccessInheritanceByConceptAsync(e,t){return Xo(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept/status?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.getAsync(n)}))}getParentAccessIdByConceptAsync(e){return Xo(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent/concept?childConceptId=${e}`)}))}assignSuperAdminByConceptAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin/concept",e)}))}revokeSuperAdminByConceptAsync(e){return Xo(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin/concept",e)}))}checkSuperAdminByConceptAsync(e){return Xo(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin/concept?conceptId=${e}`)}))}setAccessInheritanceByConceptAsync(e){return Xo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/concept",e)}))}getAccessInheritanceStatusByConceptAsync(e){return Xo(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/concept/status?conceptId=${e}&connectionTypeId=${t}`)}))}}!function(e){e[e.None=0]="None",e[e.Read=1]="Read",e[e.Write=2]="Write",e[e.Execute=4]="Execute",e[e.Delete=8]="Delete"}(Ko||(Ko={}));var zo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Jo{static initialize(){console.log("AccessControlService initialized with access control disabled by default.")}static setEnabled(e){this.isAccessControlEnabled=e}static getEnabled(){return this.isAccessControlEnabled}static setBaseUrl(e){this.apiClient=new qo(e)}static checkAccess(e,t,n){return zo(this,void 0,void 0,(function*(){var r;if(t===Ko.None)throw new Error("Permission is required");return null!==(r=(yield this.checkAccessBulk([e],t,n)).get(e))&&void 0!==r&&r}))}static checkAccessBulk(e,t,n){return zo(this,void 0,void 0,(function*(){var r,o,i,c,a,l;if(t===Ko.None)throw new Error("Permission is required");const u=this.permissionSetToString(t),d=new Map;if(!e||0===e.length)return d;if(!this.isAccessControlEnabled){for(const t of e)d.set(t,!0);return d}if(null!=n&&n>0)try{if(yield this.isSuperAdmin(n)){for(const t of e)d.set(t,!0);return d}}catch(e){}const h=[],f=new Set,p=new Map;let y=null;if(null!=n&&n>0)try{y=yield Yt(n)}catch(e){}let v=0;try{const e=yield function(){return e=this,t=void 0,r=function*(){let e=H();try{var t=yield ee("application/x-www-form-urlencoded");const n=yield C(s.GetConceptByCharacterAndCategoryUrl(),{method:"POST",headers:t,body:"character_value=the_parent_access_inheritance"});return n.ok?(e=yield n.json(),z.AddConcept(e)):(console.log("This is the concept by category and character error",n.status),re(n)),e}catch(e){throw e instanceof Error?console.log(" This is the concept by category and character error message: ",e.message):console.log(" This is the concept by category and character unexpected error: ",e),e}},new((n=void 0)||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}));var e,t,n,r}();e&&e.id&&(v=e.id)}catch(e){}const g=yield ve(e),m=new Map;for(const e of g)m.set(e.id,e);const w=new Map;for(const t of e){const e=null!==(r=m.get(t))&&void 0!==r?r:yield Yt(t);if(!e||0===e.id){d.set(t,!1);continue}const n=null!==(o=e.accessId)&&void 0!==o?o:0,s=null!==(i=e.typeId)&&void 0!==i?i:0;if(y&&y.userId&&y.userId===e.userId){d.set(t,!0);continue}if(n<1e4){d.set(t,!0);continue}let a=0;if(s>0){let e=w.get(s);if(!e)try{e=yield Yt(s),w.set(s,e)}catch(e){}e&&(a=null!==(c=e.accessId)&&void 0!==c?c:0)}h.push({conceptId:t,accessId:n,typeAccessId:a}),n>0&&(f.add(n),p.set(n,t)),a>0&&f.add(a)}if(0===h.length)return d;const T=yield this.resolveBulkInheritanceGraph(f,v,p),I=[],N=new Set;for(const e of T.values())for(const t of e)N.has(t)||(N.add(t),I.push(t));const A=yield this.resolveSubjects(n),E=yield this.resolveBulkDecisions(I,u,A);for(const e of h){const t=null!==(a=T.get(e.accessId))&&void 0!==a?a:[e.accessId],n=e.typeAccessId>0?null!==(l=T.get(e.typeAccessId))&&void 0!==l?l:[e.typeAccessId]:[],r=this.hasAnyGrant(t,n,A,E);d.set(e.conceptId,r)}return d}))}static getConceptIdsWithPermission(e,t,n){return zo(this,void 0,void 0,(function*(){if(e===Ko.None)throw new Error("Permission is required");if(!t||0===t.length)return[];if(!this.isAccessControlEnabled)return t;const r=yield this.checkAccessBulk(t,e,n);return t.filter((e=>!0===r.get(e)))}))}static resolveBulkInheritanceGraph(e,t,n){return zo(this,void 0,void 0,(function*(){var r;const o=new Map,i=new Set;let c=new Set(e),s=0;for(;c.size>0;){if(s>=10){console.warn("[AccessControl] BFS depth limit (10) reached. Stopping inheritance traversal.");break}s++;const e=new Set;for(const e of c)i.add(e);const a=Array.from(c);if(t>0)for(const t of a)try{const n=yield Co(t,["the_parent_access_inheritance"]);if(n&&n.length>0){const r=yield zn(n);for(const n of r){const r=n.toTheConceptId;r&&r>0&&!i.has(r)&&(o.has(t)||o.set(t,[]),o.get(t).push(r),e.add(r))}}}catch(e){}for(const t of a)try{const n=yield this.apiClient.getParentAccessIdAsync(t);if(!0===(null==n?void 0:n.status)&&void 0!==n.data&&null!==n.data){const r=this.parseIntData(n);null!==r&&r>0&&!i.has(r)&&(o.has(t)||o.set(t,[]),o.get(t).push(r),e.add(r))}}catch(e){}for(const c of a)try{const s=yield this.apiClient.getAccessInheritanceStatusAsync(c);if(!this.parseBoolData(s))continue;const a=n.get(c);if(!a||0===a)continue;const l=yield _n(a);if(!l||0===l.length)continue;for(const s of l){if(s.ofTheConceptId!==a)continue;if(t>0&&s.typeId!==t)continue;const l=s.toTheConceptId;if(l&&0!==l)try{const t=yield Yt(l),s=null!==(r=null==t?void 0:t.accessId)&&void 0!==r?r:0;s>0&&!i.has(s)&&(o.has(c)||o.set(c,[]),o.get(c).push(s),n.set(s,l),e.add(s))}catch(e){}}}catch(e){}for(const t of i)e.delete(t);c=e}const a=new Map;for(const t of e){const e=[t],n=new Set([t]),r=[t];for(;r.length>0&&e.length<100;){const t=r.shift(),i=o.get(t);if(i)for(const t of i)n.has(t)||(n.add(t),e.push(t),r.push(t))}a.set(t,e)}return a}))}static resolveBulkDecisions(e,t,n){return zo(this,void 0,void 0,(function*(){var r;const o=new Map,i=new Map;for(let r=0;r<n.length;r++){const c=n[r];for(const n of e){const e=this.cacheService.get(n,t,c),s=`${n}:${null!=c?c:0}`;null!==e?o.set(s,e):(i.has(r)||i.set(r,[]),i.get(r).push(n))}}for(const[e,c]of i){if(0===c.length)continue;const i=n[e];try{const e={accessIds:c,permission:t,entityId:i},n=yield this.apiClient.checkAccessBulkAsync(e);if(!0===(null==n?void 0:n.status)&&n.data&&Array.isArray(n.data)){const e=new Map;for(const t of n.data)e.set(t.accessId,t.hasAccess);for(const n of c){const c=null!==(r=e.get(n))&&void 0!==r&&r;this.cacheService.set(n,t,i,c),o.set(`${n}:${null!=i?i:0}`,c)}}else for(const e of c)this.cacheService.set(e,t,i,!1),o.set(`${e}:${null!=i?i:0}`,!1)}catch(e){for(const e of c)o.set(`${e}:${null!=i?i:0}`,!1)}}return o}))}static resolveSubjects(e){return zo(this,void 0,void 0,(function*(){const t=[null];if(null!=e&&e>0){t.push(e);try{const n=yield Co(e,["the_entity_s_group"]);if(n&&n.length>0){const e=yield zn(n);for(const n of e)n.toTheConceptId&&n.toTheConceptId>0&&t.push(n.toTheConceptId)}}catch(e){}}return t}))}static hasAnyGrant(e,t,n,r){for(const t of e)for(const e of n){const n=`${t}:${null!=e?e:0}`;if(!0===r.get(n))return!0}for(const e of t)for(const t of n){const n=`${e}:${null!=t?t:0}`;if(!0===r.get(n))return!0}return!1}static assignAccess(e,t,n){return zo(this,void 0,void 0,(function*(){var r;if(t===Ko.None)throw new Error("Permission is required");try{const o=null!==(r=(yield Yt(e)).accessId)&&void 0!==r?r:0,i=this.permissionSetToString(t),c=yield this.apiClient.assignAccessAsync({accessId:o,permission:i,entityId:n});if(!0===(null==c?void 0:c.status)&&c.data){const e=c.data;return this.cacheService.set(e.accessId,e.permission,e.entityId,e.hasAccess),!0}return!1}catch(r){throw new Error(`Error assigning access for conceptId ${e}, permission '${t}', entityId ${n}: ${r}`)}}))}static assignAccessBulk(e){return zo(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{const n=yield this.apiClient.assignAccessBulkAsync(e);if(!0!==(null==n?void 0:n.status))throw new Error((null==n?void 0:n.message)||"Failed to assign bulk access");const r=[];for(const n of e.targets)for(const o of n.permissions){const i=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(i,o,n.entityId,!0),r.push({accessId:i,permission:o,entityId:n.entityId,hasAccess:!0})}return r}catch(e){throw console.error("Failed to assign bulk access:",e),e}}))}static revokeAccess(e,t,n){return zo(this,void 0,void 0,(function*(){var r;try{const o=null!==(r=(yield Yt(e)).accessId)&&void 0!==r?r:0,i=this.permissionSetToString(t);if(0===o)throw new Error(`Concept with ID ${e} does not have a valid accessId`);const c=yield this.apiClient.revokeAccessAsync({accessId:o,permission:i,entityId:n}),s=!0===(null==c?void 0:c.status);return this.cacheService.set(o,i,n,!s),s}catch(r){throw new Error(`Error revoking access for concept ${e}, permission '${t}', entityId ${n}: ${r}`)}}))}static revokeAccessBulk(e){return zo(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{yield this.apiClient.revokeAccessBulkAsync(e);const n=[];for(const r of e.targets)for(const o of r.permissions){const i=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(i,o,r.entityId,!1),n.push({accessId:i,permission:o,entityId:r.entityId,hasAccess:!1})}return n}catch(e){throw console.error("Failed to revoke bulk access:",e),e}}))}static setAccessInheritance(e){return zo(this,void 0,void 0,(function*(){var t;try{const n=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,connectionTypeId:999});return null!==(t=null==n?void 0:n.status)&&void 0!==t&&t}catch(t){throw new Error(`Error setting access inheritance for conceptId ${e}: ${t}`)}}))}static getAccessInheritanceStatus(e){return zo(this,arguments,void 0,(function*(e,t=999){try{const n=yield this.apiClient.getAccessInheritanceStatusByConceptAsync(e,t);return this.parseBoolData(n)}catch(n){throw new Error(`Error getting access inheritance status for conceptId ${e}, connectionTypeId ${t}: ${n}`)}}))}static setAccessInheritanceStatus(e,t){return zo(this,arguments,void 0,(function*(e,t,n=999){var r;try{const o=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,enable:t,connectionTypeId:n});return null!==(r=null==o?void 0:o.status)&&void 0!==r&&r}catch(t){throw new Error(`Error setting access inheritance status for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritance(e,t){return zo(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceByConceptAsync({parentConceptId:t,childConceptId:e});if(!0===(null==n?void 0:n.status)){const e=this.parseIntData(n);if(null!==e&&e>0)return e}return 0}catch(t){throw new Error(`Error setting parent access inheritance for conceptId ${e}: ${t}`)}}))}static removeParentAccessInheritance(e,t){return zo(this,void 0,void 0,(function*(){var n;try{const r=yield this.apiClient.removeParentAccessInheritanceByConceptAsync(e,t);return null!==(n=null==r?void 0:r.message)&&void 0!==n?n:"Parent access inheritance removal failed"}catch(t){throw new Error(`Error removing parent access inheritance for conceptId ${e}: ${t}`)}}))}static hasParentAccessInheritance(e,t){return zo(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.hasParentAccessInheritanceByConceptAsync(e,t);return this.parseBoolData(n)}catch(t){throw new Error(`Error checking parent access inheritance for conceptId ${e}: ${t}`)}}))}static getParentAccessId(e){return zo(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.getParentAccessIdByConceptAsync(e);return this.parseIntData(t)}catch(t){throw new Error(`Error getting parent access ID for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritanceBulk(e,t){return zo(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceBulkByConceptAsync({parentConceptId:t,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error setting bulk parent access inheritance for parentConceptId ${t}: ${e}`)}}))}static removeParentAccessInheritanceBulk(e,t){return zo(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.removeParentAccessInheritanceBulkByConceptAsync({parentConceptId:null!=t?t:0,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error removing bulk parent access inheritance: ${e}`)}}))}static isSuperAdmin(e){return zo(this,void 0,void 0,(function*(){try{if(0===e)return!1;const t=this.cacheService.getSuperAdmin(e);if(null!==t)return t;const n=yield this.apiClient.checkSuperAdminByConceptAsync(e);if(!0===(null==n?void 0:n.status)&&void 0!==n.data){const t=this.parseBoolData(n);return this.cacheService.setSuperAdmin(e,t),t}return!1}catch(t){throw new Error(`Error checking super admin status for entityId ${e}: ${t}`)}}))}static assignSuperAdmin(e){return zo(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.assignSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&void 0!==t.data?(this.cacheService.setSuperAdmin(e,!0),e):0}catch(t){throw new Error(`Failed to assign super admin for entityId ${e}: ${t}`)}}))}static revokeSuperAdmin(e){return zo(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.revokeSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&t.message?(this.cacheService.setSuperAdmin(e,!1),t.message):"Super admin access deletion failed"}catch(t){throw new Error(`Failed to revoke super admin for entityId ${e}: ${t}`)}}))}static parseBoolData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return!1;const t=e.data;if("boolean"==typeof t)return t;if("string"==typeof t)return"true"===t.toLowerCase();if("number"==typeof t)return 0!==t;if("object"==typeof t)for(const e of["enabled","Enabled","isEnabled","IsEnabled","status","Status","hasAccess","HasAccess"])if(e in t){const n=t[e];if("boolean"==typeof n)return n;if("string"==typeof n)return"true"===n.toLowerCase()}return!1}static parseIntData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return null;const t=e.data;if("number"==typeof t)return t;if("string"==typeof t){const e=parseInt(t,10);return isNaN(e)?null:e}if("object"==typeof t)for(const e of["id","Id","accessId","AccessId","parentAccessId","ParentAccessId"])if(e in t){const n=t[e];if("number"==typeof n)return n;if("string"==typeof n){const e=parseInt(n,10);if(!isNaN(e))return e}}return null}static permissionSetToString(e){return function(e){const t=[];return e&Ko.Read&&t.push("read"),e&Ko.Write&&t.push("write"),e&Ko.Execute&&t.push("execute"),e&Ko.Delete&&t.push("delete"),t}(e)[0]||"read"}static clearCache(){this.cacheService.clear()}static clearSuperAdminCache(){this.cacheService.clearSuperAdminCache()}static updateAccessCache(e,t,n,r){this.cacheService.set(e,t,n,r)}static updateSuperAdminCache(e,t){this.cacheService.setSuperAdmin(e,t)}}Jo.cacheService=new Wo,Jo.apiClient=new qo,Jo.isAccessControlEnabled=!1,Jo.initialize();var Yo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Qo=1,Zo=2,ei=3,ti=4,ni=5,ri=6,oi=7,ii=8;class ci{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var si=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ai(e){return si(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let r=yield Se(e[n].connectionTypeId);e[n].connectionType=r.characterValue,t[e[n].conceptId]||(t[e[n].conceptId]=[]),t[e[n].conceptId].push(e[n])}return t}))}function li(e){const t=e.split("_");if(3===t.length){let e=new ci;return e.conceptId=Number(t[0]),e.connectionTypeId=Number(t[1]),e.count=Number(t[2]),e}throw new Error("Input string must contain exactly three parts separated by underscores.")}function ui(e){return e.startsWith("the_")?e.slice(4):e}var di=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function hi(e,t,n){if(e in t){const r=Array.isArray(t[e])?t[e]:[t[e]];for(const e of r)e&&(n[e.connectionType+"_count"]=e.count)}}var fi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},pi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function yi(e,t,n){return pi(this,void 0,void 0,(function*(){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1;n.includes(e[d].id)&&(h=!0);let f=yield Yt(e[d].ofTheConceptId),p=yield Yt(e[d].toTheConceptId);if(1==h){if(0!=f.id&&0!=p.id){let n,s=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?n=t[e[d].toTheConceptId]:(n={},n[s]={},t[e[d].toTheConceptId]=n);let a=yield Yt(e[d].typeId);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",n=f.characterValue;a.characterValue,a.characterValue.includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[p.id]={}}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?n=t[e[d].ofTheConceptId]:(n={},n[r]={},t[e[d].ofTheConceptId]=n);let o=yield Yt(e[d].typeId);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",n=p.characterValue;o.characterValue.includes("_s_")&&(p.id in t||(t[p.id]={}),t[p.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}var vi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function gi(e,t="DESC"){return"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var mi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};var Ci=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function wi(e,t){return Ci(this,void 0,void 0,(function*(){let n=e.outputFormat;e.outputFormat=ri;let r,o=yield function(e){return Yo(this,arguments,void 0,(function*(e,t=""){var n=yield te("application/json",t);const r=s.FreeschemaQueryUrl(),o=JSON.stringify(e);try{const e=yield C(r,{method:"POST",headers:n,body:o});if(e.ok)return yield e.json();re(e)}catch(e){!function(e,t=""){if(e.status){let n=new ne(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new ne(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,r)}}))}(e,t),i=o.conceptIds,c=(o.internalConnections,o.linkers),a=o.reverse,l=o.mainCompositionIds,u=o.countinfo,d=e.order,h=function(e=[]){let t=[];if(e.length>0)for(let n=0;n<(null==e?void 0:e.length);n++){let r=li(e[n]);t.push(r)}return t}(u);return r=n==Zo?yield function(e,t,n,r,o){return mi(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield er(e),s=yield ai(o);c=gi(c,i);let a=[];a=yield function(e,t){return fi(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Yt(e[d].ofTheConceptId),p=yield Yt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Yt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?n=t[e[d].toTheConceptId]:(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(s.characterValue+"_reverse").includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[p.id]={}}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield Yt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?n=t[e[d].ofTheConceptId]:(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",n=p.characterValue;r.characterValue.includes("_s_")&&(p.id in t||(t[p.id]={}),t[p.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}(c,a,r),a=yield function(e,t){return fi(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Yt(e[d].ofTheConceptId),p=yield Yt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Yt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=s.characterValue;""==r&&(r=e,r=ui(r));let o={id:f.id,data:{[e]:t}},l=r+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield Yt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",t=p.characterValue,i=r.characterValue,c=!1;""==i&&(i=e,i=ui(i),c=!0);let s={id:p.id,data:{[e]:t}};isNaN(Number(i))?i.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][i]=s):(Array.isArray(n[o])||(n[o]=[]),n[o].push(s))}catch(e){}}}return t}))}(c,a,r);let l=yield function(e,t,n,r){return fi(this,arguments,void 0,(function*(e,t,n,r,o=[],i){var c,s,a,l,u,d,h;(new Date).getTime();let f=[],p=[];for(let t=0;t<e.length;t++)p.push(e[t].toTheConceptId),p.push(e[t].ofTheConceptId),p.push(e[t].typeId);for(let n=0;n<e.length;n++){let r=!1,f=yield Yt(e[n].ofTheConceptId),p=yield Yt(e[n].toTheConceptId);if(o.includes(e[n].id)&&(r=!0),1==r){if(0!=f.id&&0!=p.id&&p.id in t){let r,o=yield Yt(e[n].typeId),a=null!==(s=null===(c=p.type)||void 0===c?void 0:c.characterValue)&&void 0!==s?s:"self",l=!1;e[n].toTheConceptId in t&&(l=!0),e[n].toTheConceptId in t?(r=t[e[n].toTheConceptId],"string"==typeof r[a]&&(r[a]={})):(r={},r[a]={},t[e[n].toTheConceptId]=r),hi(p.id,i,r);try{if(t[e[n].ofTheConceptId]){let i={id:f.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},c=o.characterValue+"_reverse";Array.isArray(r[a][c])?r[a][c].push(i):c.includes("_s_")?(r[a][c]=[],r[a][c].push(i)):r[a][c]=i}}catch(e){}}}else if(0!=f.id&&0!=p.id&&f.id in t){let r,o=yield Yt(e[n].typeId),c=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self",s=!1;e[n].toTheConceptId in t&&(s=!0),e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[c]&&(r[c]={})):(r={},r[c]={},t[e[n].ofTheConceptId]=r),hi(f.id,i,r);let y=!0,v=o.characterValue;""==v&&(v=p.characterValue,y=!0),""==v&&(v=null!==(d=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==d?d:"");try{null===(h=null==p?void 0:p.type)||void 0===h||h.characterValue;let s=t[e[n].toTheConceptId];if(s){let a={id:p.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(r[c])?r[c].push(s):Array.isArray(r[c][v])?r[c][o.characterValue].push(a):v.includes("_s_")?(r[c][v]=[],r[c][v].push(a)):r[c][v]=a,hi(p.id,i,a)}}catch(e){}}}for(let e=0;e<r.length;e++){let n={};n.id=r[e];let o=yield Yt(n.id);n.data=t[r[e]],n.created_on=o.entryTimeStamp,f.push(n)}return f}))}(c,a,[],n,r,s);return l}))}(c,i,l,a,h,d):n==ei?yield function(e,t,n,r,o){return mi(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield er(e),s=yield ai(o);c=gi(c,i);let a=[];a=yield yi(c,a,r),a=yield function(e,t){return di(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Yt(e[d].ofTheConceptId),p=yield Yt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Yt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=s.characterValue;""==r&&(r=e,r=ui(r));let o={id:f.id,[e]:t},l=r+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield Yt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let t=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",i=p.characterValue,c=r.characterValue,s=!1;""==c&&(c=t,c=ui(c),s=!0);let a={};a[t]={id:p.id,data:i,created_on:e[d].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][c]=s?a[t]:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(a[t]))}catch(e){}}}return t}))}(c,a,r);let l=yield function(e,t,n){return di(this,arguments,void 0,(function*(e,t,n,r=[],o){var i,c,s,a,l,u,d,h;(new Date).getTime();let f=[],p=[];for(let t=0;t<e.length;t++)p.push(e[t].toTheConceptId),p.push(e[t].ofTheConceptId),p.push(e[t].typeId);for(let n=0;n<e.length;n++){let f=!1,p=yield Yt(e[n].ofTheConceptId),y=yield Yt(e[n].toTheConceptId);if(r.includes(e[n].id)&&(f=!0),1==f){if(0!=p.id&&0!=y.id&&y.id in t){let r,o=yield Yt(e[n].typeId),s=null!==(c=null===(i=y.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self",a=!1;e[n].toTheConceptId in t&&(a=!0),e[n].toTheConceptId in t?(r=t[e[n].toTheConceptId],"string"==typeof r[s]&&(r[s]={})):(r={},r[s]={},t[e[n].toTheConceptId]=r);try{if(t[e[n].ofTheConceptId]){let i=t[e[n].ofTheConceptId];i&&(i.id=p.id,i.created_on=p.entryTimeStamp);let c=o.characterValue+"_reverse";Array.isArray(r[s][c])?r[s][c].push(i):c.includes("_s_")?(r[s][c]=[],r[s][c].push(i)):r[s][c]=i}}catch(e){}}}else if(0!=p.id&&0!=y.id&&p.id in t){let r,i=yield Yt(e[n].typeId),c=null!==(a=null===(s=p.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self",f=!1;e[n].toTheConceptId in t&&(f=!0),e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[c]&&(r[c]={})):(r={},r[c]={},t[e[n].ofTheConceptId]=r),hi(p.id,o,r);let v=!1,g=i.characterValue;""==g&&(g=y.characterValue,v=!0),""==g&&(g=null!==(u=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"");try{let i=null!==(h=null===(d=null==y?void 0:y.type)||void 0===d?void 0:d.characterValue)&&void 0!==h?h:"none",s=t[e[n].toTheConceptId];if(s){let t={};t[i]={data:s[i],id:y.id,created_on:e[n].entryTimeStamp},Array.isArray(r[c])?v?r[c].push(s[g]):r[c].push(s):Array.isArray(r[c][g])?r[c][g].push(t):g.includes("_s_")?(r[c][g]=[],v?r[c][g].push(t[i]):r[c][g].push(t)):r[c][g]=v?t[i]:t,hi(y.id,o,t)}}catch(e){}}}for(let e=0;e<n.length;e++){let r={};r=t[n[e]],r&&(r.id=n[e]),f.push(r)}return f}))}(c,a,n,r,s);return l}))}(c,i,l,a,h,d):n==ii?yield function(e,t,n,r,o){return mi(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield er(e),s=yield ai(o);c=gi(c,i);let a={};a=yield function(e){return vi(this,arguments,void 0,(function*(e,t={},n=[]){var r,o,i,c,s;for(const a of e){const e=n.includes(a.id),l=yield Yt(a.ofTheConceptId),u=yield Yt(a.toTheConceptId),d=yield Yt(a.typeId);if(0===l.id||0===u.id)continue;const h=e?u:l,f=e?l:u,p=null!==(o=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self",y=null!==(c=null===(i=f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null===(s=d.characterValue)||void 0===s?void 0:s.includes("_s_");t[h.id]||(t[h.id]={}),t[h.id][p]||(t[h.id][p]={}),g&&(t[f.id]||(t[f.id]={}),t[f.id][y]=v)}return t}))}(c,a,r),a=yield function(e){return vi(this,arguments,void 0,(function*(e,t={},n=[]){var r,o,i,c,s;for(const a of e){const e=n.includes(a.id),l=yield Yt(a.ofTheConceptId),u=yield Yt(a.toTheConceptId),d=yield Yt(a.typeId);if(0===l.id||0===u.id)continue;const h=e?u:l,f=e?l:u,p=null!==(o=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self",y=null!==(c=null===(i=f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null!==(s=d.characterValue)&&void 0!==s?s:"";let m=""===g?ui(y):g;const C=m.includes("_s_"),w=!isNaN(Number(m)),T={id:f.id,data:{[y]:v}};t[h.id]||(t[h.id]={}),p in t[h.id]&&"string"!=typeof t[h.id][p]||(t[h.id][p]=w?[]:{});try{if(C)continue;w?t[h.id][p].push(T):t[h.id][p][e?`${m}_reverse`:m]=T}catch(e){console.error("Error formatting concept data:",e)}}return t}))}(c,a,r);let l=yield function(e,t,n){return vi(this,arguments,void 0,(function*(e,t,n,r=[],o){var i,c,s;const a=[];for(const n of e){const e=r.includes(n.id),a=yield Yt(n.ofTheConceptId),l=yield Yt(n.toTheConceptId),u=yield Yt(n.typeId);if(0===a.id||0===l.id)continue;const d=e?l:a,h=e?a:l,f=d.id,p=h.id,y=null!==(c=null===(i=d.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self",v=u.characterValue+"_reverse",g=u.characterValue||h.characterValue||(null===(s=h.type)||void 0===s?void 0:s.characterValue)||"";if(t[f]){const r=t[f][y],i=t[p],c={id:h.id,data:i,created_on:n.entryTimeStamp};hi(f,o,t[f]);try{e?Array.isArray(r[v])?r[v].push(c):r[v]=[c]:Array.isArray(r)?r.push(i):Array.isArray(r[g])?r[g].push(c):g.includes("_s_")?(r[g]=[],r[g].push(c)):r[g]=[c],hi(p,o,c)}catch(e){console.error("Error processing connection:",e)}}}for(const e of n){const n=yield Yt(e);a.push({id:e,data:t[e],created_on:n.entryTimeStamp})}return a}))}(c,a,n,r,s);return l}))}(c,i,l,a,h,d):yield function(e,t,n,r){return mi(this,void 0,void 0,(function*(){let t=yield er(e);t=gi(t);let o=[];o=yield yi(t,o,r),o=yield function(e,t,n){return pi(this,void 0,void 0,(function*(){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let d=0;d<e.length;d++){let h=!1;n.includes(e[d].id)&&(h=!0);let f=yield Yt(e[d].ofTheConceptId),p=yield Yt(e[d].toTheConceptId);if(1==h){if(0!=f.id&&0!=p.id){let n,s=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},t[e[d].toTheConceptId]=n);let a=yield Yt(e[d].typeId);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=a.characterValue;""==r&&(r=e,r=ui(r));let o={[e]:t},l=r+"_reverse";a.characterValue.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],r in n||(n[r]={})):(n={},n[r]={},t[e[d].ofTheConceptId]=n);let o=yield Yt(e[d].typeId);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",t=p.characterValue,i=o.characterValue,c=(o.characterValue,!1);""==i&&(i=e,i=ui(i),c=!0);let s={[e]:t};isNaN(Number(i))?o.characterValue.includes("_s_")||("string"==typeof n[r]&&(n[r]={}),n[r][i]=c?t:s):(Array.isArray(n[r])||(n[r]=[]),n[r].push(t))}catch(e){}}}return t}))}(t,o,r);let i=yield function(){return pi(this,arguments,void 0,(function*(e=[],t=[],n=[],r,o=[]){var i,c,s,a,l,u;let d=[],h=[];for(let t=0;t<e.length;t++)h.push(e[t].toTheConceptId),h.push(e[t].ofTheConceptId),h.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let n=0;n<e.length;n++){let r=!1;o.includes(e[n].id)&&(r=!0);let d=yield Yt(e[n].ofTheConceptId),h=yield Yt(e[n].toTheConceptId);if(1==r){if(0!=d.id&&0!=h.id&&h.id in t){let r,o=null!==(c=null===(i=h.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self";e[n].toTheConceptId in t?r=t[e[n].toTheConceptId]:(r={},r[o]={},t[e[n].toTheConceptId]=r);let s=yield Yt(e[n].typeId);try{let i=s.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(r[o][i])?r[o][i].push(c):s.characterValue.includes("_s_")?(r[o][i]=[],r[o][i].push(c)):r[o][i]=c)}catch(e){}}}else if(0!=d.id&&0!=h.id&&d.id in t){let r,o=null!==(a=null===(s=d.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[o]&&(r[o]={})):(r={},r[o]={},t[e[n].ofTheConceptId]=r);let i=!1,c=(yield Yt(e[n].typeId)).characterValue;""==c&&(c=h.characterValue,i=!0),""==c&&(c=null!==(u=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"");try{let s=t[e[n].toTheConceptId];s&&(Array.isArray(r[o])?i?r[o].push(s[c]):r[o].push(s):Array.isArray(r[o][c])?r[o][c].push(s):c.includes("_s_")?(r[o][c]=[],i?r[o][c].push(s[c]):r[o][c].push(s)):r[o][c]=i?s[c]:s)}catch(e){}}}for(let e=0;e<n.length;e++){let r=t[n[e]];r&&(r.id=n[e],d.push(r))}return d}))}(t,o,n,[],r);return i}))}(c,0,l,a),r}))}class Ti{constructor(){this.type="",this.inpage=10,this.page=1,this.concepts=[],this.conceptIds=[],this.selectors=[],this.freeschemaQueries=[],this.filters=[],this.filterLogic="",this.typeConnection="",this.order="DESC",this.outputFormat=Qo,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1,this.usePipelineQuery=!1}}var Ii=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ni(e,t){return Ii(this,arguments,void 0,(function*(e,t,n=!1){let r=[];if(n){let n=yield On(e),o=yield nt(t);for(let e=0;e<n.length;e++)n[e].typeId==o.id&&r.push(n[e])}else{let n=yield _n(e);for(let e=0;e<n.length;e++)pe.AddConnection(n[e]);let o=yield nt(t);for(let e=0;e<n.length;e++)n[e].typeId==o.id&&r.push(n[e])}return r}))}function Ai(e,t,n){return Ii(this,arguments,void 0,(function*(e,t,n,r=!1){let o=[],i=[];if(o=r?yield Ni(t,n,r):yield Ni(e,n,r),r)for(let t=0;t<o.length;t++)o[t].ofTheConceptId==e&&i.push(o[t]);else for(let e=0;e<o.length;e++)o[e].toTheConceptId==t&&i.push(o[e]);return i}))}var Ei=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Si(e=""){a.BearerAccessToken=e}function Ri(){return Ei(this,arguments,void 0,(function*(e="",t="",n="CCSApp",r){var o,i;const c=r||new Eo;Jo.setBaseUrl(c.accessControlBaseUrl),Jo.setEnabled(c.enableAccessControl),s.BASE_URL=e,s.AI_URL=c.aiUrl,t&&(s.NODE_URL=t);const l=c.cacheServers.length>0?c.cacheServers:Ao(null!==(i=null===(o=c.parameters)||void 0===o?void 0:o.cacheServers)&&void 0!==i?i:c.getParameter("cacheServers",""));s.setCacheServers(l);const u=c.cacheServerUrl||c.getParameter("cacheServerUrl","");if(u?s.setNodeCacheUrl(u):0===l.length&&s.setNodeCacheUrl(""),c.hasOAuthCredentials()){const e=c.applicationName||n;a.setOAuthCredentials(c.clientId,c.clientSecret,e);const t=yield d(c.clientId,c.clientSecret,e,!0);if(!t.success)throw new Error(`OAuth token request failed: ${t.error||"unknown error"}`)}else c.hasAccessToken()&&(a.BearerAccessToken=c.accessToken);B.isDataLoaded=!1,B.isCharacterLoaded=!1,B.isTypeLoaded=!1,B.isLocalDataLoaded=!1,B.isLocalTypeLoaded=!1,B.isLocalCharacterLoaded=!1,B.isConnectionLoaded=!1,B.isConnectionTypeLoaded=!1,B.isLocalConnectionLoaded=!1,yield function(){return Ho(this,void 0,void 0,(function*(){return yield $("settings")[0]||new k(!0),yield function(){return Vo(this,void 0,void 0,(function*(){}))}(),!0}))}(),yield Promise.all([Y().then((()=>{B.isDataLoaded=!0,B.isCharacterLoaded=!0,B.isTypeLoaded=!0})),jo().then((()=>{B.isLocalDataLoaded=!0,B.isLocalTypeLoaded=!0,B.isLocalCharacterLoaded=!0})),bo().then((()=>{B.isLocalConnectionLoaded=!0})),xo().then((()=>{B.isConnectionLoaded=!0,B.isConnectionTypeLoaded=!0}))])}))}var ki=o.BG,xi=o.$e,bi=o.TR,$i=o.Tc,Li=o.U3,_i=o.Wg,Pi=o.g2,Oi=o.BO,Ui=o.WW,Bi=o.BS,Di=o.ji,Fi=o.Ij,Gi=o.Ng,ji=o.du,Vi=o.RC,Mi=o.d4,Hi=o.Cd,Wi=o.IM,Ki=o.oI,Xi=o.u9,qi=o.B7,zi=o.mF,Ji=o.Q9,Yi=o.wT,Qi=o.hZ,Zi=o.y0,ec=o.iw,tc=o.pU,nc=o.qN,rc=o.mZ,oc=o.Ec,ic=o.L0,cc=o.Te,sc=o.vw,ac=o.z8,lc=o.k9,uc=o.sP,dc=o.Y3,hc=o.WC,fc=o.Nj,pc=o.dF,yc=o.cw,vc=o.p8,gc=o.rv,mc=o.pX,Cc=o.iD,wc=o.Mb,Tc=o.bq,Ic=o.ke,Nc=o.w1,Ac=o.yz,Ec=o.RW,Sc=o.WL,Rc=o.rh,kc=o.nW,xc=o.RH,bc=o.Aj,$c=o.cV,Lc=o.jM,_c=o.nS,Pc=o.Yu,Oc=o.xf,Uc=o.KS,Bc=o.L6,Dc=o.Z9,Fc=o.Ny,Gc=o.qY,jc=o.jQ,Vc=o.NT,Mc=o.Xr,Hc=o.ab,Wc=o.SV,Kc=o.EA,Xc=o.M2,qc=o.OY,zc=o.ry,Jc=o.cS,Yc=o.ZJ,Qc=o.RA,Zc=o.BH,es=o.SL,ts=o.Ne,ns=o.fg,rs=o.M4,os=o.UG,is=o.CT,cs=o.yv,ss=o.vI,as=o.oe,ls=o.XZ,us=o.ZE,ds=o.pi,hs=o.B8,fs=o.yx,ps=o.br,ys=o.eU,vs=o.cf,gs=o.jy,ms=o.cm,Cs=o.qn,ws=o.ss,Ts=o.pf,Is=o.pZ,Ns=o.l4,As=o.f8,Es=o.Y6,Ss=o.FS,Rs=o.bM,ks=o.ZX,xs=o.CE,bs=o.Sf,$s=o.tp,Ls=o.Ry,_s=o.jh,Ps=o.dp,Os=o.a2,Us=o.C$,Bs=o.J5,Ds=o.sc,Fs=o.x9,Gs=o.Py,js=o.Xc,Vs=o.Ts,Ms=o.P$,Hs=o.xX,Ws=o.ae,Ks=o.zN,Xs=o.dU,qs=o.mA,zs=o.En,Js=o.eD,Ys=o.$Q;export{ki as ALLID,xi as AccessControlService,bi as AddGhostConcept,$i as AddGhostConnection,Li as BaseUrl,_i as BinaryTree,Pi as CCSConfig,Oi as Composition,Ui as CompositionBinaryTree,Bi as CompositionNode,Di as Concept,Fi as ConceptsData,Gi as Connection,ji as ConnectionData,Vi as CreateComposition,Mi as CreateConnection,Hi as CreateConnectionBetweenTwoConcepts,Wi as CreateConnectionBetweenTwoConceptsGeneral,Ki as CreateDefaultConcept,Xi as CreateDefaultLConcept,qi as CreateSession,zi as CreateSessionVisit,Ji as CreateTheCompositionWithCache,Yi as CreateTheConnectionGeneral,Qi as CreateTypeConcept,Zi as DATAID,ec as DATAIDDATE,tc as DATAV2,nc as DeleteConceptById,rc as DeleteConnectionById,oc as DeleteConnectionByIdBulk,ic as DeleteConnectionByTypeBulk,cc as FilterSearch,sc as FormatFromConnections,ac as FreeSchemaResponse,lc as FreeschemaQuery,uc as GetAllConnectionsOfComposition,dc as GetAllConnectionsOfCompositionBulk,hc as GetAllTheConnectionsByTypeAndOfTheConcept,fc as GetComposition,pc as GetCompositionBulk,yc as GetCompositionBulkWithDataId,vc as GetCompositionFromConnectionsWithDataId,gc as GetCompositionFromConnectionsWithDataIdInObject,mc as GetCompositionList,Cc as GetCompositionListWithId,wc as GetCompositionWithAllIds,Tc as GetCompositionWithCache,Ic as GetCompositionWithDataIdBulk,Nc as GetCompositionWithDataIdWithCache,Ac as GetCompositionWithId,Ec as GetCompositionWithIdFromMemory,Sc as GetCompositionWithIdFromMemoryFromConnections,Rc as GetConceptBulk,kc as GetConceptByCharacter,xc as GetConceptByCharacterAndCategoryDirectApi,bc as GetConceptByCharacterAndType,$c as GetConceptByTypeBulk,Lc as GetConnectionBulk,_c as GetConnectionById,Pc as GetConnectionByTypeBulk,Oc as GetConnectionOfTheConcept,Uc as GetConnectionsBetweenApi,Bc as GetLink,Dc as GetLinkRaw,Fc as GetLinkerConnectionFromConcepts,Gc as GetLinkerConnectionToConcepts,jc as GetRelation,Vc as GetRelationRaw,Mc as GetRequestHeader,Hc as GetRequestHeaderWithAuthorization,Wc as GetTheConcept,Kc as GetUserGhostConnectionId,Xc as GetUserGhostId,qc as GiveConnection,zc as HandleHttpError,Jc as HttpResponse,Yc as JUSTDATA,Qc as LConcept,Zc as LConnection,es as LISTNORMAL,ts as LoginToBackend,ns as MakeTheInstanceConcept,rs as MakeTheTimestamp,os as MakeTheTypeConcept,is as MakeTheTypeConceptApi,cs as NORMAL,ss as PatcherStructure,as as PermissionSet,ls as RAW,us as RecursiveSearchApi,ds as ReservedConnectionIds,hs as ReservedIds,fs as SchemaQueryListener,ps as SearchAllConcepts,ys as SearchLinkInternal,vs as SearchLinkMultipleAll,gs as SearchLinkMultipleApi,ms as SearchQuery,Cs as SearchStructure,ws as SearchWithLinker,Ts as SessionData,Is as Signin,Ns as Signup,As as SplitStrings,Es as SyncData,Ss as TokenRefreshError,Rs as TokenStorage,ks as Transaction,xs as TrashTheConcept,bs as UpdateComposition,$s as UserBinaryTree,Ls as ViewInternalData,_s as buildFetchConnection,Ps as convertFromLConceptToConcept,Os as deleteWithRetry,Us as fetchWithCacheServerFallback,Bs as fetchWithRetry,Ds as getFromDatabaseWithType,Fs as getFromDatabaseWithTypeOld,Gs as getOAuthToken,js as getWithRetry,Vs as init,Ms as patchWithRetry,Hs as postWithRetry,Ws as putWithRetry,Ks as recursiveFetch,Xs as recursiveFetchNew,qs as refreshOAuthToken,zs as requestWithRetry,Js as storeToDatabase,Ys as updateAccessToken};
2
+ import{createRequire as e}from"node:module";var t={144:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n=!1)=>{if(e instanceof r)return e;try{return new r(e,t)}catch(e){if(!n)return null;throw e}}},181:t=>{t.exports=e(import.meta.url)("buffer")},270:(e,t,n)=>{const r=n(3908),o=n(8311);e.exports=(e,t,n)=>{let i=null,c=null,s=null;try{s=new o(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(i&&1!==c.compare(e)||(i=e,c=new r(i,n)))})),i}},560:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n)=>new r(e,n).compare(new r(t,n))},855:(e,t,n)=>{var r=n(6585);e.exports=function(e,t){var n=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var o=r(e);if(void 0===o)return;return Math.floor(n+o/1e3)}return"number"==typeof e?n+e:void 0}},909:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n)=>{const o=new r(e,n),i=new r(t,n);return o.compare(i)||o.compareBuild(i)}},1045:(e,t,n)=>{var r=n(181).Buffer,o=n(181).SlowBuffer;function i(e,t){if(!r.isBuffer(e)||!r.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var n=0,o=0;o<e.length;o++)n|=e[o]^t[o];return 0===n}e.exports=i,i.install=function(){r.prototype.equal=o.prototype.equal=function(e){return i(this,e)}};var c=r.prototype.equal,s=o.prototype.equal;i.restore=function(){r.prototype.equal=c,o.prototype.equal=s}},1123:e=>{const t=/^[0-9]+$/,n=(e,n)=>{const r=t.test(e),o=t.test(n);return r&&o&&(e=+e,n=+n),e===n?0:r&&!o?-1:o&&!r?1:e<n?-1:1};e.exports={compareIdentifiers:n,rcompareIdentifiers:(e,t)=>n(t,e)}},1261:(e,t,n)=>{const r=n(3908),o=n(8311),i=n(5580);e.exports=(e,t)=>{e=new o(e,t);let n=new r("0.0.0");if(e.test(n))return n;if(n=new r("0.0.0-0"),e.test(n))return n;n=null;for(let t=0;t<e.set.length;++t){const o=e.set[t];let c=null;o.forEach((e=>{const t=new r(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":c&&!i(t,c)||(c=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!c||n&&!i(n,c)||(n=c)}return n&&e.test(n)?n:null}},1691:(e,t,n)=>{const r=n(1741),o=n(3726),i=n(8980),c=n(7260),s=n(855),a=n(7019),l=n(4977),u=n(5747),{KeyObject:d,createSecretKey:h,createPublicKey:f}=n(6982),p=["RS256","RS384","RS512"],y=["ES256","ES384","ES512"],v=["RS256","RS384","RS512"],g=["HS256","HS384","HS512"];l&&(p.splice(p.length,0,"PS256","PS384","PS512"),v.splice(v.length,0,"PS256","PS384","PS512")),e.exports=function(e,t,n,l){let m;if("function"!=typeof n||l||(l=n,n={}),n||(n={}),n=Object.assign({},n),m=l||function(e,t){if(e)throw e;return t},n.clockTimestamp&&"number"!=typeof n.clockTimestamp)return m(new r("clockTimestamp must be a number"));if(void 0!==n.nonce&&("string"!=typeof n.nonce||""===n.nonce.trim()))return m(new r("nonce must be a non-empty string"));if(void 0!==n.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof n.allowInvalidAsymmetricKeyTypes)return m(new r("allowInvalidAsymmetricKeyTypes must be a boolean"));const C=n.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return m(new r("jwt must be provided"));if("string"!=typeof e)return m(new r("jwt must be a string"));const w=e.split(".");if(3!==w.length)return m(new r("jwt malformed"));let T;try{T=c(e,{complete:!0})}catch(e){return m(e)}if(!T)return m(new r("invalid token"));const I=T.header;let N;if("function"==typeof t){if(!l)return m(new r("verify must be called asynchronous if secret or public key is provided as a callback"));N=t}else N=function(e,n){return n(null,t)};return N(I,(function(t,c){if(t)return m(new r("error in secret or public key callback: "+t.message));const l=""!==w[2].trim();if(!l&&c)return m(new r("jwt signature is required"));if(l&&!c)return m(new r("secret or public key must be provided"));if(!l&&!n.algorithms)return m(new r('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=c&&!(c instanceof d))try{c=f(c)}catch(e){try{c=h("string"==typeof c?Buffer.from(c):c)}catch(e){return m(new r("secretOrPublicKey is not valid key material"))}}if(n.algorithms||("secret"===c.type?n.algorithms=g:["rsa","rsa-pss"].includes(c.asymmetricKeyType)?n.algorithms=v:"ec"===c.asymmetricKeyType?n.algorithms=y:n.algorithms=p),-1===n.algorithms.indexOf(T.header.alg))return m(new r("invalid algorithm"));if(I.alg.startsWith("HS")&&"secret"!==c.type)return m(new r(`secretOrPublicKey must be a symmetric key when using ${I.alg}`));if(/^(?:RS|PS|ES)/.test(I.alg)&&"public"!==c.type)return m(new r(`secretOrPublicKey must be an asymmetric key when using ${I.alg}`));if(!n.allowInvalidAsymmetricKeyTypes)try{a(I.alg,c)}catch(e){return m(e)}let N;try{N=u.verify(e,T.header.alg,c)}catch(e){return m(e)}if(!N)return m(new r("invalid signature"));const A=T.payload;if(void 0!==A.nbf&&!n.ignoreNotBefore){if("number"!=typeof A.nbf)return m(new r("invalid nbf value"));if(A.nbf>C+(n.clockTolerance||0))return m(new o("jwt not active",new Date(1e3*A.nbf)))}if(void 0!==A.exp&&!n.ignoreExpiration){if("number"!=typeof A.exp)return m(new r("invalid exp value"));if(C>=A.exp+(n.clockTolerance||0))return m(new i("jwt expired",new Date(1e3*A.exp)))}if(n.audience){const e=Array.isArray(n.audience)?n.audience:[n.audience];if(!(Array.isArray(A.aud)?A.aud:[A.aud]).some((function(t){return e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))})))return m(new r("jwt audience invalid. expected: "+e.join(" or ")))}if(n.issuer&&("string"==typeof n.issuer&&A.iss!==n.issuer||Array.isArray(n.issuer)&&-1===n.issuer.indexOf(A.iss)))return m(new r("jwt issuer invalid. expected: "+n.issuer));if(n.subject&&A.sub!==n.subject)return m(new r("jwt subject invalid. expected: "+n.subject));if(n.jwtid&&A.jti!==n.jwtid)return m(new r("jwt jwtid invalid. expected: "+n.jwtid));if(n.nonce&&A.nonce!==n.nonce)return m(new r("jwt nonce invalid. expected: "+n.nonce));if(n.maxAge){if("number"!=typeof A.iat)return m(new r("iat required when maxAge is specified"));const e=s(n.maxAge,A.iat);if(void 0===e)return m(new r('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(C>=e+(n.clockTolerance||0))return m(new i("maxAge exceeded",new Date(1e3*e)))}if(!0===n.complete){const e=T.signature;return m(null,{header:I,payload:A,signature:e})}return m(null,A)}))}},1729:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,t);return n&&n.prerelease.length?n.prerelease:null}},1741:e=>{var t=function(e,t){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,t&&(this.inner=t)};(t.prototype=Object.create(Error.prototype)).constructor=t,e.exports=t},1763:(e,t,n)=>{const r=n(560);e.exports=(e,t)=>r(e,t,!0)},1832:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,null,!0),o=r(t,null,!0),i=n.compare(o);if(0===i)return null;const c=i>0,s=c?n:o,a=c?o:n,l=!!s.prerelease.length;if(a.prerelease.length&&!l){if(!a.patch&&!a.minor)return"major";if(0===a.compareMain(s))return a.minor&&!a.patch?"minor":"patch"}const u=l?"pre":"";return n.major!==o.major?u+"major":n.minor!==o.minor?u+"minor":n.patch!==o.patch?u+"patch":"prerelease"}},1977:(e,t,n)=>{const r=n(9589);e.exports=r.satisfies(process.version,">=15.7.0")},2010:(e,t,n)=>{var r=n(2861).Buffer,o=n(3527);function i(e){if(r.isBuffer(e))return e;if("string"==typeof e)return r.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function c(e,t,n){for(var r=0;t+r<n&&0===e[t+r];)++r;return e[t+r]>=128&&--r,r}e.exports={derToJose:function(e,t){e=i(e);var n=o(t),c=n+1,s=e.length,a=0;if(48!==e[a++])throw new Error('Could not find expected "seq"');var l=e[a++];if(129===l&&(l=e[a++]),s-a<l)throw new Error('"seq" specified length of "'+l+'", only "'+(s-a)+'" remaining');if(2!==e[a++])throw new Error('Could not find expected "int" for "r"');var u=e[a++];if(s-a-2<u)throw new Error('"r" specified length of "'+u+'", only "'+(s-a-2)+'" available');if(c<u)throw new Error('"r" specified length of "'+u+'", max of "'+c+'" is acceptable');var d=a;if(a+=u,2!==e[a++])throw new Error('Could not find expected "int" for "s"');var h=e[a++];if(s-a!==h)throw new Error('"s" specified length of "'+h+'", expected "'+(s-a)+'"');if(c<h)throw new Error('"s" specified length of "'+h+'", max of "'+c+'" is acceptable');var f=a;if((a+=h)!==s)throw new Error('Expected to consume entire buffer, but "'+(s-a)+'" bytes remain');var p=n-u,y=n-h,v=r.allocUnsafe(p+u+y+h);for(a=0;a<p;++a)v[a]=0;e.copy(v,a,d+Math.max(-p,0),d+u);for(var g=a=n;a<g+y;++a)v[a]=0;return e.copy(v,a,f+Math.max(-y,0),f+h),(v=v.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=i(e);var n=o(t),s=e.length;if(s!==2*n)throw new TypeError('"'+t+'" signatures must be "'+2*n+'" bytes, saw "'+s+'"');var a=c(e,0,n),l=c(e,n,e.length),u=n-a,d=n-l,h=2+u+1+1+d,f=h<128,p=r.allocUnsafe((f?2:3)+h),y=0;return p[y++]=48,f?p[y++]=h:(p[y++]=129,p[y++]=255&h),p[y++]=2,p[y++]=u,a<0?(p[y++]=0,y+=e.copy(p,y,0,n)):y+=e.copy(p,y,a,n),p[y++]=2,p[y++]=d,l<0?(p[y++]=0,e.copy(p,y,n)):e.copy(p,y,n+l),p}}},2111:(e,t,n)=>{const r=n(4641),o=n(3999),i=n(5580),c=n(4089),s=n(7059),a=n(5200);e.exports=(e,t,n,l)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e===n;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e!==n;case"":case"=":case"==":return r(e,n,l);case"!=":return o(e,n,l);case">":return i(e,n,l);case">=":return c(e,n,l);case"<":return s(e,n,l);case"<=":return a(e,n,l);default:throw new TypeError(`Invalid operator: ${t}`)}}},2203:t=>{t.exports=e(import.meta.url)("stream")},2525:(e,t,n)=>{const r=n(7638),o=n(560);e.exports=(e,t,n)=>{const i=[];let c=null,s=null;const a=e.sort(((e,t)=>o(e,t,n)));for(const e of a)r(e,t,n)?(s=e,c||(c=e)):(s&&i.push([c,s]),s=null,c=null);c&&i.push([c,null]);const l=[];for(const[e,t]of i)e===t?l.push(e):t||e!==a[0]?t?e===a[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`):l.push("*");const u=l.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return u.length<d.length?u:t}},2851:(e,t,n)=>{var r=n(181).Buffer;e.exports=function(e){return"string"==typeof e?e:"number"==typeof e||r.isBuffer(e)?e.toString():JSON.stringify(e)}},2861:(e,t,n)=>{var r=n(181),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function c(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=c),c.prototype=Object.create(o.prototype),i(o,c),c.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},c.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},c.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},c.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},2938:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).major},3007:(e,t,n)=>{const r=n(3908);e.exports=(e,t,n,o,i)=>{"string"==typeof n&&(i=o,o=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,o,i).version}catch(e){return null}}},3387:(e,t,n)=>{var r=n(2861).Buffer,o=n(8948),i=n(8789),c=n(2203),s=n(2851),a=n(9023);function l(e,t){return r.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function u(e){var t=e.header,n=e.payload,r=e.secret||e.privateKey,o=e.encoding,c=i(t.alg),u=function(e,t,n){n=n||"utf8";var r=l(s(e),"binary"),o=l(s(t),n);return a.format("%s.%s",r,o)}(t,n,o),d=c.sign(u,r);return a.format("%s.%s",u,d)}function d(e){var t=e.secret||e.privateKey||e.key,n=new o(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new o(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}a.inherits(d,c),d.prototype.sign=function(){try{var e=u({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},d.sign=u,e.exports=d},3527:e=>{function t(e){return(e/8|0)+(e%8==0?0:1)}var n={ES256:t(256),ES384:t(384),ES512:t(521)};e.exports=function(e){var t=n[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},3639:e=>{var t=Object.prototype.toString;e.exports=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==t.call(e)}},3726:(e,t,n)=>{var r=n(1741),o=function(e,t){r.call(this,e),this.name="NotBeforeError",this.date=t};(o.prototype=Object.create(r.prototype)).constructor=o,e.exports=o},3874:(e,t,n)=>{const r=n(8311);e.exports=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}}},3904:(e,t,n)=>{const r=Symbol("SemVer ANY");class o{static get ANY(){return r}constructor(e,t){if(t=i(t),e instanceof o){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),l("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===r?this.value="":this.value=this.operator+this.semver.version,l("comp",this)}parse(e){const t=this.options.loose?c[s.COMPARATORLOOSE]:c[s.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==n[1]?n[1]:"","="===this.operator&&(this.operator=""),n[2]?this.semver=new u(n[2],this.options.loose):this.semver=r}toString(){return this.value}test(e){if(l("Comparator.test",e,this.options.loose),this.semver===r||e===r)return!0;if("string"==typeof e)try{e=new u(e,this.options)}catch(e){return!1}return a(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof o))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new d(e.value,t).test(this.value):""===e.operator?""===e.value||new d(this.value,t).test(e.semver):!((t=i(t)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===e.value)||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))||(!this.operator.startsWith(">")||!e.operator.startsWith(">"))&&(!this.operator.startsWith("<")||!e.operator.startsWith("<"))&&(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))&&!(a(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))&&!(a(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}}e.exports=o;const i=n(8587),{safeRe:c,t:s}=n(9718),a=n(2111),l=n(7272),u=n(3908),d=n(8311)},3908:(e,t,n)=>{const r=n(7272),{MAX_LENGTH:o,MAX_SAFE_INTEGER:i}=n(6874),{safeRe:c,safeSrc:s,t:a}=n(9718),l=n(8587),{compareIdentifiers:u}=n(1123);class d{constructor(e,t){if(t=l(t),e instanceof d){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>o)throw new TypeError(`version is longer than ${o} characters`);r("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?c[a.LOOSE]:c[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(r("SemVer.compare",this.version,this.options,e),!(e instanceof d)){if("string"==typeof e&&e===this.version)return 0;e=new d(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof d||(e=new d(e,this.options)),u(this.major,e.major)||u(this.minor,e.minor)||u(this.patch,e.patch)}comparePre(e){if(e instanceof d||(e=new d(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],o=e.prerelease[t];if(r("prerelease compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}compareBuild(e){e instanceof d||(e=new d(e,this.options));let t=0;do{const n=this.build[t],o=e.build[t];if(r("build compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=new RegExp(`^${this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]}$`),n=`-${t}`.match(e);if(!n||n[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];!1===n&&(r=[t]),0===u(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=d},3927:(e,t,n)=>{const r=n(909);e.exports=(e,t)=>e.sort(((e,n)=>r(e,n,t)))},3999:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>0!==r(e,t,n)},4040:(e,t,n)=>{e.exports={decode:n(7260),verify:n(1691),sign:n(7651),JsonWebTokenError:n(1741),NotBeforeError:n(3726),TokenExpiredError:n(8980)}},4089:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)>=0},4277:(e,t,n)=>{const r=n(909);e.exports=(e,t)=>e.sort(((e,n)=>r(n,e,t)))},4493:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).patch},4623:(e,t,n)=>{const r=n(9589);e.exports=r.satisfies(process.version,">=16.9.0")},4641:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>0===r(e,t,n)},4977:(e,t,n)=>{var r=n(9589);e.exports=r.satisfies(process.version,"^6.12.0 || >=8.0.0")},5032:(e,t,n)=>{const r=n(8311),o=n(3904),{ANY:i}=o,c=n(7638),s=n(560),a=[new o(">=0.0.0-0")],l=[new o(">=0.0.0")],u=(e,t,n)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===i){if(1===t.length&&t[0].semver===i)return!0;e=n.includePrerelease?a:l}if(1===t.length&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}const r=new Set;let o,u,f,p,y,v,g;for(const t of e)">"===t.operator||">="===t.operator?o=d(o,t,n):"<"===t.operator||"<="===t.operator?u=h(u,t,n):r.add(t.semver);if(r.size>1)return null;if(o&&u){if(f=s(o.semver,u.semver,n),f>0)return null;if(0===f&&(">="!==o.operator||"<="!==u.operator))return null}for(const e of r){if(o&&!c(e,String(o),n))return null;if(u&&!c(e,String(u),n))return null;for(const r of t)if(!c(e,String(r),n))return!1;return!0}let m=!(!u||n.includePrerelease||!u.semver.prerelease.length)&&u.semver,C=!(!o||n.includePrerelease||!o.semver.prerelease.length)&&o.semver;m&&1===m.prerelease.length&&"<"===u.operator&&0===m.prerelease[0]&&(m=!1);for(const e of t){if(g=g||">"===e.operator||">="===e.operator,v=v||"<"===e.operator||"<="===e.operator,o)if(C&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===C.major&&e.semver.minor===C.minor&&e.semver.patch===C.patch&&(C=!1),">"===e.operator||">="===e.operator){if(p=d(o,e,n),p===e&&p!==o)return!1}else if(">="===o.operator&&!c(o.semver,String(e),n))return!1;if(u)if(m&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===m.major&&e.semver.minor===m.minor&&e.semver.patch===m.patch&&(m=!1),"<"===e.operator||"<="===e.operator){if(y=h(u,e,n),y===e&&y!==u)return!1}else if("<="===u.operator&&!c(u.semver,String(e),n))return!1;if(!e.operator&&(u||o)&&0!==f)return!1}return!(o&&v&&!u&&0!==f||u&&g&&!o&&0!==f||C||m)},d=(e,t,n)=>{if(!e)return t;const r=s(e.semver,t.semver,n);return r>0?e:r<0||">"===t.operator&&">="===e.operator?t:e},h=(e,t,n)=>{if(!e)return t;const r=s(e.semver,t.semver,n);return r<0?e:r>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,n={})=>{if(e===t)return!0;e=new r(e,n),t=new r(t,n);let o=!1;e:for(const r of e.set){for(const e of t.set){const t=u(r,e,n);if(o=o||null!==t,t)continue e}if(o)return!1}return!0}},5200:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)<=0},5342:(e,t,n)=>{const r=n(7075);e.exports=(e,t,n)=>r(e,t,"<",n)},5571:(e,t,n)=>{const r=n(7075);e.exports=(e,t,n)=>r(e,t,">",n)},5580:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)>0},5747:(e,t,n)=>{var r=n(3387),o=n(7599);t.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],t.sign=r.sign,t.verify=o.verify,t.decode=o.decode,t.isValid=o.isValid,t.createSign=function(e){return new r(e)},t.createVerify=function(e){return new o(e)}},5931:e=>{var t=Object.prototype.toString,n=Array.isArray;e.exports=function(e){return"string"==typeof e||!n(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==t.call(e)}},6111:e=>{var t=1/0,n=9007199254740991,r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,c=/^0o[0-7]+$/i,s=/^(?:0|[1-9]\d*)$/,a=parseInt;function l(e){return e!=e}var u,d,h=Object.prototype,f=h.hasOwnProperty,p=h.toString,y=h.propertyIsEnumerable,v=(u=Object.keys,d=Object,function(e){return u(d(e))}),g=Math.max;function m(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||s.test(e))&&e>-1&&e%1==0&&e<t}var C=Array.isArray;function w(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=T(e)?p.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)}function T(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function I(e){return!!e&&"object"==typeof e}e.exports=function(e,n,s,u){var d;e=w(e)?e:(d=e)?function(e,t){return function(t){for(var n=-1,r=t?t.length:0,o=Array(r);++n<r;)o[n]=(i=t[n],e[i]);var i;return o}(t)}(d,function(e){return w(e)?function(e,t){var n=C(e)||function(e){return function(e){return I(e)&&w(e)}(e)&&f.call(e,"callee")&&(!y.call(e,"callee")||"[object Arguments]"==p.call(e))}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var i in e)!t&&!f.call(e,i)||o&&("length"==i||m(i,r))||n.push(i);return n}(e):function(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||h))return v(e);var t,n,r=[];for(var o in Object(e))f.call(e,o)&&"constructor"!=o&&r.push(o);return r}(e)}(d)):[],s=s&&!u?function(e){var n=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||I(e)&&"[object Symbol]"==p.call(e)}(e))return NaN;if(T(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=T(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var n=i.test(e);return n||c.test(e)?a(e.slice(2),n?2:8):o.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),s=n%1;return n==n?s?n-s:n:0}(s):0;var N=e.length;return s<0&&(s=g(N+s,0)),function(e){return"string"==typeof e||!C(e)&&I(e)&&"[object String]"==p.call(e)}(e)?s<=N&&e.indexOf(n,s)>-1:!!N&&function(e,t,n){if(t!=t)return function(e,t,n){for(var r=e.length,o=n+-1;++o<r;)if(t(e[o],o,e))return o;return-1}(e,l,n);for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}(e,n,s)>-1}},6170:(e,t,n)=>{const r=n(3908),o=n(144),{safeRe:i,t:c}=n(9718);e.exports=(e,t)=>{if(e instanceof r)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){const r=t.includePrerelease?i[c.COERCERTLFULL]:i[c.COERCERTL];let o;for(;(o=r.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&o.index+o[0].length===n.index+n[0].length||(n=o),r.lastIndex=o.index+o[1].length+o[2].length;r.lastIndex=-1}else n=e.match(t.includePrerelease?i[c.COERCEFULL]:i[c.COERCE]);if(null===n)return null;const s=n[2],a=n[3]||"0",l=n[4]||"0",u=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return o(`${s}.${a}.${l}${u}${d}`,t)}},6254:(e,t,n)=>{const r=n(3908);e.exports=(e,t)=>new r(e,t).minor},6585:e=>{var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o;function c(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,s){s=s||{};var a,l,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var c=/^(-?(?:\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(c){var s=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return s*i;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*r;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;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"===u&&isFinite(e))return s.long?(a=e,(l=Math.abs(a))>=o?c(a,l,o,"day"):l>=r?c(a,l,r,"hour"):l>=n?c(a,l,n,"minute"):l>=t?c(a,l,t,"second"):a+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=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))}},6780:(e,t,n)=>{const r=n(8311);e.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))},6874:e=>{const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},6953:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e,t);return n?n.version:null}},6982:t=>{t.exports=e(import.meta.url)("crypto")},7019:(e,t,n)=>{const r=n(1977),o=n(4623),i={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},c={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};e.exports=function(e,t){if(!e||!t)return;const n=t.asymmetricKeyType;if(!n)return;const s=i[n];if(!s)throw new Error(`Unknown key type "${n}".`);if(!s.includes(e))throw new Error(`"alg" parameter for "${n}" key type must be one of: ${s.join(", ")}.`);if(r)switch(n){case"ec":const n=t.asymmetricKeyDetails.namedCurve,r=c[e];if(n!==r)throw new Error(`"alg" parameter "${e}" requires curve "${r}".`);break;case"rsa-pss":if(o){const n=parseInt(e.slice(-3),10),{hashAlgorithm:r,mgf1HashAlgorithm:o,saltLength:i}=t.asymmetricKeyDetails;if(r!==`sha${n}`||o!==r)throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${e}.`);if(void 0!==i&&i>n>>3)throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${e}.`)}}}},7059:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(e,t,n)<0},7075:(e,t,n)=>{const r=n(3908),o=n(3904),{ANY:i}=o,c=n(8311),s=n(7638),a=n(5580),l=n(7059),u=n(5200),d=n(4089);e.exports=(e,t,n,h)=>{let f,p,y,v,g;switch(e=new r(e,h),t=new c(t,h),n){case">":f=a,p=u,y=l,v=">",g=">=";break;case"<":f=l,p=d,y=a,v="<",g="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(s(e,t,h))return!1;for(let n=0;n<t.set.length;++n){const r=t.set[n];let c=null,s=null;if(r.forEach((e=>{e.semver===i&&(e=new o(">=0.0.0")),c=c||e,s=s||e,f(e.semver,c.semver,h)?c=e:y(e.semver,s.semver,h)&&(s=e)})),c.operator===v||c.operator===g)return!1;if((!s.operator||s.operator===v)&&p(e,s.semver))return!1;if(s.operator===g&&y(e,s.semver))return!1}return!0}},7083:e=>{var t=1/0,n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt,s=Object.prototype.toString;function a(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return function(e,l){var u;if("function"!=typeof l)throw new TypeError("Expected a function");return e=function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return NaN;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=o.test(e);return l||i.test(e)?c(e.slice(2),l?2:8):r.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),u=l%1;return l==l?u?l-u:l:0}(e),function(){return--e>0&&(u=l.apply(this,arguments)),e<=1&&(l=void 0),u}}(2,e)}},7260:(e,t,n)=>{var r=n(5747);e.exports=function(e,t){t=t||{};var n=r.decode(e,t);if(!n)return null;var o=n.payload;if("string"==typeof o)try{var i=JSON.parse(o);null!==i&&"object"==typeof i&&(o=i)}catch(e){}return!0===t.complete?{header:n.header,payload:o,signature:n.signature}:o}},7272:e=>{const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},7414:(e,t,n)=>{const r=n(144);e.exports=(e,t)=>{const n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},7599:(e,t,n)=>{var r=n(2861).Buffer,o=n(8948),i=n(8789),c=n(2203),s=n(2851),a=n(9023),l=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function u(e){var t=e.split(".",1)[0];return function(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}(r.from(t,"base64").toString("binary"))}function d(e){return e.split(".")[2]}function h(e){return l.test(e)&&!!u(e)}function f(e,t,n){if(!t){var r=new Error("Missing algorithm parameter for jws.verify");throw r.code="MISSING_ALGORITHM",r}var o=d(e=s(e)),c=function(e){return e.split(".",2).join(".")}(e);return i(t).verify(c,o,n)}function p(e,t){if(t=t||{},!h(e=s(e)))return null;var n=u(e);if(!n)return null;var o=function(e,t){t=t||"utf8";var n=e.split(".")[1];return r.from(n,"base64").toString(t)}(e);return("JWT"===n.typ||t.json)&&(o=JSON.parse(o,t.encoding)),{header:n,payload:o,signature:d(e)}}function y(e){var t=(e=e||{}).secret||e.publicKey||e.key,n=new o(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new o(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}a.inherits(y,c),y.prototype.verify=function(){try{var e=f(this.signature.buffer,this.algorithm,this.key.buffer),t=p(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},y.decode=p,y.isValid=h,y.verify=f,e.exports=y},7631:(e,t,n)=>{const r=n(8311);e.exports=(e,t)=>new r(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},7638:(e,t,n)=>{const r=n(8311);e.exports=(e,t,n)=>{try{t=new r(t,n)}catch(e){return!1}return t.test(e)}},7651:(e,t,n)=>{const r=n(855),o=n(4977),i=n(7019),c=n(5747),s=n(6111),a=n(7914),l=n(8928),u=n(3639),d=n(9001),h=n(5931),f=n(7083),{KeyObject:p,createSecretKey:y,createPrivateKey:v}=n(6982),g=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];o&&g.splice(3,0,"PS256","PS384","PS512");const m={expiresIn:{isValid:function(e){return l(e)||h(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return l(e)||h(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return h(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:s.bind(null,g),message:'"algorithm" must be a valid string enum value'},header:{isValid:d,message:'"header" must be an object'},encoding:{isValid:h,message:'"encoding" must be a string'},issuer:{isValid:h,message:'"issuer" must be a string'},subject:{isValid:h,message:'"subject" must be a string'},jwtid:{isValid:h,message:'"jwtid" must be a string'},noTimestamp:{isValid:a,message:'"noTimestamp" must be a boolean'},keyid:{isValid:h,message:'"keyid" must be a string'},mutatePayload:{isValid:a,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:a,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:a,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},C={iat:{isValid:u,message:'"iat" should be a number of seconds'},exp:{isValid:u,message:'"exp" should be a number of seconds'},nbf:{isValid:u,message:'"nbf" should be a number of seconds'}};function w(e,t,n,r){if(!d(n))throw new Error('Expected "'+r+'" to be a plain object.');Object.keys(n).forEach((function(o){const i=e[o];if(i){if(!i.isValid(n[o]))throw new Error(i.message)}else if(!t)throw new Error('"'+o+'" is not allowed in "'+r+'"')}))}const T={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},I=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];e.exports=function(e,t,n,o){"function"==typeof n?(o=n,n={}):n=n||{};const s="object"==typeof e&&!Buffer.isBuffer(e),a=Object.assign({alg:n.algorithm||"HS256",typ:s?"JWT":void 0,kid:n.keyid},n.header);function l(e){if(o)return o(e);throw e}if(!t&&"none"!==n.algorithm)return l(new Error("secretOrPrivateKey must have a value"));if(null!=t&&!(t instanceof p))try{t=v(t)}catch(e){try{t=y("string"==typeof t?Buffer.from(t):t)}catch(e){return l(new Error("secretOrPrivateKey is not valid key material"))}}if(a.alg.startsWith("HS")&&"secret"!==t.type)return l(new Error(`secretOrPrivateKey must be a symmetric key when using ${a.alg}`));if(/^(?:RS|PS|ES)/.test(a.alg)){if("private"!==t.type)return l(new Error(`secretOrPrivateKey must be an asymmetric key when using ${a.alg}`));if(!n.allowInsecureKeySizes&&!a.alg.startsWith("ES")&&void 0!==t.asymmetricKeyDetails&&t.asymmetricKeyDetails.modulusLength<2048)return l(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`))}if(void 0===e)return l(new Error("payload is required"));if(s){try{!function(e){w(C,!0,e,"payload")}(e)}catch(e){return l(e)}n.mutatePayload||(e=Object.assign({},e))}else{const t=I.filter((function(e){return void 0!==n[e]}));if(t.length>0)return l(new Error("invalid "+t.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==n.expiresIn)return l(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==n.notBefore)return l(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){w(m,!1,e,"options")}(n)}catch(e){return l(e)}if(!n.allowInvalidAsymmetricKeyTypes)try{i(a.alg,t)}catch(e){return l(e)}const u=e.iat||Math.floor(Date.now()/1e3);if(n.noTimestamp?delete e.iat:s&&(e.iat=u),void 0!==n.notBefore){try{e.nbf=r(n.notBefore,u)}catch(e){return l(e)}if(void 0===e.nbf)return l(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==n.expiresIn&&"object"==typeof e){try{e.exp=r(n.expiresIn,u)}catch(e){return l(e)}if(void 0===e.exp)return l(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(T).forEach((function(t){const r=T[t];if(void 0!==n[t]){if(void 0!==e[r])return l(new Error('Bad "options.'+t+'" option. The payload already has an "'+r+'" property.'));e[r]=n[t]}}));const d=n.encoding||"utf8";if("function"!=typeof o){let r=c.sign({header:a,payload:e,secret:t,encoding:d});if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(a.alg)&&r.length<256)throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`);return r}o=o&&f(o),c.createSign({header:a,privateKey:t,payload:e,encoding:d}).once("error",o).once("done",(function(e){if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(a.alg)&&e.length<256)return o(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${a.alg}`));o(null,e)}))}},7914:e=>{var t=Object.prototype.toString;e.exports=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==t.call(e)}},8311:(e,t,n)=>{const r=/\s+/g;class o{constructor(e,t){if(t=c(t),e instanceof o)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new o(e.raw,t);if(e instanceof s)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(r," "),this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!g(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&y)|(this.options.loose&&v))+":"+e,n=i.get(t);if(n)return n;const r=this.options.loose,o=r?u[d.HYPHENRANGELOOSE]:u[d.HYPHENRANGE];e=e.replace(o,b(this.options.includePrerelease)),a("hyphen replace",e),e=e.replace(u[d.COMPARATORTRIM],h),a("comparator trim",e),e=e.replace(u[d.TILDETRIM],f),a("tilde trim",e),e=e.replace(u[d.CARETTRIM],p),a("caret trim",e);let c=e.split(" ").map((e=>w(e,this.options))).join(" ").split(/\s+/).map((e=>x(e,this.options)));r&&(c=c.filter((e=>(a("loose invalid filter",e,this.options),!!e.match(u[d.COMPARATORLOOSE]))))),a("range list",c);const l=new Map,m=c.map((e=>new s(e,this.options)));for(const e of m){if(g(e))return[e];l.set(e.value,e)}l.size>1&&l.has("")&&l.delete("");const C=[...l.values()];return i.set(t,C),C}intersects(e,t){if(!(e instanceof o))throw new TypeError("a Range is required");return this.set.some((n=>C(n,t)&&e.set.some((e=>C(e,t)&&n.every((n=>e.every((e=>n.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new l(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if($(this.set[t],e,this.options))return!0;return!1}}e.exports=o;const i=new(n(8794)),c=n(8587),s=n(3904),a=n(7272),l=n(3908),{safeRe:u,t:d,comparatorTrimReplace:h,tildeTrimReplace:f,caretTrimReplace:p}=n(9718),{FLAG_INCLUDE_PRERELEASE:y,FLAG_LOOSE:v}=n(6874),g=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,C=(e,t)=>{let n=!0;const r=e.slice();let o=r.pop();for(;n&&r.length;)n=r.every((e=>o.intersects(e,t))),o=r.pop();return n},w=(e,t)=>(a("comp",e,t),e=A(e,t),a("caret",e),e=I(e,t),a("tildes",e),e=S(e,t),a("xrange",e),e=k(e,t),a("stars",e),e),T=e=>!e||"x"===e.toLowerCase()||"*"===e,I=(e,t)=>e.trim().split(/\s+/).map((e=>N(e,t))).join(" "),N=(e,t)=>{const n=t.loose?u[d.TILDELOOSE]:u[d.TILDE];return e.replace(n,((t,n,r,o,i)=>{let c;return a("tilde",e,t,n,r,o,i),T(n)?c="":T(r)?c=`>=${n}.0.0 <${+n+1}.0.0-0`:T(o)?c=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:i?(a("replaceTilde pr",i),c=`>=${n}.${r}.${o}-${i} <${n}.${+r+1}.0-0`):c=`>=${n}.${r}.${o} <${n}.${+r+1}.0-0`,a("tilde return",c),c}))},A=(e,t)=>e.trim().split(/\s+/).map((e=>E(e,t))).join(" "),E=(e,t)=>{a("caret",e,t);const n=t.loose?u[d.CARETLOOSE]:u[d.CARET],r=t.includePrerelease?"-0":"";return e.replace(n,((t,n,o,i,c)=>{let s;return a("caret",e,t,n,o,i,c),T(n)?s="":T(o)?s=`>=${n}.0.0${r} <${+n+1}.0.0-0`:T(i)?s="0"===n?`>=${n}.${o}.0${r} <${n}.${+o+1}.0-0`:`>=${n}.${o}.0${r} <${+n+1}.0.0-0`:c?(a("replaceCaret pr",c),s="0"===n?"0"===o?`>=${n}.${o}.${i}-${c} <${n}.${o}.${+i+1}-0`:`>=${n}.${o}.${i}-${c} <${n}.${+o+1}.0-0`:`>=${n}.${o}.${i}-${c} <${+n+1}.0.0-0`):(a("no pr"),s="0"===n?"0"===o?`>=${n}.${o}.${i}${r} <${n}.${o}.${+i+1}-0`:`>=${n}.${o}.${i}${r} <${n}.${+o+1}.0-0`:`>=${n}.${o}.${i} <${+n+1}.0.0-0`),a("caret return",s),s}))},S=(e,t)=>(a("replaceXRanges",e,t),e.split(/\s+/).map((e=>R(e,t))).join(" ")),R=(e,t)=>{e=e.trim();const n=t.loose?u[d.XRANGELOOSE]:u[d.XRANGE];return e.replace(n,((n,r,o,i,c,s)=>{a("xRange",e,n,r,o,i,c,s);const l=T(o),u=l||T(i),d=u||T(c),h=d;return"="===r&&h&&(r=""),s=t.includePrerelease?"-0":"",l?n=">"===r||"<"===r?"<0.0.0-0":"*":r&&h?(u&&(i=0),c=0,">"===r?(r=">=",u?(o=+o+1,i=0,c=0):(i=+i+1,c=0)):"<="===r&&(r="<",u?o=+o+1:i=+i+1),"<"===r&&(s="-0"),n=`${r+o}.${i}.${c}${s}`):u?n=`>=${o}.0.0${s} <${+o+1}.0.0-0`:d&&(n=`>=${o}.${i}.0${s} <${o}.${+i+1}.0-0`),a("xRange return",n),n}))},k=(e,t)=>(a("replaceStars",e,t),e.trim().replace(u[d.STAR],"")),x=(e,t)=>(a("replaceGTE0",e,t),e.trim().replace(u[t.includePrerelease?d.GTE0PRE:d.GTE0],"")),b=e=>(t,n,r,o,i,c,s,a,l,u,d,h)=>`${n=T(r)?"":T(o)?`>=${r}.0.0${e?"-0":""}`:T(i)?`>=${r}.${o}.0${e?"-0":""}`:c?`>=${n}`:`>=${n}${e?"-0":""}`} ${a=T(l)?"":T(u)?`<${+l+1}.0.0-0`:T(d)?`<${l}.${+u+1}.0-0`:h?`<=${l}.${u}.${d}-${h}`:e?`<${l}.${u}.${+d+1}-0`:`<=${a}`}`.trim(),$=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(a(e[n].semver),e[n].semver!==s.ANY&&e[n].semver.prerelease.length>0){const r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}},8587:e=>{const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},8789:(e,t,n)=>{var r=n(1045),o=n(2861).Buffer,i=n(6982),c=n(2010),s=n(9023),a="secret must be a string or buffer",l="key must be a string or a buffer",u="function"==typeof i.createPublicKey;function d(e){if(!o.isBuffer(e)&&"string"!=typeof e){if(!u)throw y(l);if("object"!=typeof e)throw y(l);if("string"!=typeof e.type)throw y(l);if("string"!=typeof e.asymmetricKeyType)throw y(l);if("function"!=typeof e.export)throw y(l)}}function h(e){if(!o.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw y("key must be a string, a buffer or an object")}function f(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function p(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var n=0;n<t;++n)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function y(e){var t=[].slice.call(arguments,1),n=s.format.bind(s,e).apply(null,t);return new TypeError(n)}function v(e){var t;return t=e,o.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function g(e){return function(t,n){!function(e){if(!o.isBuffer(e)){if("string"==typeof e)return e;if(!u)throw y(a);if("object"!=typeof e)throw y(a);if("secret"!==e.type)throw y(a);if("function"!=typeof e.export)throw y(a)}}(n),t=v(t);var r=i.createHmac("sha"+e,n);return f((r.update(t),r.digest("base64")))}}function m(e){return function(t,n,i){var c=g(e)(t,i);return r(o.from(n),o.from(c))}}function C(e){return function(t,n){h(n),t=v(t);var r=i.createSign("RSA-SHA"+e);return f((r.update(t),r.sign(n,"base64")))}}function w(e){return function(t,n,r){d(r),t=v(t),n=p(n);var o=i.createVerify("RSA-SHA"+e);return o.update(t),o.verify(r,n,"base64")}}function T(e){return function(t,n){h(n),t=v(t);var r=i.createSign("RSA-SHA"+e);return f((r.update(t),r.sign({key:n,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function I(e){return function(t,n,r){d(r),t=v(t),n=p(n);var o=i.createVerify("RSA-SHA"+e);return o.update(t),o.verify({key:r,padding:i.constants.RSA_PKCS1_PSS_PADDING,saltLength:i.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function N(e){var t=C(e);return function(){var n=t.apply(null,arguments);return c.derToJose(n,"ES"+e)}}function A(e){var t=w(e);return function(n,r,o){return r=c.joseToDer(r,"ES"+e).toString("base64"),t(n,r,o)}}function E(){return function(){return""}}function S(){return function(e,t){return""===t}}u&&(l+=" or a KeyObject",a+="or a KeyObject"),e.exports=function(e){var t={hs:g,rs:C,ps:T,es:N,none:E},n={hs:m,rs:w,ps:I,es:A,none:S},r=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);if(!r)throw y('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',e);var o=(r[1]||r[3]).toLowerCase(),i=r[2];return{sign:t[o](i),verify:n[o](i)}}},8794:e=>{e.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}},8928:e=>{var t=1/0,n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt,s=Object.prototype.toString;function a(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return"number"==typeof e&&e==function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return NaN;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=o.test(e);return l||i.test(e)?c(e.slice(2),l?2:8):r.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),u=l%1;return l==l?u?l-u:l:0}(e)}},8948:(e,t,n)=>{var r=n(2861).Buffer,o=n(2203);function i(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=r.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=r.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}n(9023).inherits(i,o),i.prototype.write=function(e){this.buffer=r.concat([this.buffer,r.from(e)]),this.emit("data",e)},i.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},e.exports=i},8980:(e,t,n)=>{var r=n(1741),o=function(e,t){r.call(this,e),this.name="TokenExpiredError",this.expiredAt=t};(o.prototype=Object.create(r.prototype)).constructor=o,e.exports=o},9001:e=>{var t,n,r=Function.prototype,o=Object.prototype,i=r.toString,c=o.hasOwnProperty,s=i.call(Object),a=o.toString,l=(t=Object.getPrototypeOf,n=Object,function(e){return t(n(e))});e.exports=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=a.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=l(e);if(null===t)return!0;var n=c.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&i.call(n)==s}},9023:t=>{t.exports=e(import.meta.url)("util")},9589:(e,t,n)=>{const r=n(9718),o=n(6874),i=n(3908),c=n(1123),s=n(144),a=n(6953),l=n(7414),u=n(3007),d=n(1832),h=n(2938),f=n(6254),p=n(4493),y=n(1729),v=n(560),g=n(9970),m=n(1763),C=n(909),w=n(3927),T=n(4277),I=n(5580),N=n(7059),A=n(4641),E=n(3999),S=n(4089),R=n(5200),k=n(2111),x=n(6170),b=n(3904),$=n(8311),L=n(7638),_=n(7631),P=n(9628),O=n(270),U=n(1261),B=n(3874),D=n(7075),F=n(5571),G=n(5342),j=n(6780),V=n(2525),M=n(5032);e.exports={parse:s,valid:a,clean:l,inc:u,diff:d,major:h,minor:f,patch:p,prerelease:y,compare:v,rcompare:g,compareLoose:m,compareBuild:C,sort:w,rsort:T,gt:I,lt:N,eq:A,neq:E,gte:S,lte:R,cmp:k,coerce:x,Comparator:b,Range:$,satisfies:L,toComparators:_,maxSatisfying:P,minSatisfying:O,minVersion:U,validRange:B,outside:D,gtr:F,ltr:G,intersects:j,simplifyRange:V,subset:M,SemVer:i,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:o.SEMVER_SPEC_VERSION,RELEASE_TYPES:o.RELEASE_TYPES,compareIdentifiers:c.compareIdentifiers,rcompareIdentifiers:c.rcompareIdentifiers}},9628:(e,t,n)=>{const r=n(3908),o=n(8311);e.exports=(e,t,n)=>{let i=null,c=null,s=null;try{s=new o(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(i&&-1!==c.compare(e)||(i=e,c=new r(i,n)))})),i}},9718:(e,t,n)=>{const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:i}=n(6874),c=n(7272),s=(t=e.exports={}).re=[],a=t.safeRe=[],l=t.src=[],u=t.safeSrc=[],d=t.t={};let h=0;const f="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[f,o]],y=(e,t,n)=>{const r=(e=>{for(const[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=h++;c(e,o,t),d[e]=o,l[o]=t,u[o]=r,s[o]=new RegExp(t,n?"g":void 0),a[o]=new RegExp(r,n?"g":void 0)};y("NUMERICIDENTIFIER","0|[1-9]\\d*"),y("NUMERICIDENTIFIERLOOSE","\\d+"),y("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),y("MAINVERSION",`(${l[d.NUMERICIDENTIFIER]})\\.(${l[d.NUMERICIDENTIFIER]})\\.(${l[d.NUMERICIDENTIFIER]})`),y("MAINVERSIONLOOSE",`(${l[d.NUMERICIDENTIFIERLOOSE]})\\.(${l[d.NUMERICIDENTIFIERLOOSE]})\\.(${l[d.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASEIDENTIFIER",`(?:${l[d.NUMERICIDENTIFIER]}|${l[d.NONNUMERICIDENTIFIER]})`),y("PRERELEASEIDENTIFIERLOOSE",`(?:${l[d.NUMERICIDENTIFIERLOOSE]}|${l[d.NONNUMERICIDENTIFIER]})`),y("PRERELEASE",`(?:-(${l[d.PRERELEASEIDENTIFIER]}(?:\\.${l[d.PRERELEASEIDENTIFIER]})*))`),y("PRERELEASELOOSE",`(?:-?(${l[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[d.PRERELEASEIDENTIFIERLOOSE]})*))`),y("BUILDIDENTIFIER",`${f}+`),y("BUILD",`(?:\\+(${l[d.BUILDIDENTIFIER]}(?:\\.${l[d.BUILDIDENTIFIER]})*))`),y("FULLPLAIN",`v?${l[d.MAINVERSION]}${l[d.PRERELEASE]}?${l[d.BUILD]}?`),y("FULL",`^${l[d.FULLPLAIN]}$`),y("LOOSEPLAIN",`[v=\\s]*${l[d.MAINVERSIONLOOSE]}${l[d.PRERELEASELOOSE]}?${l[d.BUILD]}?`),y("LOOSE",`^${l[d.LOOSEPLAIN]}$`),y("GTLT","((?:<|>)?=?)"),y("XRANGEIDENTIFIERLOOSE",`${l[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),y("XRANGEIDENTIFIER",`${l[d.NUMERICIDENTIFIER]}|x|X|\\*`),y("XRANGEPLAIN",`[v=\\s]*(${l[d.XRANGEIDENTIFIER]})(?:\\.(${l[d.XRANGEIDENTIFIER]})(?:\\.(${l[d.XRANGEIDENTIFIER]})(?:${l[d.PRERELEASE]})?${l[d.BUILD]}?)?)?`),y("XRANGEPLAINLOOSE",`[v=\\s]*(${l[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[d.XRANGEIDENTIFIERLOOSE]})(?:${l[d.PRERELEASELOOSE]})?${l[d.BUILD]}?)?)?`),y("XRANGE",`^${l[d.GTLT]}\\s*${l[d.XRANGEPLAIN]}$`),y("XRANGELOOSE",`^${l[d.GTLT]}\\s*${l[d.XRANGEPLAINLOOSE]}$`),y("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),y("COERCE",`${l[d.COERCEPLAIN]}(?:$|[^\\d])`),y("COERCEFULL",l[d.COERCEPLAIN]+`(?:${l[d.PRERELEASE]})?`+`(?:${l[d.BUILD]})?(?:$|[^\\d])`),y("COERCERTL",l[d.COERCE],!0),y("COERCERTLFULL",l[d.COERCEFULL],!0),y("LONETILDE","(?:~>?)"),y("TILDETRIM",`(\\s*)${l[d.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",y("TILDE",`^${l[d.LONETILDE]}${l[d.XRANGEPLAIN]}$`),y("TILDELOOSE",`^${l[d.LONETILDE]}${l[d.XRANGEPLAINLOOSE]}$`),y("LONECARET","(?:\\^)"),y("CARETTRIM",`(\\s*)${l[d.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",y("CARET",`^${l[d.LONECARET]}${l[d.XRANGEPLAIN]}$`),y("CARETLOOSE",`^${l[d.LONECARET]}${l[d.XRANGEPLAINLOOSE]}$`),y("COMPARATORLOOSE",`^${l[d.GTLT]}\\s*(${l[d.LOOSEPLAIN]})$|^$`),y("COMPARATOR",`^${l[d.GTLT]}\\s*(${l[d.FULLPLAIN]})$|^$`),y("COMPARATORTRIM",`(\\s*)${l[d.GTLT]}\\s*(${l[d.LOOSEPLAIN]}|${l[d.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",y("HYPHENRANGE",`^\\s*(${l[d.XRANGEPLAIN]})\\s+-\\s+(${l[d.XRANGEPLAIN]})\\s*$`),y("HYPHENRANGELOOSE",`^\\s*(${l[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[d.XRANGEPLAINLOOSE]})\\s*$`),y("STAR","(<|>)?=?\\s*\\*"),y("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),y("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},9970:(e,t,n)=>{const r=n(560);e.exports=(e,t,n)=>r(t,e,n)}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};r.d(o,{BG:()=>oi,$e:()=>Yo,TR:()=>ro,Tc:()=>oo,U3:()=>s,Wg:()=>V,g2:()=>So,BO:()=>Ir,WW:()=>mr,BS:()=>vr,ji:()=>M,Ij:()=>z,Ng:()=>se,du:()=>pe,RC:()=>Gt,d4:()=>xt,Cd:()=>dn,IM:()=>fn,oI:()=>H,u9:()=>Tn,B7:()=>Vr,mF:()=>Hr,Q9:()=>Ar,wT:()=>kt,hZ:()=>vn,y0:()=>ei,iw:()=>ni,pU:()=>ci,qN:()=>Mn,mZ:()=>zt,Ec:()=>Jt,L0:()=>Co,Te:()=>No,vw:()=>lo,z8:()=>ne,k9:()=>Ii,sP:()=>ke,Y3:()=>Ne,WC:()=>Ai,Nj:()=>$e,dF:()=>Qn,cw:()=>Zn,p8:()=>er,rv:()=>nr,pX:()=>Ke,iD:()=>Xe,Mb:()=>Le,bq:()=>Br,ke:()=>Gr,w1:()=>Fr,yz:()=>De,RW:()=>Pe,WL:()=>Ue,rh:()=>ve,nW:()=>He,RH:()=>Je,Aj:()=>Lt,cV:()=>_t,jM:()=>Jn,nS:()=>Xt,Yu:()=>wo,xf:()=>Vt,KS:()=>Sr,L6:()=>mn,Z9:()=>Cn,Ny:()=>Dn,qY:()=>Fn,jQ:()=>qr,NT:()=>zr,Xr:()=>ee,ab:()=>te,SV:()=>Qt,EA:()=>no,M2:()=>to,OY:()=>Ei,ry:()=>re,cS:()=>y,ZJ:()=>ti,RA:()=>wn,BH:()=>Yr,SL:()=>ii,Ne:()=>cr,fg:()=>Dt,M4:()=>Xn,UG:()=>Ln,CT:()=>nt,yv:()=>Zo,vI:()=>To,oe:()=>Xo,XZ:()=>ri,ZE:()=>or,pi:()=>vt,B8:()=>yt,yx:()=>Ti,br:()=>_r,eU:()=>go,cf:()=>ao,jy:()=>co,cm:()=>qn,qn:()=>Ao,ss:()=>Or,pf:()=>Io,pZ:()=>ur,l4:()=>ar,f8:()=>Q,Y6:()=>At,FS:()=>p,bM:()=>a,ZX:()=>xr,CE:()=>Wn,Sf:()=>$r,tp:()=>Zr,Ry:()=>fo,jh:()=>Rr,dp:()=>po,a2:()=>N,C$:()=>R,J5:()=>C,sc:()=>_,x9:()=>P,Py:()=>d,Xc:()=>T,Ts:()=>ki,P$:()=>A,xX:()=>w,ae:()=>I,zN:()=>Fe,dU:()=>wr,mA:()=>h,En:()=>m,eD:()=>L,$Q:()=>Ri});var i=r(4040),c=r.n(i);class s{static setNodeCacheUrl(e=""){this.NODE_CACHE_URL=e,this.isNearestCache=!0}static setCacheServers(e=[]){this.CACHE_SERVERS=e.filter((e=>"string"==typeof e&&""!==e.trim())),this.NODE_CACHE_URL=this.CACHE_SERVERS.length>0?this.CACHE_SERVERS[0]:"",this.isNearestCache=!0}static GetReadBaseUrl(){return this.NODE_CACHE_URL&&""!==this.NODE_CACHE_URL.trim()?this.NODE_CACHE_URL:this.BASE_URL}static GetNodeBaseUrl(){return this.NODE_URL&&""!==this.NODE_URL.trim()?this.NODE_URL:this.BASE_URL}static GetReadBaseUrlCandidates(){const e=[this.NODE_CACHE_URL,...this.CACHE_SERVERS,this.GetNodeBaseUrl(),this.BASE_URL].filter((e=>"string"==typeof e&&""!==e.trim())).map((e=>e.trim()));return Array.from(new Set(e))}static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.GetNodeBaseUrl()+"/api/get_connection_bulk"}static GetAllConceptsOfUserUrl(){return this.BASE_URL+"/api/get_all_concepts_of_user"}static GetAllConnectionsOfUserUrl(){return this.BASE_URL+"/api/get_all_connections_of_user"}static GetConnectionsBetweenUrl(){return this.BASE_URL+"/api/get-connection-between"}static GetAllConnectionsOfCompositionUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition"}static GetAllConnectionsOfCompositionBulkUrl(){return this.BASE_URL+"/api/get_all_connections_of_composition_bulk"}static GetConceptByCharacterValueUrl(){return this.BASE_URL+"/api/get_concept_by_character_value"}static GetConceptByCharacterAndTypeUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_type"}static GetConceptByCharacterAndCategoryUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category"}static GetConceptByCharacterAndCategoryDirectUrl(){return this.BASE_URL+"/api/get_concept_by_character_and_category_direct"}static GetCharacterByCharacterUrl(){return this.BASE_URL+"/api/get_character_by_character"}static GetAllConceptsByTypeUrl(){return this.BASE_URL+"/api/get_all_concepts_by_type"}static GetAllConnectionsOfConceptUrl(){return this.BASE_URL+"/api/get-link-connections"}static GetAllConnectionsToConceptUrl(){return this.BASE_URL+"/api/get-link-reverse-connections"}static GetAllAiData(){return this.BASE_URL+"/api/get-preloaded-concepts"}static GetAllPrefetchConnectionsUrl(){return this.BASE_URL+"/api/get_all_connections_of_user?inpage=500"}static GetAllLinkerConnectionOfConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-from-concept"}static GetAllLinkerConnectionToConceptUrl(){return this.BASE_URL+"/api/get-all-linkers-to-concept"}static DeleteConceptUrl(){return this.BASE_URL+"/api/delete_concept"}static RecursiveSearchUrl(){return this.BASE_URL+"/api/recursivesearch-concept-connection"}static SearchLinkMultipleAllApiUrl(){return this.BASE_URL+"/api/Connection/search-link-multiple-all-ccs"}static MakeTheNameInBackendUrl(){return this.BASE_URL+"/api/make-name-from-frontend"}static LoginUrl(){return this.BASE_URL+"/api/auth/login"}static SignupUrl(){return this.BASE_URL+"/api/auth/signup"}static GetCompositionConnectionBetweenTwoConceptsUrl(){return this.BASE_URL+"/api/get-composition-connection-between-two-concepts"}static SearchCompositionsUrl(){return this.BASE_URL+"/api/search-compositions"}static SearchLinkMultipleAll(){return this.BASE_URL+"/api/Connection/search-link-multiple-all"}static CreateSessionId(){return this.BASE_URL+"/api/create-session-id-remote"}static CreateSessionVisitUrl(){return this.BASE_URL+"/api/create-remote-session-visit"}static ViewInternalDataUrl(){return this.BASE_URL+"/api/view-api-internal-data-ccs-id-bulk"}static SearchInternalWithAuthenticatedCcsUrl(){return this.BASE_URL+"/api/search-composition-internal-authenticated-ccs"}static GetReservedIdUrl(){return this.BASE_URL+"/api/get_reserved_ids"}static GetReservedConnectionIdUrl(){return this.BASE_URL+"/api/get_reserved_connection_ids"}static CreateTheTextDataUrl(){return this.BASE_URL+"/api/create_text_data"}static CreateTheCharacterDataUrl(){return this.BASE_URL+"/api/create_character_data"}static CreateTheConceptUrl(){return this.BASE_URL+"/api/create_the_concept"}static CreateTheConnectionUrl(){return this.BASE_URL+"/api/create_the_connection"}static CreateTheConnectionNewUrl(){return this.BASE_URL+"/api/create_the_connection_new"}static MakeTheTypeConceptUrl(){return this.BASE_URL+"/api/make_the_type_concept"}static CreateTypeConceptUrl(){return this.BASE_URL+"/api/create_type_concept"}static DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static DeleteTheConnectionBulkUrl(){return this.BASE_URL+"/api/delete_connection_bulk"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}static GetConceptConnectionByType(){return this.BASE_URL+"/api/get_type_concept_by_character_bulk"}static OAuthTokenUrl(){return this.BASE_URL+"/api/oauth/token"}static OAuthRefreshUrl(){return this.BASE_URL+"/api/oauth/refresh"}}s.BASE_URL="https://localhost:7053/",s.NODE_CACHE_URL="",s.CACHE_SERVERS=[],s.isNearestCache=!0,s.AI_URL="https://ai.freeschema.com",s.MQTT_URL="192.168.1.249",s.NODE_URL="";class a{static getAuthHeader(){return this.BearerAccessToken?{Authorization:`Bearer ${this.BearerAccessToken}`}:{}}static setToken(e,t){this.BearerAccessToken=e,this.TOKEN_EXPIRY=t&&t>0?Date.now()+1e3*t:Date.now()+36e5}static isTokenExpiredOrNearExpiry(){return!!this.TOKEN_EXPIRY&&Date.now()>=this.TOKEN_EXPIRY-this.EXPIRY_BUFFER_MS}static getTimeUntilExpiry(){if(!this.TOKEN_EXPIRY)return-1;const e=Date.now(),t=this.TOKEN_EXPIRY-e;return t>0?Math.floor(t/1e3):-1}static hasOAuthCredentials(){return!!(this.CLIENT_ID&&this.CLIENT_SECRET&&this.APPLICATION_NAME)}static setOAuthCredentials(e,t,n){this.CLIENT_ID=e,this.CLIENT_SECRET=t,this.APPLICATION_NAME=n}static setDefaultIdentity(e,t,n,r){this.DEFAULT_USER_ID=e,this.DEFAULT_USER_CONCEPT_ID=t,this.DEFAULT_ENTITY_ID=n,this.DEFAULT_SESSION_ID=r}}a.BearerAccessToken="",a.CLIENT_ID="",a.CLIENT_SECRET="",a.APPLICATION_NAME="",a.TOKEN_EXPIRY=0,a.EXPIRY_BUFFER_MS=3e5,a.DEFAULT_USER_ID=0,a.DEFAULT_USER_CONCEPT_ID=0,a.DEFAULT_ENTITY_ID=0,a.DEFAULT_SESSION_ID=0;var l=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function u(e){try{const t=c().decode(e);if(!t)return;a.setDefaultIdentity(Number(t.unique_name)||0,Number(t.upn)||0,Number(t.EntityId)||0,Number(t.primarysid)||0)}catch(e){}}function d(e,t,n){return l(this,arguments,void 0,(function*(e,t,n,r=!0){try{const o=s.OAuthTokenUrl(),i=new URLSearchParams;i.append("client_id",e),i.append("client_secret",t),i.append("application_name",n);const c=yield fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i.toString()});if(c.ok){let e="",t="Bearer",n=0;const o=c.headers.get("content-type");if(o&&o.includes("application/json"))try{const r=yield c.json();e=r.access_token||"",t=r.token_type||"Bearer",n=r.expires_in||0}catch(t){e=yield c.text()}else e=yield c.text();return e?(r&&(a.setToken(e,n),u(e)),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield c.text();return{success:!1,error:`HTTP ${c.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}function h(e,t,n){return l(this,arguments,void 0,(function*(e,t,n,r=!0){try{const o=s.OAuthRefreshUrl(),i=new URLSearchParams;i.append("client_id",e),i.append("client_secret",t),i.append("refresh_token",n),i.append("grant_type","refresh_token");const c=yield fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i.toString()});if(c.ok){let e="",t="Bearer",n=0;const o=c.headers.get("content-type");if(o&&o.includes("application/json"))try{const r=yield c.json();e=r.access_token||"",t=r.token_type||"Bearer",n=r.expires_in||0}catch(t){e=yield c.text()}else e=yield c.text();return e?(r&&(a.setToken(e,n),u(e)),{success:!0,access_token:e,token_type:t,expires_in:n}):{success:!1,error:"No access token in response"}}{const e=yield c.text();return{success:!1,error:`HTTP ${c.status}: ${e}`}}}catch(e){return e instanceof TypeError?{success:!1,error:`Network error: ${e.message}`}:{success:!1,error:`Unexpected error: ${e instanceof Error?e.message:String(e)}`}}}))}var f=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class p extends Error{constructor(e){super(e),this.name="TokenRefreshError"}}class y{constructor(e,t,n){this.status=e,this.body=t,this.headers=n}json(){return f(this,void 0,void 0,(function*(){return JSON.parse(this.body)}))}text(){return f(this,void 0,void 0,(function*(){return this.body}))}get ok(){return this.status>=200&&this.status<300}}function v(){return f(this,void 0,void 0,(function*(){if(!a.hasOAuthCredentials())return!1;try{return(yield d(a.CLIENT_ID,a.CLIENT_SECRET,a.APPLICATION_NAME,!0)).success}catch(e){return console.error("Token refresh failed:",e),!1}}))}const g=3e4;function m(e,t,n,r){return f(this,arguments,void 0,(function*(e,t,n,r,o=1,i=g){var c,s;const l=Object.assign(Object.assign({},n),a.getAuthHeader()),u=["GET","HEAD","OPTIONS"].includes(e.toUpperCase());for(let n=0;n<=o;n++){const d=new AbortController,h=setTimeout((()=>d.abort()),i);try{const i={method:e,headers:l,signal:d.signal};if(void 0!==r){const e=r instanceof URLSearchParams||"undefined"!=typeof FormData&&r instanceof FormData||"undefined"!=typeof Blob&&r instanceof Blob||r instanceof ArrayBuffer||ArrayBuffer.isView(r);"object"!=typeof r||e?i.body=r:(l["Content-Type"]||l["content-type"]||(l["Content-Type"]="application/json"),(null===(c=l["Content-Type"])||void 0===c?void 0:c.includes("application/json"))||(null===(s=l["content-type"])||void 0===s?void 0:s.includes("application/json"))?i.body=JSON.stringify(r):i.body=r)}i.headers=l;const u=yield fetch(t,i),h=yield u.text(),f={};if(u.headers.forEach(((e,t)=>{f[t]=e})),401!==u.status)return new y(u.status,h,f);if(n<o){if(yield v()){Object.assign(l,a.getAuthHeader());continue}throw new p("Token refresh failed. Please check OAuth credentials.")}return new y(u.status,h,f)}catch(e){if(e instanceof p)throw e;if(n>=o||!u)throw e;console.error(`Request failed (attempt ${n+1}/${o+1}):`,e)}finally{clearTimeout(h)}}throw new Error("Request failed after all retry attempts")}))}function C(e){return f(this,arguments,void 0,(function*(e,t={},n=1){return m(t.method||"GET",e,function(e){if(e){if(e instanceof Headers){const t={};return e.forEach(((e,n)=>{t[n]=e})),t}return Array.isArray(e)?e.reduce(((e,[t,n])=>(e[t]=n,e)),{}):e}}(t.headers),t.body,n)}))}function w(e,t,n){return f(this,void 0,void 0,(function*(){return m("POST",e,t,n)}))}function T(e,t,n){return f(this,void 0,void 0,(function*(){let r=e;if(n){const t=[];for(const e in n)n.hasOwnProperty(e)&&t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n[e]))}`);t.length>0&&(r=`${e}?${t.join("&")}`)}return m("GET",r,t)}))}function I(e,t,n){return f(this,void 0,void 0,(function*(){return m("PUT",e,t,n)}))}function N(e,t){return f(this,void 0,void 0,(function*(){return m("DELETE",e,t)}))}function A(e,t,n){return f(this,void 0,void 0,(function*(){return m("PATCH",e,t,n)}))}var E=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function S(e,t){return`${e.replace(/\/+$/,"")}${t}`}function R(e){return E(this,arguments,void 0,(function*(e,t={},n=1){const r=s.GetReadBaseUrlCandidates();let o;for(const i of r){try{const r=yield C(S(i,e),t,n);if(i.replace(/\/+$/,"")===s.BASE_URL.replace(/\/+$/,""))return r;if(r.ok)return s.NODE_CACHE_URL=i,r;o=new Error(`Cache server ${i} returned status ${r.status}`)}catch(e){o=e}s.isNearestCache=!1}throw o instanceof Error?o:new Error("All cache servers failed")}))}class k{constructor(e){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=e}}var x=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const b={};function $(e){return b[e]||(b[e]=[]),b[e]}function L(e,t){const n=$(e);if(t&&"number"==typeof t.id){const e=n.findIndex((e=>e&&e.id===t.id));if(e>=0)return void(n[e]=t)}n.push(t)}function _(e,t,n){return x(this,void 0,void 0,(function*(){return $(e).filter((e=>e&&e[t]===n))}))}function P(e){return x(this,void 0,void 0,(function*(){return $(e).slice()}))}function O(e,t){const n=$(e),r=n.findIndex((e=>e&&e.id===t));r>=0&&n.splice(r,1)}function U(e){return x(this,void 0,void 0,(function*(){return $(e).slice()}))}class B{}B.isTypeLoaded=!1,B.isCharacterLoaded=!1,B.isDataLoaded=!1,B.isLocalDataLoaded=!1,B.isLocalCharacterLoaded=!1,B.isLocalTypeLoaded=!1,B.isConnectionLoaded=!1,B.isConnectionTypeLoaded=!1,B.isLocalConnectionLoaded=!1;class D{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getCharacterFromNodeUpdated(e,t){var n;return t?e==t.key||51==(null===(n=t.value)||void 0===n?void 0:n.typeId)?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.categoryId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.categoryId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndCategory(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var F=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class G{static waitForDataToLoad(){return F(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isCharacterLoaded)return e("done");setTimeout(G.checkFlag,1e3,e)}static addNodeToTree(e){return F(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=e,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(e,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(e,t){return F(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,e,t)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(e){if(""!=e.characterValue){var t=new D(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(e){return this.characterRoot?this.characterRoot.getCharacterFromNode(e,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(e,t){return F(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(e,t,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(e,t){return F(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(e,t,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(e){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,e))}}G.characterRoot=null;var j=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class V{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static waitForDataToLoad(){return j(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isDataLoaded)return e("done");setTimeout(V.checkFlag,1e3,e)}static addConceptToTree(e){var t=new D(e.id,e,null,null),n=new D(e.characterValue,e,null,null);G.addNodeToTree(n),this.addNodeToTree(t)}static getNodeFromTree(e){return j(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return j(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}V.root=null;class M{constructor(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p,y=!1,v,g){this.referent=null,this.updateRecursion=!1,this.isTemp=!1,this.id=e,this.userId=t,this.typeId=n,this.typeUserId=r,this.ghostId=e,this.categoryId=o,this.categoryUserId=i,this.referentId=c,this.referentUserId=s,this.characterValue=`${a}`,this.securityId=l,this.securityUserId=u,this.accessId=d,this.accessUserId=h,this.sessionInformationId=f,this.sessionInformationUserId=p,this.x=0,this.y=0,this.type=null,this.isNew=y,this.entryTimeStamp=v,this.updatedTimeStamp=g}getType(){console.log(this.typeId)}}function H(){let e=W(new Date),t=W(new Date);return new M(0,0,0,0,0,0,0,0,"0",0,0,0,0,0,0,!1,e,t)}function W(e){const t=e.getMonth()+1,n=e.getDate(),r=e.getFullYear();let o=e.getHours();const i=e.getMinutes(),c=e.getSeconds(),s=o>=12?"PM":"AM";o%=12,o=o||12;const a=e=>e.toString().padStart(2,"0");return`${t}/${n}/${r} ${o}:${a(i)}:${a(c)} ${s}`}var K=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class X{static addNodeToTree(e){return K(this,void 0,void 0,(function*(){return null==this.typeRoot?(this.typeRoot=e,this.typeRoot):(this.typeRoot=this.typeRoot.addTypeNode(e,this.typeRoot,this.typeRoot.height),this.typeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new D(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.typeRoot&&(this.typeRoot=this.typeRoot.removeNodeWithVariants(this.typeRoot,e,t))}static getNodeFromTree(e){return this.typeRoot?this.typeRoot.getFromNode(e,this.typeRoot):this.typeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return K(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isTypeLoaded)return e("done");setTimeout(X.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return K(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)if(r.variants[e].value.userId==t){var o=!1;for(let t=0;t<n.length;t++)n[t].id==r.variants[e].value.id&&(o=!0);o||n.push(r.variants[e].value)}}return n}))}static getTypeVariantsWithCharacterValue(e,t){return K(this,void 0,void 0,(function*(){let n=H();var r=this.getNodeFromTree(t);if(r){r.value.characterValue==e&&(n=r.value);for(let t=0;t<r.variants.length;t++)r.variants[t].value.characterValue==e&&(n=r.variants[t].value)}return n}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}X.typeRoot=null;var q=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class z{constructor(){this.name="conceptsArray"}static RemoveExpiredNpc(e=Date.now()){this.NPC=this.NPC.filter((t=>{const n=this.NPCMeta.get(t);return n&&n.expiresAt>e}))}static CheckContains(e){for(var t=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==e.id&&(t=!0);return t}static AddNpc(e){var t;const n=Date.now();this.RemoveExpiredNpc(n),this.NPC.includes(e)||this.NPC.push(e);const r=this.NPCMeta.get(e),o=(null!==(t=null==r?void 0:r.attempts)&&void 0!==t?t:0)+1;this.NPCMeta.set(e,{attempts:o,expiresAt:n+o*this.NPC_BACKOFF_SECONDS*1e3})}static GetNpc(e){const t=Date.now();this.RemoveExpiredNpc(t);const n=this.NPCMeta.get(e);return!!(n&&n.expiresAt>t)}static AddConceptToStorage(e){e.id>0&&L("concept",e)}static AddConcept(e){e.id>0&&(L("concept",e),V.addConceptToTree(e),X.addConceptToTree(e),G.addConceptToTree(e))}static AddConceptToMemory(e){e.id>0&&(V.addConceptToTree(e),X.addConceptToTree(e),G.addConceptToTree(e))}static AddConceptTemporary(e){var t=this.CheckContains(e);this.conceptDictionary[e.id]=e,t&&this.RemoveConcept(e),this.conceptsArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsArray.length;t++)this.conceptsArray[t].id==e.id&&this.conceptsArray.splice(t,1);V.removeNodeFromTree(e.id),O("concept",e.id)}static GetConcept(e){return q(this,void 0,void 0,(function*(){var t=H(),n=yield V.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConceptByCharacter(e){return q(this,void 0,void 0,(function*(){var t=H(),n=G.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterUpdated(e){return q(this,void 0,void 0,(function*(){var t=H(),n=G.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return q(this,void 0,void 0,(function*(){return H(),yield X.getTypeVariantsWithCharacterValue(e,t)}))}static GetConceptByCharacterAndCategoryLocal(e,t){return q(this,void 0,void 0,(function*(){var n=H(),r=yield G.getCharacterAndCategoryFromTree(e,t);return r&&(n=r.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==e&&t.push(this.conceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return q(this,void 0,void 0,(function*(){let n=[];return n=yield X.getTypeVariantsFromTreeWithUserId(e,t),n}))}static GetBinaryCharacterTree(){return G.characterRoot}getName(){return this.name}}z.conceptsArray=[],z.NPC=[],z.NPCMeta=new Map,z.NPC_BACKOFF_SECONDS=30,z.conceptDictionary=[];var J=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Y(){return J(this,void 0,void 0,(function*(){(new Date).getTime();var e=yield P("concept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];z.AddConceptToMemory(n)}(new Date).getTime()}))}function Q(e){const t=e.lastIndexOf("_");let n=[];return n=t>0?[e.substring(0,t),e.substring(t+1,e.length)]:[e],n}var Z=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ee(){return Z(this,arguments,void 0,(function*(e="application/json",t="application/json"){if(a.isTokenExpiredOrNearExpiry()&&a.hasOAuthCredentials()){const e=yield d(a.CLIENT_ID,a.CLIENT_SECRET,a.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+a.BearerAccessToken,Accept:t}}))}function te(){return Z(this,arguments,void 0,(function*(e="application/json",t="",n="application/json"){if(""!==t)return{"Content-Type":e,Authorization:"Bearer "+t,Accept:n};if(a.isTokenExpiredOrNearExpiry()&&a.hasOAuthCredentials()){const e=yield d(a.CLIENT_ID,a.CLIENT_SECRET,a.APPLICATION_NAME,!0);e.success||console.error("Failed to refresh token:",e.error)}return{"Content-Type":e,Authorization:"Bearer "+a.BearerAccessToken,Accept:n}}))}class ne{constructor(e,t,n,r){this.url=s.BASE_URL,this.message=e,this.ok=t,this.status=n,this.data=r}getMessage(){return this.message}setMessage(e){return this.message=e,this}getStatus(){return this.status}setStatus(e){return this.status=e,this}getData(){return this.data}setData(e){return this.data=e,this}getOk(){return this.ok}setOk(e){return this.ok=e,this}getUrl(){return this.url}setUrl(e){return this.url=e,this}}function re(e){if(!e.ok){const t=e instanceof y,n=t?e.body||`HTTP error ${e.status}`:e.statusText||`HTTP error ${e.status}`;let r=new ne(n,!1,e.status,"");throw r.setUrl(t?e.headers.url||"":e.url),r}}function oe(e){if(!e.ok){const t=e.body||`HTTP error ${e.status}`;let n=new ne(t,!1,e.status,e.body);throw n.setUrl(e.headers.url||""),n}}var ie=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ce(e,t){return ie(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",e),n.append("user_id",t.toString());var r=yield ee("application/x-www-form-urlencoded");const i=yield C(s.GetAllConceptsByTypeUrl(),{method:"POST",headers:r,body:n});if(i.ok){const e=yield i.json();for(var o=0;o<e.length;o++)z.AddConcept(e[o])}console.log("GetAllConceptsByType error",i.status),re(i)}catch(e){throw e instanceof Error?console.log("GetAllConceptsByType error message: ",e.message):console.log("GetAllConceptsByType unexpected error: ",e),e}}))}class se{constructor(e=0,t,n,r,o,i,c,s,a,l,u,d,h,f,p,y){this.isTemp=!1,this.toUpdate=!1,this.type=H(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.ofTheConceptUserId=r,this.toTheConceptUserId=o,this.userId=i,this.typeId=c,this.ghostId=e,this.typeUserId=s,this.orderId=a,this.orderUserId=l,this.securityId=u,this.securityUserId=d,this.accessId=h,this.accessUserId=f,this.sessionInformationId=p,this.sessionInformationUserId=y,this.entryTimeStamp=W(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date}}class ae{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;e.value.id==t.value.id&&(n=!0);for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var le=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class ue{static addNodeToTree(e){if(null==this.connectionroot)return this.connectionroot=e,this.connectionroot;this.connectionroot=this.connectionroot.addNode(e,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(e){var t=new ae(e.id,e,null,null);this.addNodeToTree(t)}static waitForDataToLoad(){return le(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isConnectionLoaded)return e("done");setTimeout(ue.checkFlag,1e3,e)}static removeNodeFromTree(e){return le(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,e))}))}static getNodeFromTree(e){return le(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(e,this.connectionroot):this.connectionroot}))}}ue.connectionroot=null;var de=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class he{static addNodeToTree(e){return de(this,void 0,void 0,(function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=e,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addTypeNode(e,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)}))}static waitForDataToLoad(){return de(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isConnectionTypeLoaded)return e("done");setTimeout(he.checkFlag,1e3,e)}static addConnectionToTree(e){if(0!=e.typeId){var t=new ae(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeTypeConcept(e,t){this.connectionTypeRoot&&(this.connectionTypeRoot=this.connectionTypeRoot.removeNodeWithVariants(this.connectionTypeRoot,e,t))}static getNodeFromTree(e){return this.connectionTypeRoot?this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot):this.connectionTypeRoot}static getTypeVariantsFromTree(e){return de(this,void 0,void 0,(function*(){var t=[],n=this.getNodeFromTree(e);if(n){t.push(null==n?void 0:n.value);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value);return t}}))}static getTypeVariantsFromTreeWithUserId(e,t){return de(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)r.variants[e].value.userId==t&&n.push(r.variants[e].value)}return n}))}}he.connectionTypeRoot=null;var fe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class pe{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnectionToStorage(e){L("connection",e)}static AddConnection(e){e.isTemp||(L("connection",e),ue.addConnectionToTree(e),he.addConnectionToTree(e))}static AddConnectionToMemory(e){e.isTemp||(ue.addConnectionToTree(e),he.addConnectionToTree(e))}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){0!=e.id&&(O("connection",e.id),ue.removeNodeFromTree(e.id),he.removeTypeConcept(e.typeId,e.id))}static GetConnectionTree(){return ue.connectionroot}static GetConnectionTypeTree(){return he.connectionTypeRoot}static GetConnection(e){return fe(this,void 0,void 0,(function*(){var t=new se(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n=yield ue.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConnectionsOfCompositionLocal(e){return fe(this,void 0,void 0,(function*(){var t=[],n=yield he.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;if(r){let e=r;t.push(e);for(let e=0;e<n.variants.length;e++)t.push(n.variants[e].value)}}return t}))}getName(){return this.name}}pe.connectionArray=[],pe.connectionDictionary=[];var ye=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ve(e){return ye(this,void 0,void 0,(function*(){let t=[];try{var n=[];for(let r=0;r<e.length;r++){let o=yield z.GetConcept(e[r]);0==o.id?n.push(e[r]):t.push(o)}if(0==n.length)return t;{const e=JSON.stringify(n);var r=yield ee();const o=yield R("/api/get_concept_bulk",{method:"POST",headers:r,body:e});if(o.ok){let e=yield o.json();if(e.length>0)for(let n=0;n<e.length;n++){let r=e[n];t.push(r),z.AddConcept(r)}}else console.log("Get Concept Bulk error",o.status),re(o);return t}}catch(e){throw e instanceof Error?console.log("Get Concept Bulk error message: ",e.message):console.log("Get Concept Bulk unexpected error: ",e),e}}))}var ge=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function me(){return ge(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length>0){for(let n=0;n<e.length;n++)t.includes(e[n].ofTheConceptId)||t.push(e[n].ofTheConceptId),t.includes(e[n].toTheConceptId)||t.push(e[n].toTheConceptId);yield ve(t)}}))}var Ce=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function we(){return Ce(this,arguments,void 0,(function*(e=[]){var t=[];for(let r=0;r<e.length;r++){var n=yield pe.GetConnectionsOfCompositionLocal(e[r]);t.push(...n)}return t}))}function Te(e=[],t=[]){for(let n=0;n<t.length;n++)Array.isArray(e)&&(e.find((e=>e.id===t[n].id))||pe.RemoveConnection(t[n]))}var Ie=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ne(){return Ie(this,arguments,void 0,(function*(e=[]){var t=[];if(e.length<=0)return t;var n=yield we(e),r=yield function(){return Ie(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=yield ee();const o=yield C(s.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(o.ok){const e=yield o.json();for(var r=0;r<e.length;r++)pe.AddConnection(e[r]),t.push(e[r])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),re(o);return t}catch(e){throw e instanceof Error?console.log("Get all connections of composition bulk error message: ",e.message):console.log("Get all connections of composition bulk unexpected error: ",e),e}}))}(e);return Te(t=r,n),yield me(t),t}))}var Ae=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Ee=new Map;function Se(e){return Ae(this,void 0,void 0,(function*(){let t=H();if(Ee.has(e))return Ee.get(e)||t;const n=(()=>Ae(this,void 0,void 0,(function*(){try{var n=yield z.GetConcept(e);let o=z.GetNpc(e);if(0!=n.id||o)return n;{var r=yield ee("application/x-www-form-urlencoded");const n=yield C(s.GetConceptUrl(),{method:"POST",headers:r,body:`id=${e}`});return n.ok?(t=yield n.json(),t.id>0?z.AddConcept(t):z.AddNpc(e)):(console.log("Get the concept error",n.status,e),re(n)),t}}catch(t){throw t instanceof Error?console.log("Get the concept error message: ",t.message,e):console.log("Get the concept unexpected error: ",t,e),t}finally{Ee.delete(e)}})))();return Ee.set(e,n),n}))}var Re=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ke(e){return Re(this,void 0,void 0,(function*(){var t=[];if(0==(t=yield pe.GetConnectionsOfCompositionLocal(e)).length)t=yield xe(e);else{var n=yield xe(e);Te(n,t),t=n}return t}))}function xe(e){return Re(this,void 0,void 0,(function*(){var t=[];try{var n=yield ee("application/x-www-form-urlencoded");const o=yield C(s.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:n,body:`composition_id=${e}`});if(!o.ok)throw re(o),new Error(`Error! status: ${o.status}`);const i=yield o.json();for(var r=0;r<i.length;r++)pe.AddConnection(i[r]),t.push(i[r]);return t}catch(e){throw e instanceof Error?console.log("Get all connection of composition error : ",e.message):console.log("Get all connection of composition error : ",e),e}}))}var be=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function $e(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield ke(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function Le(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield ke(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Ge(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function _e(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield pe.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);return o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a,o}))}function Pe(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield pe.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=o,l.id=e,l}))}function Oe(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield pe.GetConnectionsOfCompositionLocal(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=o,l.id=e,l.created_at=s.entryTimeStamp,l}))}function Ue(e,t){return be(this,void 0,void 0,(function*(){for(var n,r,o={},i=[],c=0;c<t.length;c++)i.includes(t[c].ofTheConceptId)||i.push(t[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,t,i);o[null!==(r=null===(n=null==s?void 0:s.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=a;var l={};return l.created_at=s.entryTimeStamp,l.data=o,l.id=e,l}))}function Be(e,t){return be(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i={},c=yield z.GetConcept(e);0==c.id&&null!=e&&null!=e&&(c=yield Se(e));var s=yield Fe(e,t,n);i[null!==(o=null===(r=null==c?void 0:c.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:""]=s;var a={};return a.created_at=c.entryTimeStamp,a.data=i,a.id=e,a}))}function De(e){return be(this,void 0,void 0,(function*(){var t,n,r,o={};r=yield ke(e);for(var i=[],c=0;c<r.length;c++)i.includes(r[c].ofTheConceptId)||i.push(r[c].ofTheConceptId);var s=yield z.GetConcept(e);0==s.id&&null!=e&&null!=e&&(s=yield Se(e));var a=yield Fe(e,r,i);o[null!==(n=null===(t=null==s?void 0:s.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=a;var l={};return l.data=o,l.id=e,l}))}function Fe(e,t,n){return be(this,arguments,void 0,(function*(e,t,n,r=[]){var o,i,c,s={},a=[];if(0==e)return null;var l=yield z.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Se(e)),0!=l.id&&null==l.type){var u=l.typeId,d=yield z.GetConcept(u);l.type=d,null==d&&null!=u&&null!=u&&(d=yield Se(u),l.type=d)}if(null===(o=null==l?void 0:l.type)||void 0===o?void 0:o.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(r.includes(e))return"";r.push(e);for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,p=yield z.GetConcept(f);null!=p&&0!=p.id||null==f||null==f||(p=yield Se(f)),p&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield z.GetConcept(u),p.type=d,null==d&&null!=u&&null!=u&&(d=yield Se(u),p.type=d));var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield Fe(f,t,n,r);s[y]=e}}else{const e=yield Fe(f,t,n,r);a[y]=e,s=a}}return s}))}function Ge(e,t,n){return be(this,arguments,void 0,(function*(e,t,n,r=[]){var o,i,c,s={},a=[];if(0==e)return null;var l=yield z.GetConcept(e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Se(e)),0!=l.id&&null==l.type){var u=l.typeId,d=yield z.GetConcept(u);l.type=d,null==d&&null!=u&&null!=u&&(d=yield Se(u),l.type=d)}if(null===(o=null==l?void 0:l.type)||void 0===o?void 0:o.characterValue,!n.includes(e))return null==l?void 0:l.characterValue;if(r.includes(e))return"";r.push(e),s.id=e;for(var h=0;h<t.length;h++)if(t[h].ofTheConceptId==e){var f=t[h].toTheConceptId,p=yield z.GetConcept(f);null!=p&&0!=p.id||null==f||null==f||(p=yield Se(f)),p&&null==(null==p?void 0:p.type)&&(u=p.typeId,d=yield z.GetConcept(u),p.type=d,null==d&&null!=u&&null!=u&&(d=yield Se(u),p.type=d));var y=(null!==(c=null===(i=null==p?void 0:p.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace("the_","");if(isNaN(Number(y))){if(y){const e=yield Ge(f,t,n);s[y]=e}}else{const e=yield Ge(f,t,n);a[y]=e,s=a}}return s}))}var je=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ve(e){return je(this,void 0,void 0,(function*(){let t=H();try{var n=yield ee("application/x-www-form-urlencoded");const r=yield C(s.GetConceptByCharacterValueUrl(),{method:"POST",headers:n,body:`character_value=${e}`});return r.ok?(t=yield r.json(),t.id>0&&z.AddConcept(t)):(console.log("Error in Getting concept by character value Error",r.status),re(r)),t}catch(e){throw e instanceof Error?console.log("Error in Getting concept by character value error message: ",e):console.log("Error in Getting concept by character value unexpected error: ",e),e}}))}var Me=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function He(e){return Me(this,void 0,void 0,(function*(){var t=yield z.GetConceptByCharacter(e),n=`${e}`;return null!=t&&0!=(null==t?void 0:t.id)||!n||(yield Ve(e),t=yield z.GetConceptByCharacter(e)),t}))}var We=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ke(e,t){return We(this,arguments,void 0,(function*(e,t,n=10,r=1){var o=yield He(e),i=[];if(o){yield ce(e,t);for(var c=yield z.GetConceptsByTypeIdAndUser(o.id,t),s=n*(r-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield Ne(a),l=s;l<s+n;l++)if(c[l]){var u=yield _e(c[l].id);i.push(u)}}return i}))}function Xe(e,t){return We(this,arguments,void 0,(function*(e,t,n=10,r=1){var o=yield He(e),i=[];if(o){yield ce(e,t);for(var c=yield z.GetConceptsByTypeIdAndUser(o.id,t),s=n*(r-1),a=[],l=s;l<s+n;l++)c[l]&&a.push(c[l].id);for(yield Ne(a),l=s;l<s+n;l++)if(c[l]){var u=yield Pe(c[l].id);i.push(u)}}return i}))}var qe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const ze=new Map;function Je(e,t){return qe(this,void 0,void 0,(function*(){let n=H();if(ze.has(e+t))return ze.get(e+t)||n;const r=(()=>qe(this,void 0,void 0,(function*(){try{var r=yield ee("application/x-www-form-urlencoded");const o=yield C(s.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:r,body:`character_value=${e}&category_id=${t}`});if(o.ok){let e=yield o.json();n=e,z.AddConcept(n)}else console.log("This is the concept by category and character direct api error",o.status),re(o);return n}catch(n){throw n instanceof Error?console.log(" This is the concept by category and character direct api error message: ",n.message,e,t,s.GetConceptByCharacterAndCategoryDirectUrl()):console.log(" This is the concept by category and character unexpected direct api error: ",n,e,t,s.GetConceptByCharacterAndCategoryDirectUrl()),n}finally{ze.delete(e+t)}})))();return ze.set(e+t,r),r}))}var Ye=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Qe(e){return Ye(this,void 0,void 0,(function*(){let t=H();if("the"==e)return t.id=1,t.typeId=5,t.characterValue="the",t;let n=e.length;var r=Q(e);if(r.length>1){let n=1,o=yield Qe(r[0]);0!=o.id&&(n=o.id),t=yield function(e,t){return Ye(this,void 0,void 0,(function*(){let n=yield z.GetConceptByCharacterAndCategoryLocal(e,t);return 0==n.id&&(n=yield Je(e,t)),n}))}(e,n)}else r[0]==e&&1==n?t=yield function(e){return Ye(this,void 0,void 0,(function*(){var t=yield z.GetConceptByCharacterAndTypeLocal(e,49);return 0==t.id&&(t=yield Ve(e)),t}))}(e):r[0]==e&&(t=yield function(e){return Ye(this,void 0,void 0,(function*(){var t=yield z.GetConceptByCharacterAndTypeLocal(e,51);return 0==t.id&&(t=yield Ve(e)),t}))}(e));return t}))}var Ze=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const et=new Map,tt=new Map;function nt(e,t){return Ze(this,void 0,void 0,(function*(){let t=H();if(tt.has(e))return tt.get(e);if(et.has(e))return et.get(e)||t;const n=(()=>Ze(this,void 0,void 0,(function*(){try{if(t=yield Qe(e),0==t.id||4==t.typeId){var n=yield ee("application/x-www-form-urlencoded");const r=yield C(s.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${e}`});if(!r.ok)throw re(r),new Error(`Error! status: ${r.status}`);let o=yield r.json();t=o,t.id>0&&z.AddConcept(t)}return t.id>0&&tt.set(e,t),t}catch(e){throw e instanceof Error?console.log("Make The Type Concept Api error : ",e.message):console.log("Make The Type Concept Api error : ",e),e}finally{et.delete(e)}})))();return et.set(e,n),n}))}function rt(e){return t=this,n=arguments,o=function*(e,t=3,n=300){let r,o;for(let i=0;i<t;i++){try{const t=yield e();if(t.ok)return t;r=t}catch(e){o=e}if(i<t-1){const e=n*Math.pow(2,i);yield new Promise((t=>setTimeout(t,e)))}}if(r)return r;throw o},new((r=void 0)||(r=Promise))((function(e,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(c,s)}a((o=o.apply(t,n||[])).next())}));var t,n,r,o}var ot=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};let it=!1,ct=[];const st=()=>{ct.length>0&&!it&&ct.shift()()};function at(e){return ot(this,void 0,void 0,(function*(){return new Promise(((t,n)=>{ct.push((()=>ot(this,void 0,void 0,(function*(){try{if(it)return;if(it=!0,!e&&vt.connectionIds.length>10)return it=!1,st(),t();const n=e?`${s.GetReservedConnectionIdUrl()}?${new URLSearchParams({count:String(e)}).toString()}`:s.GetReservedConnectionIdUrl();var r=yield ee("application/x-www-form-urlencoded");const i=yield rt((()=>C(n,{method:"GET",headers:r})));if(!i.ok)throw re(i),new Error(`Error! status: ${i.status}`);const c=yield i.json();for(var o=0;o<c.length;o++)vt.AddId(c[o]);t()}catch(e){e instanceof Error?console.log("get reserved connection ids error message: ",e.message):console.log("get reserved connection ids unexpected error: ",e),n(e)}finally{it=!1,st()}})))),st()}))}))}var lt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};let ut=!1,dt=[];const ht=()=>{dt.length>0&&!ut&&dt.shift()()};function ft(){return lt(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{dt.push((()=>lt(this,void 0,void 0,(function*(){try{if(ut)return;if(ut=!0,yt.ids.length>10)return ut=!1,ht(),e();var n=yield ee("application/x-www-form-urlencoded");const t=yield rt((()=>C(s.GetReservedIdUrl(),{method:"GET",headers:n})));if(!t.ok)throw re(t),new Error(`Error! status: ${t.status}`);const o=yield t.json();for(var r=0;r<o.length;r++)yt.AddId(o[r]);e()}catch(e){t(e)}finally{ut=!1,ht()}})))),ht()}))}))}var pt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class yt{static getId(){return pt(this,void 0,void 0,(function*(){for(this.ids.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>pt(this,void 0,void 0,(function*(){try{yield ft()}finally{this.pendingFetch=null}})))(),this.ids.length>0&&this.pendingFetch.catch((e=>console.error("Reserved ID refill failed:",e))));0===this.ids.length;)if(this.pendingFetch||(this.pendingFetch=(()=>pt(this,void 0,void 0,(function*(){try{yield ft()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.ids.length)throw new Error("No reserved concept IDs were returned by the backend.");return this.ids.shift()}))}static AddId(e){Number.isFinite(e)&&e>0&&!this.ids.includes(e)&&this.ids.push(e)}}yt.ids=[],yt.pendingFetch=null;class vt{static getId(){return pt(this,void 0,void 0,(function*(){for(this.connectionIds.length<10&&!this.pendingFetch&&(this.pendingFetch=(()=>pt(this,void 0,void 0,(function*(){try{yield at()}finally{this.pendingFetch=null}})))());0===this.connectionIds.length;)if(this.pendingFetch||(this.pendingFetch=(()=>pt(this,void 0,void 0,(function*(){try{yield at()}finally{this.pendingFetch=null}})))()),yield this.pendingFetch,0===this.connectionIds.length)throw new Error("No reserved connection IDs were returned by the backend.");return this.connectionIds.shift()}))}static AddId(e){Number.isFinite(e)&&e>0&&!this.connectionIds.includes(e)&&this.connectionIds.push(e)}static warmUp(e){return pt(this,void 0,void 0,(function*(){const t=e-this.connectionIds.length;t<=0||(this.pendingFetch||(this.pendingFetch=(()=>pt(this,void 0,void 0,(function*(){try{yield at(t)}finally{this.pendingFetch=null}})))()),yield this.pendingFetch)}))}}vt.connectionIds=[],vt.pendingFetch=null;function gt(e){return{id:e.id,userId:e.userId,characterValue:e.characterValue,typeId:e.typeId,categoryId:e.categoryId,accessId:e.accessId,referentId:e.referentId,sessionInformationId:e.sessionInformationId}}function mt(e){return t=this,n=void 0,o=function*(){let t=H();try{var n=yield ee();const r=function(e){return Array.isArray(e)?e.map((e=>gt(e))):gt(e)}(e),o=yield w(s.CreateTheConceptUrl(),n,r);if(!o.ok)throw oe(o),new Error(`Error! status: ${o.status}`);return t=yield o.json(),t}catch(e){throw e instanceof Error?console.log("Create the concept api error message: ",e):console.log("Create the concept api unexpected error: ",e),e}},new((r=void 0)||(r=Promise))((function(e,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(c,s)}a((o=o.apply(t,n||[])).next())}));var t,n,r,o}function Ct(e){return t=this,n=void 0,o=function*(){let t=new se(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);try{var n=yield ee();const r=function(e){return e.map((e=>function(e){return{id:e.id,ofTheConceptId:e.ofTheConceptId,toTheConceptId:e.toTheConceptId,ofTheConceptUserId:e.ofTheConceptUserId,toTheConceptUserId:e.toTheConceptUserId,typeId:e.typeId,userId:e.userId,orderId:e.orderId,accessId:e.accessId,sessionInformationId:e.sessionInformationId}}(e)))}(e),o=yield w(s.CreateTheConnectionUrl(),n,r);if(!o.ok)throw console.log("Create the connection error message: ",o),oe(o),new Error(`Error! status: ${o.status}`);return t=yield o.json(),t}catch(e){throw e instanceof Error?console.log("Create the connection error message: ",e.message):console.log(" Create the connection unexpected error: ",e),e}},new((r=void 0)||(r=Promise))((function(e,i){function c(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(c,s)}a((o=o.apply(t,n||[])).next())}));var t,n,r,o}var wt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Tt(e){return e?`[SyncData:${e}]`:"[SyncData]"}function It(e,t){console.log(`${Tt(t)} ${e}`)}function Nt(e,t,n,r,o){r<100&&n!==r||n!==r&&1!==n&&n%100!=0||console.log(`${Tt(o)} ${e} ${t}: ${n}/${r} done, ${r-n} remaining`)}class At{static CheckContains(e){for(var t=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==e.id&&(t=!0);return t}static SyncDataDelete(e){for(var t=0;t<this.conceptsSyncArray.length;t++)e==this.conceptsSyncArray[t].id&&this.conceptsSyncArray.splice(t,1);for(t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].ofTheConceptId!=e&&this.connectionSyncArray[t].toTheConceptId!=e&&this.connectionSyncArray[t].typeId!=e||this.connectionSyncArray.splice(t,1)}static CheckContainsConnection(e){for(var t=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==e.id&&(t=!0);return t}static AddConcept(e){this.conceptsSyncArray.push(e)}static RemoveConcept(e){for(var t=0;t<this.conceptsSyncArray.length;t++)this.conceptsSyncArray[t].id==e.id&&this.conceptsSyncArray.splice(t,1)}static AddConnection(e){this.connectionSyncArray.push(e)}static RemoveConnection(e){for(var t=0;t<this.connectionSyncArray.length;t++)this.connectionSyncArray[t].id==e.id&&this.connectionSyncArray.splice(t,1)}static SyncDataOnline(e){return wt(this,void 0,void 0,(function*(){try{let t=[],n=[];if(e&&this.transactionCollections.some((t=>t.id==e))){const r=this.transactionCollections.find((t=>t.id==e));if(this.transactionCollections=this.transactionCollections.filter((t=>t.id==e||new Date(t.createdDate).getTime()>(new Date).getTime()-6048e5)),!r)return;t=r.data.concepts.slice(),n=r.data.connections.slice(),It(`starting online sync with ${t.length} concepts and ${n.length} connections`,e),t.length>0&&(It(`sending ${t.length} concepts to backend`,e),yield mt(t),Nt("synced","concepts",t.length,t.length,e)),n.length>0&&(It(`sending ${n.length} connections to backend`,e),yield Ct(n),Nt("synced","connections",n.length,n.length,e)),this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e)),It("online sync complete",e)}else{const e=this.conceptsSyncArray.length,r=this.connectionSyncArray.length;It(`starting online sync with ${e} queued concepts and ${r} queued connections`);for(let t=0;t<this.conceptsSyncArray.length;t++)z.AddConcept(this.conceptsSyncArray[t]),Nt("prepared local cache for","concepts",t+1,e);for(let e=0;e<this.connectionSyncArray.length;e++)pe.AddConnection(this.connectionSyncArray[e]),Nt("prepared local cache for","connections",e+1,r);this.conceptsSyncArray.length>0&&(t=this.conceptsSyncArray.slice(),It(`sending ${t.length} concepts to backend`),yield mt(t),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.some((t=>t.id===e.id)))),Nt("synced","concepts",t.length,t.length)),this.connectionSyncArray.length>0&&(n=this.connectionSyncArray.slice(),It(`sending ${n.length} connections to backend`),yield Ct(n),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!n.some((t=>t.id===e.id)))),Nt("synced","connections",n.length,n.length)),It(`online sync complete; ${this.conceptsSyncArray.length} concepts and ${this.connectionSyncArray.length} connections remain queued`)}return"done"}catch(e){throw e}}))}static initializeTransaction(e){return wt(this,void 0,void 0,(function*(){try{if(this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections.push({id:e,data:{concepts:[],connections:[]},createdDate:(new Date).toISOString()})}catch(e){console.log("error in initializeTransaction",e)}}))}static markTransactionActions(e,t){return wt(this,void 0,void 0,(function*(){try{this.transactionCollections=this.transactionCollections.map((n=>n.id==e?Object.assign(Object.assign({},n),{data:JSON.parse(JSON.stringify(t))}):n)),this.conceptsSyncArray=this.conceptsSyncArray.filter((e=>!t.concepts.some((t=>t.id==e.id||t.ghostId==e.id)))),this.connectionSyncArray=this.connectionSyncArray.filter((e=>!t.connections.some((t=>t.id==e.id||t.ghostId==e.id))))}catch(e){console.log("error in markTransactionActions",e)}}))}static rollbackTransaction(e,t){return wt(this,void 0,void 0,(function*(){try{if(!this.transactionCollections.some((t=>t.id==e)))return;this.transactionCollections=this.transactionCollections.filter((t=>t.id!=e))}catch(e){console.log("LocalSyncData, roll",e)}}))}static syncDataLocalDb(){return wt(this,void 0,void 0,(function*(){if(It(`starting local sync with ${this.conceptsSyncArray.length} queued concepts and ${this.connectionSyncArray.length} queued connections`),this.conceptsSyncArray.length>0){const e=this.conceptsSyncArray.length;for(let t=0;t<this.conceptsSyncArray.length;t++)L("localconcept",this.conceptsSyncArray[t]),Nt("stored locally","concepts",t+1,e);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){const e=this.connectionSyncArray.length;for(let t=0;t<this.connectionSyncArray.length;t++)L("localconnection",this.connectionSyncArray[t]),Nt("stored locally","connections",t+1,e);this.connectionSyncArray=[]}return It("local sync complete"),"done"}))}}function Et(e,t){const n=Number(e);if(!Number.isFinite(n)||n<=0)throw new Error(`Cannot create a connection: ${t} must be a positive finite number. Received ${JSON.stringify(e)}.`);return n}function St(e){return e||(a.DEFAULT_USER_ID?a.DEFAULT_USER_ID:999)}At.conceptsSyncArray=[],At.connectionSyncArray=[],At.transactionCollections=[];var Rt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function kt(e,t,n,r,o,i,c){return Rt(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s=1,a=4,l=999,u={concepts:[],connections:[]}){const d=function(e,t){const n=Et(e,"ofTheConceptId"),r=Et(t,"toTheConceptId");if(n===r)throw new Error(`Cannot create a self-connection for concept ${n}.`);return{ofTheConceptId:n,toTheConceptId:r}}(e,n);e=d.ofTheConceptId,n=d.toTheConceptId;let h=t,f=t,p=t;999!=l&&(p=l);let y=t,v=t,g=yield vt.getId(),m=new se(g,e,n,t,r,p,o,f,s,h,0,y,a,v,i,c);return m.toUpdate=!0,m.isTemp=!1,At.AddConnection(m),u.connections.push(m),m}))}function xt(e,t,n){return Rt(this,arguments,void 0,(function*(e,t,n,r={concepts:[],connections:[]}){let o=St(e.userId),i=yield nt(n);return yield kt(e.id,e.userId,t.id,t.userId,i.id,999,999,1e3,4,o,r)}))}var bt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const $t=new Map;function Lt(e,t){return bt(this,void 0,void 0,(function*(){let n=yield z.GetConceptByCharacterAndTypeLocal(e,t),r=e+t;if($t.has(r))return $t.get(r)||n;const o=(()=>bt(this,void 0,void 0,(function*(){try{if(null==n||0==n.id){var o={character_value:`${e}`,type_id:t},i=JSON.stringify(o),c=yield ee();const r=yield C(s.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:i});if(r.ok){let e=yield r.json();n=e,z.AddConcept(n)}else console.log("This is the concept by type and character error",r.status),re(r)}return n}catch(e){throw e instanceof Error?console.log(" This is the concept by type and character error message: ",e.message):console.log(" This is the concept by type and character unexpected error: ",e),e}finally{$t.delete(r)}})))();return $t.set(r,o),o}))}function _t(e){return bt(this,void 0,void 0,(function*(){let t=[],n=JSON.stringify(e);var r=yield ee();const o=yield C(s.GetConceptConnectionByType(),{method:"POST",headers:r,body:n});if(o.ok){let e=yield o.json();t=yield ve(e)}else console.log("This is the concept by type and character error",o.status),re(o);return t}))}var Pt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ot(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return Pt(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p={concepts:[],connections:[]}){var y=yield yt.getId();let v=new Date,g=new Date;var m=new M(y,t,o,i,n,r,c,s,e,a,l,u,d,h,f,!0,v,g);return m.isTemp=!1,At.AddConcept(m),p.concepts.push(m),m}))}function Ut(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return Pt(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s,a,l,u,d,h,f,p={concepts:[],connections:[]}){var y=yield yt.getId();let v=new Date,g=new Date;var m=new M(y,t,o,i,n,r,c,s,e,a,l,u,d,h,f,!1,v,g);return z.AddConcept(m),m.updateRecursion=!0,At.AddConcept(m),p.concepts.push(m),m}))}var Bt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Dt(e,t){return Bt(this,arguments,void 0,(function*(e,t,n=!1,r,o,i=999,c=0,s={concepts:[],connections:[]}){let a,l=i,u=r=St(r),d=r,h=o,f=r,p=e.startsWith("the_")?e:"the_"+e,y=H();return n?(y=yield nt(e),a=yield Ot(t,r,4,r,y.id,y.userId,c,999,999,u,h,f,l,d,s)):(y=yield nt(p),a=yield Lt(t,y.id),0==a.id&&0==a.userId&&(a=yield Ut(t,r,4,r,y.id,y.userId,c,999,999,u,h,f,l,d,s))),a.type=y,a}))}var Ft=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Gt(e){return Ft(this,arguments,void 0,(function*(e,t=null,n=null,r=null,o=null,i=null,c=null){var s=null!=o?o:999,a=null!=i?i:4,l=null!=c?c:999,u=null!=r?r:0,d=H();for(const r in e)if("string"!=typeof e[r]&&"number"!=typeof e[r])if(null==t&&null==n){var h=u;d=y=yield Dt(r,"",!0,s,a,l),h=y.id,u=y.id,yield Gt(e[r],y.id,y.userId,h,o,i,c)}else{var f=null!=t?t:999,p=null!=n?n:999;h=u,d=y=yield Dt(r,"",!0,s,a,l),yield kt(f,p,y.id,y.userId,h,l,y.userId),yield Gt(e[r],y.id,y.userId,h,o,i,c)}else{f=null!=t?t:999,p=null!=n?n:10267,h=u;var y=yield Dt(r,e[r].toString(),!1,s,a,l);yield kt(f,p,y.id,y.userId,h,l,y.userId)}return d}))}var jt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Vt(e,t,n){return jt(this,arguments,void 0,(function*(e,t,n,r=10,o=1){let i=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("ofTheConceptId",`${t}`),c.append("userId",`${n}`),c.append("inpage",`${r}`),c.append("page",`${o}`);var a=yield ee("application/x-www-form-urlencoded");const l=yield C(s.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:a,body:c});return l.ok?i=yield l.json():(console.log("Get connection of concept error",l.status),re(l)),i}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Mt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Ht=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Wt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Kt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Xt(e){return Kt(this,void 0,void 0,(function*(){var t=yield pe.GetConnection(e);if((null==t||0==t.id)&&null!=e&&null!=e){var n=yield function(e){return Wt(this,void 0,void 0,(function*(){var t=yield pe.GetConnection(e);try{if(0!=t.id)return t;{var n=yield ee("application/x-www-form-urlencoded");const r=yield C(s.GetConnectionUrl(),{method:"POST",headers:n,body:`id=${e}`});return r.ok?(t=yield r.json(),pe.AddConnection(t)):(console.log("Get Connection Error",r.status),re(r)),t}}catch(e){throw e instanceof Error?console.log("Get Connection error message: ",e.message):console.log("Get Connection unexpected error: ",e),e}}))}(e);t=n}return t}))}var qt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function zt(e){return qt(this,arguments,void 0,(function*(e,t=""){let n=!1;var r=yield Xt(e);return n=yield function(e){return Ht(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let r=yield yield te("",t),o=yield{Authorization:r.Authorization,Accept:"application/json"};const i=new URLSearchParams;i.append("id",e.toString()),i.append("apiKey","nodeserver");const c=yield C(s.DeleteTheConnectionUrl(),{method:"POST",headers:o,body:i,redirect:"follow"});c.ok?n=(yield c.json()).success:(console.log("Delete connection error status: ",c.status),re(c))}catch(e){throw e instanceof Error?console.log("Delete connection error message: ",e.message):console.log("Delete connection unexpected error: ",e),e}return n}))}(e,t),O("connection",e),ue.removeNodeFromTree(e),he.removeTypeConcept(r.typeId,e),n}))}function Jt(e){return qt(this,void 0,void 0,(function*(){let t=yield function(e){return Mt(this,void 0,void 0,(function*(){let t=!1;try{let n=yield te();const r=yield C(s.DeleteTheConnectionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});r.ok?t=(yield r.json()).success:(console.log("Delete connection Bulk Api error status: ",r.status),re(r))}catch(e){e instanceof Error?console.log("Delete connection Bulk Api error message: ",e.message):console.log("Delete connection Bulk Api unexpected error: ",e)}return t}))}(e);if(t)for(let t=0;t<e.length;t++){let n=e[t];n>0&&ue.removeNodeFromTree(n)}return t}))}var Yt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Qt(e){return Yt(this,arguments,void 0,(function*(e,t=999){var n=H();if(e<0)return po(yield to(t,e));if(null!=(n=yield z.GetConcept(e))&&0!=n.id||null==e||null==e||(n=yield Se(e)),0!=n.id&&null==n.type&&null!=n.typeId&&null!=n.typeId){var r=yield z.GetConcept(n.typeId);if(0!=r.id)n.type=r;else{var o=yield Se(n.typeId);0!=o.id&&(n.type=o)}}return n}))}var Zt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const en=999,tn=4,nn=999,rn=999,on=1e3;function cn(e){const t=`${null!=e?e:""}`.trim();if(0===t.length)throw new Error("Cannot create a typed connection without a linker name.");return t}function sn(e,t){return Zt(this,void 0,void 0,(function*(){var n,r,o;if(null==e||null==e.id||0===e.id)throw new Error(`Cannot create a typed connection: ${t} must be a persisted concept.`);const i=e.type;if(null===(n=null==i?void 0:i.characterValue)||void 0===n?void 0:n.trim())return i.characterValue.trim();const c=(yield Qt(e.id,e.userId)).type;if(null===(r=null==c?void 0:c.characterValue)||void 0===r?void 0:r.trim())return e.type=c,c.characterValue.trim();if(null!=e.typeId&&0!==e.typeId){const t=yield Qt(e.typeId,e.typeUserId);if(0!==t.id&&(null===(o=t.characterValue)||void 0===o?void 0:o.trim()))return e.type=t,t.characterValue.trim()}throw new Error(`Cannot create a typed connection: ${t} concept ${e.id} has no resolvable type.`)}))}function an(e){return Zt(this,void 0,void 0,(function*(){return yield Dt("connection",e,!1,en,en,nn)}))}function ln(e,t,n){return Zt(this,void 0,void 0,(function*(){return yield kt(e.id,e.userId,t.id,t.userId,n.id,nn,rn,on,tn)}))}function un(e,t,n){return Zt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){const i=cn(n),c=e.userId;if(r){const n=yield function(e,t){return Zt(this,void 0,void 0,(function*(){return`${yield sn(e,"toTheConcept")}_s_${t}_by`}))}(t,i);o&&(yield hn(`${i}_by`,t,c));const r=yield an(n);yield ln(t,e,r)}const s=yield function(e,t){return Zt(this,void 0,void 0,(function*(){return`${yield sn(e,"ofTheConcept")}_s_${t}_s`}))}(e,i);o&&(yield hn(`${i}_s`,e,c));const a=yield an(s);return yield ln(e,t,a)}))}function dn(e,t,n){return Zt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){return yield un(e,t,n,r,o)}))}function hn(e,t){return Zt(this,arguments,void 0,(function*(e,t,n=null){for(var r=t,o=null!=n?n:t.userId,i=999,c=cn(e)+"_count",s=(yield sn(t,"concept"))+"_s_"+c,a=yield Dt("connection",s,!1,o,4,i),l=yield Vt(a.id,t.id,o,10,1),u=[],d=H(),h=0;h<l.length;h++){let e=yield Qt(l[h].toTheConceptId);u.push(e)}if(u.length<1)d=yield Dt("count","1",!1,o,4,i);else{var f=u[0];let e=Number(f.characterValue),t=Number.isFinite(e)?e+1:1;d=yield Dt("count",t.toString(),!1,o,4,i);for(let e=0;e<l.length;e++)yield zt(l[e].id)}yield kt(r.id,r.userId,d.id,d.userId,a.id,i,rn,on,4,o)}))}function fn(e,t,n){return Zt(this,arguments,void 0,(function*(e,t,n,r=!1,o=!1){return yield un(e,t,n,r,o)}))}var pn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function yn(e){return encodeURIComponent(String(e))}function vn(e,t){return pn(this,arguments,void 0,(function*(e,t,n=("number"==typeof e?999:e.userId),r=("number"==typeof e?4:e.accessId),o=999){const i="number"==typeof e?e:e.id,c="number"==typeof e?n:e.userId,a=yield ee("application/x-www-form-urlencoded"),l=[`character_value=${yn(t)}`,`type_id=${yn(i)}`,`type_user_id=${yn(c)}`,`access_id=${yn(r)}`,`session_information_id=${yn(o)}`].join("&"),u=yield C(s.CreateTypeConceptUrl(),{method:"POST",headers:a,body:l});if(!u.ok)throw re(u),new Error(`Error! status: ${u.status}`);const d=yield u.json();return"number"!=typeof e&&(d.type=e),z.AddConcept(d),d}))}var gn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function mn(e,t){return gn(this,arguments,void 0,(function*(e,t,n=10,r=1){var o,i=[],c=yield Qt(e),s=(null===(o=c.type)||void 0===o?void 0:o.characterValue)+"_s_"+t,a=yield Lt(s,16);if(a.id>0){for(var l=yield Vt(a.id,c.id,c.userId,n,r),u=[],d=0;d<l.length;d++)u.push(l[d].toTheConceptId);yield Ne(u),i=yield Promise.all(l.map((e=>gn(this,void 0,void 0,(function*(){let t=yield Qt(e.toTheConceptId);return yield Oe(t.id)})))))}return i}))}function Cn(e,t){return gn(this,arguments,void 0,(function*(e,t,n=10,r=1){var o,i=[],c=yield Qt(e),s=(null===(o=c.type)||void 0===o?void 0:o.characterValue)+"_s_"+t,a=yield Lt(s,16);if(a.id>0){for(var l=yield Vt(a.id,c.id,c.userId,n,r),u=[],d=0;d<l.length;d++)u.push(l[d].toTheConceptId);i=yield Promise.all(l.map((e=>Qt(e.toTheConceptId))))}return i}))}class wn{constructor(e,t,n,r,o,i,c,s=!1,a,l,u,d=999){this.isComposition=!1,this.isTemp=!1,this.applicationId=999,this.id=e,this.userId=t,this.typeId=n,this.ghostId=e,this.categoryId=r,this.characterValue=i,this.accessId=o,this.type=null,this.isNew=s,this.typeCharacter=c,this.entryTimeStamp=a,this.updatedTimeStamp=l,this.referentId=u,this.applicationId=d}getType(){console.log(this.typeId)}}function Tn(){let e=new Date,t=new Date;return new wn(0,0,0,0,0,"0","0",!1,e,t,0)}class In{constructor(e,t,n,r,o,i,c,s,a,l){this.id=0,this.isNew=!1,this.userId=e,this.data=`${t}`,this.securityId=n,this.securityUserId=r,this.accessId=o,this.accessUserId=i,this.sessionId=c,this.sessionUserId=s,this.isNew=l}}class Nn{constructor(){this.name="character Repository"}static AddCharacter(e){this.characterData[e.id]=e}static GetCharacter(e){for(var t=new In(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==e&&(t=this.characterData[n]);return t}}Nn.characterData=[];class An{constructor(e,t,n,r){this.id=e,this.userId=t,this.referentId=n,this.isNew=r}}var En=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},Sn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Rn(e,t,n,r,o){return Sn(this,void 0,void 0,(function*(){return new In(t,e,n,t,r,t,o,t,"",!1),yield function(){return En(this,void 0,void 0,(function*(){var e;try{if(0==(e=Nn.GetCharacter(e.data)).id){var t=yield ee();const r=yield C(s.CreateTheCharacterDataUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!r.ok)throw re(r),new Error(`Error! status: ${r.status}`);const o=yield r.json();var n=new In(o.userId,e.data,0,0,4,4,999,999,"",!1);return n.id=o.id,Nn.AddCharacter(n),o}return new An(e.id,e.userId,0,!1)}catch(e){throw e instanceof Error?console.log("create the character error message: ",e.message):console.log("create the character unexpected error: ",e),e}}))}()}))}var kn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function xn(e,t,n,r,o,i,c,s,a,l,u,d,h,f){return kn(this,void 0,void 0,(function*(){var p=yield Lt(e,o),y=p;return 0==y.id&&(y=p=yield Ot(e,t,n,r,o,i,c,s,a,l,u,d,h,f)),y}))}var bn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},$n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ln(e,t,n,r){return $n(this,arguments,void 0,(function*(e,t,n,r,o={concepts:[],connections:[]}){var i=yield He(e);if(i&&(0==i.id||0==i.userId)){var c=Q(e);if(c.length>0)if(c[0]==e){var s=yield function(e,t,n,r,o,i){return bn(this,void 0,void 0,(function*(){var o,c=t,s=t;o=t;var a,l=t,u=t,d=t;if(1==e.length){var h=e.charCodeAt(0);yield Rn(e,t,n,r,i),a=yield xn(e,t,4,c,49,l,h,d,n,s,r,o,i,u)}else{var f=yield Rn(e,t,n,r,i);f.isNew,a=yield xn(e,t,4,c,51,l,f.id,f.userId,n,s,r,o,i,u)}return a}))}(e,r,999,999,0,t);i=s}else{var a=yield Ln(c[0],t,n,r,o),l=yield Ln(c[1],t,n,r,o);l&&(i=yield Ut(e,r,a.id,r,l.id,r,999,r,999,r,999,r,t,r,o))}}return i}))}var _n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Pn(e){return _n(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=yield ee("application/x-www-form-urlencoded");const i=new URLSearchParams({conceptId:String(e)}),c=yield C(`${s.GetAllLinkerConnectionOfConceptUrl()}?${i.toString()}`,{method:"GET",headers:n});if(c.ok){const e=yield c.json();for(var r=0;r<e.length;r++){var o=e[r];t.push(o)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),re(c);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection from the concepts error: ",e.message):console.log("Get all linker connection from the concepts error(Unexpected): ",e),e}}))}var On=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Un(e){return On(this,void 0,void 0,(function*(){var t=[];try{(new Date).getTime();var n=yield ee("application/x-www-form-urlencoded");const i=new URLSearchParams({conceptId:String(e)}),c=yield C(`${s.GetAllLinkerConnectionToConceptUrl()}?${i.toString()}`,{method:"GET",headers:n});if(c.ok){const e=yield c.json();for(var r=0;r<e.length;r++){var o=e[r];t.push(o)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),re(c);return t}catch(e){throw e instanceof Error?console.log("Get all linker connection To the concepts error: ",e.message):console.log("Get all linker connection To the concepts error(Unexpected): ",e),e}}))}var Bn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Dn(e){return Bn(this,void 0,void 0,(function*(){for(var t=yield Pn(e),n=0;n<t.length;n++){let e=t[n];var r=e.typeId;let o=yield Qt(r);e.type=o}return t}))}function Fn(e){return Bn(this,void 0,void 0,(function*(){for(var t=yield Un(e),n=0;n<t.length;n++){let e=t[n];var r=e.typeId;let o=yield Qt(r);e.type=o}return t}))}var Gn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},jn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},Vn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Mn(e){return Vn(this,arguments,void 0,(function*(e,t=""){var n=yield Qt(e);yield V.removeNodeFromTree(e);var r=n.typeId,o=n.characterValue;yield X.removeTypeConcept(r,e),yield G.removeNodeByCharacter(o,e),O("concept",e);let i=yield function(e){return Gn(this,arguments,void 0,(function*(e,t=""){let n=!1;try{let r=yield yield yield te("application/x-www-form-urlencoded",t);const o=new FormData;o.append("id",e.toString()),o.append("apiKey","nodeserver");const{"Content-Type":i}=r,c=jn(r,["Content-Type"]),a=yield C(s.DeleteConceptUrl(),{method:"POST",headers:c,body:o});if(!a.ok)throw re(a),new Error(`Error! status: ${a.status}`);n=(yield a.json()).success}catch(e){throw e instanceof Error?console.log("Delete concept error message: ",e.message):console.log("Delete concept unexpected error: ",e),e}return n}))}(e,t);return i}))}var Hn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Wn(e,t){return Hn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+t);const r=new FormData;r.append("id",e.toString());const o=yield C(s.DeleteConceptUrl(),{method:"POST",body:r,headers:n});if(!o.ok)throw re(o),new Error(`Delete composition Error! status: ${o.status}`)}catch(e){throw e instanceof Error?console.log("Delete composition error message: ",e.message):console.log("Delete composition unexpected error: ",e),e}}))}var Kn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Xn(e,t,n,r){return Kn(this,arguments,void 0,(function*(e,t,n,r,o=999){var i,c=n,s=n,a=n,l=e.startsWith("the_"),u=H();return i=l?e:"the_"+e,u=yield nt(i),yield xn(t,n,4,n,u.id,u.userId,0,999,999,c,r,a,o,s)}))}class qn{constructor(){this.composition=0,this.type="",this.linker="",this.inpage=10,this.page=1,this.listLinkers=[],this.fullLinkers=[],this.textSearch="",this.logic="or",this.reverse=!1,this.doFilter=!1,this.filterSearches=[],this.selectors=[]}}var zn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Jn(){return zn(this,arguments,void 0,(function*(e=[]){var t=[];try{var n=[];for(let r=0;r<e.length;r++){let o=yield pe.GetConnection(e[r]);0==o.id?n.push(e[r]):t.push(o)}if(0==n.length)return t;{var r=yield ee();const e=yield R("/api/get_connection_bulk",{method:"POST",headers:r,body:JSON.stringify(n)});if(e.ok){const n=yield e.json();if(n.length>0){for(let e=0;e<n.length;e++){let r=n[e];t.push(r),pe.AddConnection(r)}yield me(t)}}else console.log("Get Connection Bulk error",e.status),re(e);return t}}catch(e){throw e instanceof Error?console.log("Get Connection Bulk error message: ",e.message):console.log("Get Connection Bulk unexpected error: ",e),e}}))}var Yn=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Qn(){return Yn(this,arguments,void 0,(function*(e=[]){yield Ne(e);var t=[];for(let r=0;r<e.length;r++){var n=yield _e(e[r]);t.push(n)}return t}))}function Zn(){return Yn(this,arguments,void 0,(function*(e=[]){yield Ne(e);var t=[];for(let r=0;r<e.length;r++){var n=yield Pe(e[r]);t.push(n)}return t}))}function er(){return Yn(this,arguments,void 0,(function*(e=[],t=[]){yield Jn(t),function(e=[],t=[]){for(let n=0;n<t.length;n++)e.includes(t[n].id)||pe.RemoveConnection(t[n])}(t,yield we(e));var n=[];for(let t=0;t<e.length;t++){var r=yield Pe(e[t]);n.push(r)}return n}))}function tr(){return Yn(this,arguments,void 0,(function*(e=[]){let t=[],n=[],r={};for(let r=0;r<(null==e?void 0:e.length);r++){let o=yield pe.GetConnection(e[r]);0==o.id?t.push(e[r]):n.push(o)}for(let n=0;n<t.length;n++)r[e[n]]=!1;let o=[],i=yield Jn(t);n=[...n,...i];for(let e=0;e<n.length;e++)o.push(n[e].ofTheConceptId),o.push(n[e].toTheConceptId),o.push(n[e].typeId);return yield ve(o),n}))}function nr(){return Yn(this,arguments,void 0,(function*(e=[],t=[]){let n=[],r=[];for(let e=0;e<t.length;e++){let o=yield pe.GetConnection(t[e]);0==o.id?n.push(t[e]):r.push(o)}let o=yield Jn(n);for(let e=0;e<o.length;e++)r.push(o[e]);let i={},c=[];for(var s=0;s<r.length;s++)c.includes(r[s].ofTheConceptId)||c.push(r[s].ofTheConceptId);for(let t=0;t<e.length;t++){let n=yield Be(e[t],r,c);i[e[t]]=n}return i}))}var rr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function or(){return rr(this,arguments,void 0,(function*(e=0,t=[],n="",r=[]){var o=[];try{var i=new qn;i.composition=e,i.listLinkers=t,i.textSearch=n,i.fullLinkers=r;var c=JSON.stringify(i),a=yield ee();const d=yield C(s.RecursiveSearchUrl(),{method:"POST",headers:a,body:c});if(d.ok){const e=yield d.json();var l=e.compositionIds,u=e.internalConnections;e.externalConnections,o=yield er(l,u)}else console.log("recursive search error ",d.status),re(d);return o}catch(e){throw e instanceof Error?console.log("recursive search error message: ",e.message):console.log("recursive search unexpected error: ",e),e}}))}var ir=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function cr(e,t){return ir(this,void 0,void 0,(function*(){try{var n={email:e,password:t},r=new Headers;r.append("Content-Type","application/json");var o=JSON.stringify(n);const i=yield C(s.LoginUrl(),{method:"POST",headers:r,body:o});if(i.ok){const e=yield i.json();return a.BearerAccessToken=e.data.token,e}console.log("Login tsccs error message: ",i.status),re(i)}catch(e){throw e instanceof Error?console.log("Login tsccs error message: ",e.message):console.log(" Login tsccs unexpected error: ",e),e}}))}var sr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ar(e){return sr(this,void 0,void 0,(function*(){const t=yield function(){return sr(this,arguments,void 0,(function*(e="",t={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const r=yield C(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(t)}),o=yield r.json();return r.ok?n={message:"success",status:!0,statusCode:200,data:o}:re(r),n}catch(e){throw console.log("Signup Error: ",e),e}}))}(s.SignupUrl(),e);return t}))}var lr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ur(e){return lr(this,void 0,void 0,(function*(){const t=JSON.stringify({email:e.email,password:e.password});let n={message:"success",status:!1,statusCode:200,data:""};const r=new Headers;r.append("Content-Type","application/json");const o=s.LoginUrl();try{const e=yield C(o,{method:"POST",headers:r,body:t,redirect:"follow"}),i=yield e.json();return e.ok?n={message:"success",status:!0,statusCode:200,data:null==i?void 0:i.data}:re(e),n}catch(e){throw console.log("Sign in api error",e),e}}))}function dr(e,t){return-1===e.indexOf(t)&&e.push(t),e}function hr(e=[],t){var n,r;let o=[],i=null===(n=t.type)||void 0===n?void 0:n.characterValue;if((null==i?void 0:i.startsWith("the_"))||(i="the_"+i),Array.isArray(e))for(let n=0;n<e.length;n++){let c=null===(r=e[n].type)||void 0===r?void 0:r.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),t.typeId!=e[n].typeId&&i!=c||o.push(e[n])}return o}function fr(e=[],t){let n=[];if(Array.isArray(e)){const r=e.find((e=>e.toTheConceptId==t));r&&n.push(r);const o=e.find((e=>e.ofTheConceptId==t));o&&n.push(o)}return n}function pr(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}function yr(e=[],t){Array.isArray(e)&&e.splice(e.findIndex((function(e){return e.id===t.id})),1)}class vr{constructor(e,t,n,r){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r}isValid(){const e=new Date(Date.now());return!(this.expiryTime<e&&(mr.removeNodeFromTree(this.key),1))}saveToCache(e){this.value.cached=e}addNode(e,t,n){if(null==t)return e;const r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return this.isValid(),e;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));const i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return this.isValid(),t}rightRotate(e){if(e){const t=e.leftNode;if(t){const n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){const t=e.rightNode;if(t){const n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key&&t.isValid()?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){const t=e.rightNode;return e=null,t}if(null==e.rightNode){const t=e.leftNode;return e=null,t}{const t=this.inOrderSuccessor(e.rightNode);return e.value=t.value,e.key=t.key,e.rightNode=this.removeNode(e.rightNode,t.key),e}}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var gr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class mr{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addCompositionToTree(e){const t=new vr(e.id,e,null,null);this.addNodeToTree(t)}static getNodeFromTree(e){return gr(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static removeNodeFromTree(e){return gr(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}mr.root=null;var Cr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function wr(e,t,n,r){return Cr(this,arguments,void 0,(function*(e,t,n,r,o=[]){var i,c;let s={};const a=[];if(0==e)return"";let l=Tr(n,e);if(null!=l&&0!=l.id||null==e||null==e||(l=yield Qt(e)),0!=l.id&&null==l.type){const e=l.typeId;let t=Tr(n,e);l.type=t,null==t&&null!=e&&null!=e&&(t=yield Qt(e),l.type=t)}if(!r.includes(e))return null==l?void 0:l.characterValue;if(o.includes(e))return"";o.push(e);for(let l=0;l<t.length;l++)if(t[l].ofTheConceptId==e){const u=t[l].toTheConceptId;if(r.includes(e)){let e=Tr(n,u);if(null!=e&&0!=e.id||null==u||null==u||(e=yield Qt(u)),0!=e.id&&null==(null==e?void 0:e.type)){const t=e.typeId;let n=yield z.GetConcept(t);e.type=n,null==n&&null!=t&&null!=t&&(n=yield Qt(t),e.type=n)}const l="the_",d=(null!==(c=null===(i=null==e?void 0:e.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(d))){if(d){const e=yield wr(u,t,n,r,o);s[d]=e}}else{const e=yield wr(u,t,n,r,o);a[d]=e,s=a}}}return s}))}function Tr(e,t){let n=H();for(let r=0;r<e.length;r++)if(t==e[r].id)return n=e[r],n;return n}class Ir{constructor(){this.id=0,this.mainConcept=H(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return e=this,t=void 0,r=function*(){if(0==this.mainConcept.id)for(let e=0;e<this.concepts.length;e++)this.concepts[e].id==this.id&&(this.mainConcept=this.concepts[e]);this.cached=yield wr(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}));var e,t,n,r}UpdateAcrossDistributedSystem(){var e,t;try{0!=this.id&&(t=null===(e=this.id)||void 0===e?void 0:e.toString(),s.MQTT_CONNECTION&&s.MQTT_CONNECTION.publish("compositionUpdate",t))}catch(e){console.log("Error while publishing message",e)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var e,t,n;const r={};r[null!==(n=null===(t=null===(e=this.mainConcept)||void 0===e?void 0:e.type)||void 0===t?void 0:t.characterValue)&&void 0!==n?n:""]=this.cached;const o={};return o.data=r,o.id=this.id,o}}var Nr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ar(e){return Nr(this,arguments,void 0,(function*(e,t=null,n=null,r=null,o=null,i=null,c=null,s=null){const a=null!=o?o:999,l=null!=i?i:4,u=null!=c?c:999;let d=null!=r?r:0,h=H();null==s&&(s=new Ir);for(const r in e)if("object"==typeof e[r]||Array.isArray(e[r])){const f=yield Dt(r,"",!0,a,l,u);if(null==t&&null==n){let t=d;h=f,t=f.id,d=f.id,s.concepts.push(f),s.id=f.id,yield Ar(e[r],f.id,f.userId,t,o,i,c,s)}else{const a=null!=t?t:999,l=null!=n?n:999,p=d;h=f,s.concepts.push(f);const y=yield kt(a,l,f.id,f.userId,p,u,f.userId);s.connections.push(y),yield Ar(e[r],f.id,f.userId,p,o,i,c,s)}null!=e[r]&&null!=e[r]&&s.subcompositions.push(f.id)}else{const o=null!=t?t:999,i=null!=n?n:999,c=d,h=yield Dt(r,e[r],!1,a,l,u);s.concepts.push(h);const f=yield kt(o,i,h.id,h.userId,c,u,h.userId);s.connections.push(f)}return h}))}var Er=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Sr(e){return Er(this,void 0,void 0,(function*(){try{const t=yield ee(),n=yield C(s.GetConnectionsBetweenUrl(),{method:"POST",headers:t,body:JSON.stringify(e)});if(!n.ok)throw console.log("GetConnectionsBetweenApi error status: ",n.status),re(n),new Error(`GetConnectionsBetweenApi error: ${n.status}`);return yield n.json()}catch(e){throw e instanceof Error?console.log("GetConnectionsBetweenApi error message: ",e.message):console.log("GetConnectionsBetweenApi unexpected error: ",e),e}}))}function Rr(e){var t,n,r,o,i,c,s;return{ofTheConceptId:null!==(t=e.ofTheConceptId)&&void 0!==t?t:0,toTheConceptId:null!==(n=e.toTheConceptId)&&void 0!==n?n:0,typeId:null!==(r=e.typeId)&&void 0!==r?r:0,type:null!==(o=e.type)&&void 0!==o?o:"",oldType:null!==(i=e.oldType)&&void 0!==i?i:"",reverse:null!==(c=e.reverse)&&void 0!==c&&c,isComposition:null!==(s=e.isComposition)&&void 0!==s&&s,connectionIds:[]}}var kr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class xr{constructor(){this.actions={concepts:[],connections:[]},this.success=!0,this.pendingConnectionDeletions=[],this.transactionId=Math.random().toString().substring(5)}initialize(){return kr(this,void 0,void 0,(function*(){yield At.initializeTransaction(this.transactionId)}))}markAction(){return kr(this,void 0,void 0,(function*(){yield At.markTransactionActions(this.transactionId,this.actions)}))}rollbackTransaction(){return kr(this,void 0,void 0,(function*(){this.success=!1,this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],yield At.rollbackTransaction(this.transactionId,this.actions)}))}commitTransaction(){return kr(this,void 0,void 0,(function*(){if(!this.success)throw Error("Query Transaction Expired");yield At.SyncDataOnline(this.transactionId),this.pendingConnectionDeletions.length>0&&(yield Jt(this.pendingConnectionDeletions)),this.actions={concepts:[],connections:[]},this.pendingConnectionDeletions=[],this.success=!1}))}DeleteConnectionsBetween(e){return kr(this,void 0,void 0,(function*(){return this.DeleteConnectionsBetweenBulk([e])}))}DeleteConnectionsBetweenBulk(e){return kr(this,arguments,void 0,(function*(e,t=[]){try{if(!this.success)throw Error("Query Transaction Expired");const n=[...t];if(e.length>0){const t=e.map(Rr),r=yield Sr(t);for(const e of r)n.push(...e.connectionIds)}return this.pendingConnectionDeletions.push(...n),n}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheInstanceConcept(e,t){return kr(this,arguments,void 0,(function*(e,t,n=!1,r,o,i=999,c=0){try{if(!this.success)throw Error("Query Transaction Expired");const s=yield Dt(e,t,n,r,o,i,c,this.actions);return yield this.markAction(),s}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTypeConcept(e,t){return kr(this,arguments,void 0,(function*(e,t,n=("number"==typeof e?999:e.userId),r=("number"==typeof e?4:e.accessId),o=999){try{if(!this.success)throw Error("Query Transaction Expired");return yield vn(e,t,n,r,o)}catch(e){throw console.log(e),this.success=!1,e}}))}CreateConnection(e,t,n){return kr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const r=yield xt(e,t,n,this.actions);return yield this.markAction(),r}catch(e){throw console.log(e),this.success=!1,e}}))}MakeTheTypeConcept(e,t,n,r){return kr(this,void 0,void 0,(function*(){try{if(!this.success)throw Error("Query Transaction Expired");const o=yield Ln(e,t,n,r,this.actions);return yield this.markAction(),o}catch(e){throw console.log(e),this.success=!1,e}}))}CreateTheConnectionGeneral(e,t,n,r,o,i,c){return kr(this,arguments,void 0,(function*(e,t,n,r,o,i,c,s=1,a=4,l=999){try{if(!this.success)throw Error("Query Transaction Expired");const u=yield kt(e,t,n,r,o,i,c,s,a,l,this.actions);return yield this.markAction(),u}catch(e){throw console.log(e),this.success=!1,e}}))}}var br=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function $r(e){return br(this,void 0,void 0,(function*(){const t=e.userId,n=e.sessionId,r=e.accessId;let o=[];const i=[];let c=H(),s=H();const a=[];let l=e.compositionId;const u=e.ofTheCompositionId;let d=[];if(l<0){let e=yield Qt(l,t);if(!(e.id>0))return null;l=e.id}const h=new xr;yield h.initialize();try{o=yield ke(l);const f=[],p=new Ir,y=[];p.id=l,p.isUpdating();let v=[];for(let e=0;e<o.length;e++)dr(y,o[e].ofTheConceptId),dr(f,o[e].ofTheConceptId),dr(f,o[e].toTheConceptId),v.push(o[e].ofTheConceptId);p.subcompositions=y,p.connections=o;for(let e=0;e<f.length;e++){const t=yield Qt(f[e]);l==f[e]&&(c=t),u==f[e]&&(s=t),i.push(t)}const g=e.patchObject;for(const e in g){let o=H();const l=g[e];let u=c;if(s.id>0&&(u=s),Array.isArray(l)||"object"==typeof l){o=yield h.MakeTheInstanceConcept(e,"",!0,c.userId,4,999),p.subcompositions.push(o.id);const t=hr(i,o);for(let e=0;e<t.length;e++)if(t[e].id>0){const n=fr(p.connections,t[e].id);d=d.concat(n),a.push(t[e])}yield Ar(g[e],o.id,o.userId,c.id,c.userId,4,999,p)}else{o=yield h.MakeTheInstanceConcept(e,l,!1,t,r,n);const c=hr(i,o);for(let e=0;e<c.length;e++)if(c[e].id>0){const t=fr(p.connections,c[e].id);d=d.concat(t),a.push(c[e])}}const f=yield h.CreateTheConnectionGeneral(u.id,u.userId,o.id,o.userId,c.id,n,t);i.push(o),p.connections.push(f)}for(let e=0;e<d.length;e++)yr(p.connections,d[e]);d.length>0&&(yield h.DeleteConnectionsBetweenBulk([],d.map((e=>e.id))));for(let e=0;e<a.length;e++)pr(i,a[e]);return p.concepts=p.concepts.concat(i),p.mainConcept=c,p.id=c.id,yield h.commitTransaction(),yield At.SyncDataOnline(),yield p.updateCache(),mr.addCompositionToTree(p),p.GetDataCache()}catch(e){throw yield h.rollbackTransaction(),e}}))}var Lr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function _r(e,t,n,r){return Lr(this,arguments,void 0,(function*(e,t,n,r,o=10,i=1){var c=yield te("application/x-www-form-urlencoded",r),a=new URLSearchParams;a.append("type",e),a.append("search",t),a.append("composition",n),a.append("inpage",o.toString()),a.append("page",i.toString());const l=s.SearchCompositionsUrl()+"?"+a.toString();try{const e=yield C(l,{method:"GET",headers:c});if(e.ok)return yield e.json();re(e)}catch(e){throw e}}))}var Pr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Or(e){return Pr(this,arguments,void 0,(function*(e,t=""){var n=yield te("application/json",t);const r=s.SearchLinkMultipleAll(),o=JSON.stringify(e);try{const e=yield C(r,{method:"POST",headers:n,body:o});if(e.ok)return yield e.json();re(e)}catch(e){throw e}}))}var Ur=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Br(e){return Ur(this,arguments,void 0,(function*(e,t=[]){var n,r;let o=[];const i=[];let c={},s={};const a=[];let l=yield z.GetConcept(e);0==l.id&&null!=e&&null!=e&&(l=yield Se(e));let u=[];u=t.length>0?Dr(e,t):yield ke(e),o=u;for(let e=0;e<o.length;e++)a.includes(o[e].ofTheConceptId)||(a.push(o[e].ofTheConceptId),i.push(o[e].ofTheConceptId)),i.includes(o[e].toTheConceptId)||i.push(o[e].toTheConceptId);return s=yield Fe(e,o,a,[]),c[null!==(r=null===(n=null==l?void 0:l.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=s,0==l.id?"":c}))}function Dr(e,t){const n=[];for(let r=0;r<t.length;r++)t[r].typeId==e&&n.push(t[r]);return n}function Fr(e){return Ur(this,arguments,void 0,(function*(e,t=[]){var n,r;let o={},i=[];const c=[];let s;const a={},l=[];let u=yield z.GetConcept(e);0==u.id&&null!=e&&null!=e&&(u=yield Se(e));let d=[];d=t.length>0?Dr(e,t):yield ke(e),i=d;for(let e=0;e<i.length;e++)l.includes(i[e].ofTheConceptId)||(l.push(i[e].ofTheConceptId),c.push(i[e].ofTheConceptId)),c.includes(i[e].toTheConceptId)||c.push(i[e].toTheConceptId);return s=yield Fe(e,i,l),a[null!==(r=null===(n=null==u?void 0:u.type)||void 0===n?void 0:n.characterValue)&&void 0!==r?r:""]=s,o.created_at=u.entryTimeStamp,o.data=a,o.id=e,0==u.id?"":o}))}function Gr(e,t){return Ur(this,void 0,void 0,(function*(){let n=[];const r=[];n=yield Jn(t);for(let t=0;t<e.length;t++){const o=yield Fr(e[t],n);o&&r.push(o)}return r}))}var jr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Vr(e){return jr(this,void 0,void 0,(function*(){try{var t=yield ee();const n=JSON.stringify(e),r=yield C(s.CreateSessionId(),{method:"POST",headers:t,body:n});return r.ok?r.json():(console.log("Creating session failed",yield r.json()),re(r),null)}catch(e){throw console.log("Creating session failed",e),e}}))}var Mr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Hr(e,t){return Mr(this,void 0,void 0,(function*(){try{var n=yield ee("application/x-www-form-urlencoded");const r=new URLSearchParams;r.append("sessionId",e.toString()),r.append("url",t);const o=yield C(s.CreateSessionVisitUrl(),{method:"POST",headers:n,body:r});return o.ok?o.json():(console.log("Creating session url failed",yield o.json()),re(o),null)}catch(e){throw console.log("Creating session url failed",e),e}}))}var Wr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Kr(e,t,n){return Wr(this,arguments,void 0,(function*(e,t,n,r=10,o=1){let i=[];try{var c=new URLSearchParams;c.append("typeId",`${e}`),c.append("toTheConceptId",`${t}`),c.append("userId",`${n}`),c.append("inpage",`${r}`),c.append("page",`${o}`);var a=yield ee("application/x-www-form-urlencoded");const l=yield C(s.GetAllConnectionsToConceptUrl(),{method:"POST",headers:a,body:c});return l.ok?i=yield l.json():(console.log("Get connection of concept error",l.status),re(l)),i}catch(e){throw e instanceof Error?console.log("Get connection of concept error message: ",e.message):console.log("Get connection of concept unexpected error: ",e),e}}))}var Xr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function qr(e,t){return Xr(this,arguments,void 0,(function*(e,t,n=10,r=1,o=!1){let i=[],c=yield Qt(e),s=yield Qe(t);if(s.id>0){let e=[],t=[];if(o){t=yield Kr(s.id,c.id,c.userId,n,r);let e=[];for(let n=0;n<t.length;n++)e.push(t[n].ofTheConceptId);yield Ne(e);for(let e=0;e<t.length;e++){let n=t[e].ofTheConceptId,r=yield Qt(n),o=yield Oe(r.id);i.push(o)}}else{t=yield Vt(s.id,c.id,c.userId,n,r);for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield Ne(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,r=yield Qt(n),o=yield Oe(r.id);i.push(o)}}}return i}))}function zr(e,t){return Xr(this,arguments,void 0,(function*(e,t,n=10,r=1,o=!1){let i=[],c=yield Qt(e),s=yield Qe(t),a=[],l=[];if(s.id>0){if(o){a=yield Kr(s.id,c.id,c.userId,n,r);for(let e=0;e<a.length;e++)l.push(a[e].ofTheConceptId)}else{a=yield Vt(s.id,c.id,c.userId,n,r);for(let e=0;e<a.length;e++)l.push(a[e].toTheConceptId)}i=yield ve(l)}return i}))}class Jr{constructor(e,t,n){this.value=new Map,this.connectionValue=new Map,this.key=e,t.id>0&&this.value.set(t.ghostId,t),n.id>0&&this.connectionValue.set(n.ghostId,n)}}class Yr{constructor(e=0,t,n,r,o,i,c=999){this.isTemp=!1,this.applicationId=999,this.type=Tn(),this.id=e,this.ofTheConceptId=t,this.toTheConceptId=n,this.typeId=r,this.ghostId=e,this.orderId=o,this.typeCharacter="",this.accessId=i,this.entryTimeStamp=W(new Date),this.terminationDateTime=new Date,this.localSyncTime=new Date,this.applicationId=c}}var Qr=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Zr{static compositeKey(e,t,n=999){return("0000"+e.toString(16).toUpperCase()).slice(-4)+("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+n.toString(16).toUpperCase()).slice(-4)}static waitForDataToLoad(){return Qr(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isDataLoaded)return e("done");setTimeout(Zr.checkFlag,1e3,e)}static addConceptToTree(e,t,n=999){const r=this.compositeKey(t,n,e.applicationId),o=this.nodeMap.get(r);o?e.id>0&&o.value.set(e.ghostId,e):this.nodeMap.set(r,new Jr(r,e,new Yr(0,0,0,0,0,0)))}static addConnectionToTree(e,t,n=999){const r=this.compositeKey(t,n,e.applicationId),o=this.nodeMap.get(r);o?e.id>0&&o.connectionValue.set(e.ghostId,e):this.nodeMap.set(r,new Jr(r,Tn(),e))}static getNodeFromTree(e,t){return Qr(this,arguments,void 0,(function*(e,t,n=999){var r;const o=this.compositeKey(e,t,n);return null!==(r=this.nodeMap.get(o))&&void 0!==r?r:null}))}static removeNodeFromTree(e){return Qr(this,arguments,void 0,(function*(e,t=999,n=999){const r=this.compositeKey(e,t,n);this.nodeMap.delete(r)}))}static countNumberOfNodes(){return this.nodeMap.size}}Zr.nodeMap=new Map;var eo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function to(e,t){return eo(this,arguments,void 0,(function*(e,t,n=999,r=999){var o;let i=yield Zr.getNodeFromTree(e,n,r),c=Tn();return i&&(c=null!==(o=i.value.get(t))&&void 0!==o?o:c),c}))}function no(e,t){return eo(this,arguments,void 0,(function*(e,t,n=999,r=999){var o;let i=yield Zr.getNodeFromTree(e,n,r),c=new Yr(0,0,0,0,0,0);return i&&(c=null!==(o=i.connectionValue.get(t))&&void 0!==o?o:c),c}))}function ro(e,t){return eo(this,arguments,void 0,(function*(e,t,n=999){Zr.addConceptToTree(e,t,n)}))}function oo(e,t){return eo(this,arguments,void 0,(function*(e,t,n=999){Zr.addConnectionToTree(e,t,n)}))}var io=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function co(e){return io(this,arguments,void 0,(function*(e,t=""){var n=yield te("application/json",t);const r=s.SearchLinkMultipleAllApiUrl(),o=JSON.stringify(e);try{const e=yield C(r,{method:"POST",headers:n,body:o});if(e.ok)return yield e.json();re(e)}catch(e){throw e}}))}var so=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function ao(e){return so(this,arguments,void 0,(function*(e,t=""){let n=[],r=yield co(e,t),o=e[0].composition;const i=r;let c=i.compositionIds,s=i.internalConnections,a=i.linkers,l=i.reverse;return n=yield nr(c,s),yield lo(a,n,o,l)}))}function lo(e,t,n){return so(this,arguments,void 0,(function*(e,t,n,r=[]){let o={},i=yield Jn(e);for(let e=0;e<i.length;e++){let n=!1;if(r.includes(i[e].id)&&(n=!0),1==n){if(t[i[e].ofTheConceptId]&&t[i[e].toTheConceptId]){let n=t[i[e].toTheConceptId],r=yield Qt(i[e].typeId),o=null==n?void 0:n.data,c=Object.keys(o)[0];try{let n=r.characterValue+"_reverse";"string"==typeof o&&(o={}),Array.isArray(o[c][n])||("string"==typeof o[c]&&(o[c]={}),o[c][n]=[]),o[c][n].push(t[i[e].ofTheConceptId])}catch(e){}}}else if(t[i[e].ofTheConceptId]&&t[i[e].toTheConceptId]){let n=t[i[e].ofTheConceptId],r=yield Qt(i[e].typeId),o=null==n?void 0:n.data,c=Object.keys(o)[0];try{"string"==typeof o&&(o={}),Array.isArray(o[c][r.characterValue])||("string"==typeof o[c]&&(o[c]={}),o[c][r.characterValue]=[]),o[c][r.characterValue].push(t[i[e].toTheConceptId])}catch(e){}}}return o=t[n],o}))}var uo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},ho=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function fo(e){return ho(this,void 0,void 0,(function*(){var t;let n=yield function(e){return uo(this,void 0,void 0,(function*(){let t=[];try{var n=yield ee();const r=yield C(s.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(e)});if(r.ok){let e=yield r.json(),n={};for(let r=0;r<e.length;r++){let o=e[r].concepts;t=e[r].connections;let i=e[r].id;yield ve(o),n[i]=t}return n}return console.log("View Internal Data error",r.status),re(r),t}catch(e){throw e instanceof Error?console.log(" This is the view internal data error message: ",e.message):console.log(" This is the view internal data unexpected error: ",e),e}}))}(e),r=[];for(let o=0;o<e.length;o++){let i=e[o],c=n[i];if(i&&c){let e=[],t={};for(let t=0;t<c.length;t++)e.includes(c[t].ofTheConceptId)||e.push(c[t].ofTheConceptId);let n=yield Fe(i,c,e);t.data=n,t.id=i,r.push(t)}else{let e={};e.id=i;let n=yield Qt(i),o={};n.type&&(o[null===(t=null==n?void 0:n.type)||void 0===t?void 0:t.characterValue]=n.characterValue,e.data=o,r.push(e))}}return r}))}function po(e){const t=H();return t.id=e.id,t.ghostId=e.ghostId,t.userId=e.userId,t.accessId=e.accessId,t.entryTimeStamp=e.entryTimeStamp,t.typeId=e.typeId,t.categoryId=e.categoryId,t.characterValue=e.characterValue,t}var yo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},vo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function go(e){return vo(this,arguments,void 0,(function*(e,t=""){var n=yield function(e){return yo(this,arguments,void 0,(function*(e,t=""){var n,r,o,i,c,a,l=yield te("application/json",t);const u=new URLSearchParams({composition:String(null!==(n=e.composition)&&void 0!==n?n:""),search:String(null!==(r=e.search)&&void 0!==r?r:""),internalComposition:String(null!==(o=e.internalComposition)&&void 0!==o?o:""),type:String(null!==(i=e.type)&&void 0!==i?i:""),inpage:String(null!==(c=e.inpage)&&void 0!==c?c:""),page:String(null!==(a=e.page)&&void 0!==a?a:"")}),d=`${s.SearchInternalWithAuthenticatedCcsUrl()}?${u.toString()}`;try{const e=yield C(d,{method:"GET",headers:l});if(e.ok)return yield e.json();re(e)}catch(e){throw e}}))}(e,t);return yield fo(n)}))}var mo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Co(e,t){return mo(this,void 0,void 0,(function*(){let n=!0,r=yield Pn(e),o=yield _t(t),i=[];for(let e=0;e<r.length;e++)for(let t=0;t<o.length;t++)r[e].typeId==o[t].id&&i.push(r[e].id);for(let e=0;e<i.length;e++){let t=yield zt(i[e]);n=n&&t}return n}))}function wo(e,t){return mo(this,void 0,void 0,(function*(){let n=yield Pn(e),r=yield _t(t),o=[];for(let e=0;e<n.length;e++)for(let t=0;t<r.length;t++)n[e].typeId==r[t].id&&o.push(n[e].id);return o}))}class To{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class Io{constructor(){this.id="0",this.remote_address="",this.server_port="",this.server_address="",this.server_name="",this.server_software="",this.http_user_agent="",this.self="",this.port="",this.userId="",this.email=""}}class No{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class Ao{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1}}function Eo(e){if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()));if("string"!=typeof e)return[];const t=e.trim();if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter((e=>"string"==typeof e&&""!==e.trim()))}catch(e){}return t.split(",").map((e=>e.trim())).filter(Boolean)}class So{constructor(e){var t;this.aiUrl="https://ai.freeschema.com",this.cacheServerUrl="",this.cacheServers=[],this.accessToken="",this.enableAi=!0,this.enableAccessControl=!1,e&&(Object.assign(this,e),this.cacheServers=Eo(null!==(t=e.cacheServers)&&void 0!==t?t:e.cache_servers),this.cacheServerUrl=e.cacheServerUrl||e.cacheServer||this.cacheServerUrl)}hasOAuthCredentials(){return!(!this.clientId||!this.clientSecret)}hasAccessToken(){return""!==this.accessToken}getFlag(e,t=!1){var n,r;return null!==(r=null===(n=this.flags)||void 0===n?void 0:n[e])&&void 0!==r?r:t}getParameter(e,t=""){var n,r;return null!==(r=null===(n=this.parameters)||void 0===n?void 0:n[e])&&void 0!==r?r:t}setFlag(e,t){this.flags||(this.flags={}),this.flags[e]=t}setParameter(e,t){this.parameters||(this.parameters={}),this.parameters[e]=t}}var Ro=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class ko{constructor(){this.name="Connection Array"}static CheckContains(e){for(var t=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e.id&&(t=!0);return t}static AddConnection(e){this.CheckContains(e)&&this.RemoveConnection(e),(0!=e.id||e.isTemp)&&L("localconnection",e),this.connectionArray.push(e)}static AddToDictionary(e){this.connectionDictionary[e.id]=e}static RemoveConnection(e){for(var t=0;t<this.connectionArray.length;t++)this.connectionArray[t].id==e.id&&this.connectionArray.splice(t,1);e.id}static GetConnection(e){var t;t=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==e&&(t=this.connectionArray[n]);return t}static waitForDataToLoad(){return Ro(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isLocalConnectionLoaded)return e("done");setTimeout(ko.checkFlag,1e3,e)}static GetConnectionsOfCompositionLocal(e){return Ro(this,void 0,void 0,(function*(){var t=[];try{for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==e&&t.push(this.connectionArray[n]);return t}catch(e){return t}}))}getName(){return this.name}}ko.connectionArray=[],ko.connectionDictionary=[];var xo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function bo(){return xo(this,void 0,void 0,(function*(){yield function(){return xo(this,void 0,void 0,(function*(){var e=yield P("connection");if(Array.isArray(e))for(var t=0;t<e.length;t++)pe.AddConnectionToMemory(e[t])}))}()}))}function $o(){return xo(this,void 0,void 0,(function*(){yield function(){return xo(this,void 0,void 0,(function*(){var e=yield U("localconnection");if(Array.isArray(e))for(var t=0;t<e.length;t++)ko.AddConnection(e[t])}))}()}))}class Lo{constructor(e,t,n,r){this.variants=[],this.height=1,this.key=e,this.value=t,this.leftNode=n,this.rightNode=r,this.currentNode=null}addCurrentNode(e,t){return null==t?t=e:(e.value.typeId!=t.value.typeId&&(t.currentNode=this.addCurrentNode(e,t.currentNode)),t)}addCurrentNodeType(e,t){if(null==t)return e;var n=!1;for(let r=0;r<t.variants.length;r++)t.variants[r].value.id==e.value.id&&(n=!0);return n||t.variants.push(e),t}addNode(e,t,n){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addNode(e,r,n);else{if(!(t.key<e.key))return t;t.rightNode=this.addNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}return t}addCharacterNode(e,t,n){if(""!=e.value.characterValue){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addCharacterNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&""!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addCharacterNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}addTypeNode(e,t,n){if(0!=e.value.typeId){if(null==t)return e;var r=t.leftNode,o=t.rightNode;if(t.key>e.key)t.leftNode=this.addTypeNode(e,r,n);else{if(!(t.key<e.key))return t.key==e.key&&0!=t.key&&t.value.id!=e.value.id&&t.addCurrentNodeType(e,t),t;t.rightNode=this.addTypeNode(e,o,n)}t.height=1+Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode));let i=this.getBalanceFactor(t);if(i>1&&t.leftNode){if(e.key<t.leftNode.key)return this.rightRotate(t);if(e.key>t.leftNode.key)return t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)}if(i<-1&&t.rightNode){if(e.key>t.rightNode.key)return this.leftRotate(t);if(e.key<t.rightNode.key)return t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)}}return t}rightRotate(e){if(e){let t=e.leftNode;if(t){let n=t.rightNode;return e.leftNode=n,t.rightNode=e,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}leftRotate(e){if(e){let t=e.rightNode;if(t){let n=t.leftNode;return t.leftNode=e,e.rightNode=n,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,t}}return e}getHeight(e){return e?e.height:0}getBalanceFactor(e){return null==e?0:this.getHeight(e.leftNode)-this.getHeight(e.rightNode)}getFromNode(e,t){return t?e==t.key?t:e<t.key?this.getFromNode(e,t.leftNode):e>t.key?this.getFromNode(e,t.rightNode):t:t}getCharacterFromNode(e,t){return t?e==t.key?t:e<t.key?this.getCharacterFromNode(e,t.leftNode):e>t.key?this.getCharacterFromNode(e,t.rightNode):t:t}getFromNodeWithCharacterAndType(e,t,n){if(e=`${e}`,n){if(e==n.key){if(e==n.value.characterValue&&t==n.value.typeId)return n;for(let e=0;e<n.variants.length;e++)if(n.variants[e].value.typeId==t)return n.variants[e]}else{if(e<n.key)return this.getFromNodeWithCharacterAndType(e,t,n.leftNode);if(e>n.key)return this.getFromNodeWithCharacterAndType(e,t,n.rightNode)}return null}return n}removeNode(e,t){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNode(e.leftNode,t),e;if(e.key<t)return e.rightNode=this.removeNode(e.rightNode,t),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var n=this.inOrderSuccessor(e.rightNode);return e.value=n.value,e.key=n.key,e.variants=n.variants,e.currentNode=n.currentNode,e.rightNode=this.removeNode(e.rightNode,n.key),e}removeNodeWithVariants(e,t,n){if(null==e)return e;if(e.key>t)return e.leftNode=this.removeNodeWithVariants(e.leftNode,t,n),e;if(e.key<t)return e.rightNode=this.removeNodeWithVariants(e.rightNode,t,n),e;if(e.variants.length>0)if(e.value.id==n){var r=e.variants[0];if(r)return e.value=r.value,e.key=r.key,e.currentNode=r.currentNode,e.variants.splice(0,1),e}else for(let t=0;t<e.variants.length;t++)if(n==e.variants[t].value.id)return e.variants.splice(t,1),e;if(null==e.leftNode){let t=e.rightNode;return e=null,t}if(null==e.rightNode){let t=e.leftNode;return e=null,t}var o=this.inOrderSuccessor(e.rightNode);return e.value=o.value,e.key=o.key,e.variants=o.variants,e.currentNode=o.currentNode,e.rightNode=this.removeNodeWithVariants(e.rightNode,o.key,n),e}countNodeBelow(e){return null==e?0:1+this.countNodeBelow(e.leftNode)+this.countNodeBelow(e.rightNode)}inOrderSuccessor(e){for(;null!=e.leftNode;)e=e.leftNode;return e}}var _o=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Po{static addNodeToTree(e){if(null==this.root)return this.root=e,this.root;this.root=this.root.addNode(e,this.root,this.root.height)}static addConceptToTree(e){var t=new Lo(e.id,e,null,null);new Lo(e.characterValue,e,null,null),this.addNodeToTree(t)}static waitForDataToLoad(){return _o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isLocalDataLoaded)return e("done");setTimeout(Po.checkFlag,1e3,e)}static getNodeFromTree(e){return _o(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(e,this.root):null}))}static getCharacterAndTypeFromTree(e,t){return this.root?this.root.getFromNodeWithCharacterAndType(e,t,this.root):this.root}static removeNodeFromTree(e){return _o(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,e))}))}}Po.root=null;var Oo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Uo{static waitForDataToLoad(){return Oo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isLocalCharacterLoaded)return e("done");setTimeout(Uo.checkFlag,1e3,e)}static addNodeToTree(e){return Oo(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=e,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(e,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(e){if(""!=e.characterValue){var t=new Lo(e.characterValue,e,null,null);this.addNodeToTree(t)}}static getNodeFromTree(e){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(e,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(e,t){return Oo(this,void 0,void 0,(function*(){return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(e,t,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(e,t){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,e,t))}}Uo.LocalCharacterRoot=null;var Bo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Do{static addNodeToTree(e){return Bo(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=e,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(e,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(e){if(0!=e.typeId){var t=new Lo(e.typeId,e,null,null);this.addNodeToTree(t)}}static removeConceptType(e,t){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,e,t))}static getNodeFromTree(e){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(e,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(e){var t=this.getNodeFromTree(e),n=[];if(t){n.push(null==t?void 0:t.value);for(let e=0;e<t.variants.length;e++)n.push(t.variants[e].value);return n}}static waitForDataToLoad(){return Bo(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.checkFlag(e),setTimeout((()=>{t("not")}),25e3)}))}))}static checkFlag(e){if(B.isLocalTypeLoaded)return e("done");setTimeout(Do.checkFlag,1e3,e)}static getTypeVariantsFromTreeWithUserId(e,t){return Bo(this,void 0,void 0,(function*(){var n=[],r=this.getNodeFromTree(e);if(r){r.value.userId==t&&n.push(null==r?void 0:r.value);for(let e=0;e<r.variants.length;e++)r.variants[e].value.userId==t&&n.push(r.variants[e].value)}return n}))}}Do.LocalTypeRoot=null;var Fo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Go{constructor(){this.name="conceptsArray"}static AddConcept(e){e.id>0&&(L("localconcept",e),Po.addConceptToTree(e),Uo.addConceptToTree(e),Do.addConceptToTree(e),this.localconceptsArray.push(e))}static AddConceptToMemory(e){e.id>0&&(Po.addConceptToTree(e),Uo.addConceptToTree(e),Do.addConceptToTree(e))}static GetConcept(e){return Fo(this,void 0,void 0,(function*(){var t=Tn(),n=yield Po.getNodeFromTree(e);if(null==n?void 0:n.value){var r=n.value;r&&(t=r)}return t}))}static GetConceptByCharacter(e){return Fo(this,void 0,void 0,(function*(){var t=Tn(),n=Uo.getNodeFromTree(e);return n&&(t=n.value),t}))}static GetConceptByCharacterAndTypeLocal(e,t){return Fo(this,void 0,void 0,(function*(){var n=Tn(),r=yield Uo.getCharacterAndTypeFromTree(e,t);return r&&(n=r.value),n}))}static GetConceptsByTypeId(e){let t=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==e&&t.push(this.localconceptsArray[n]);return t}static GetConceptsByTypeIdAndUser(e,t){return Fo(this,void 0,void 0,(function*(){let n=[];return n=yield Do.getTypeVariantsFromTreeWithUserId(e,t),n}))}getName(){return this.name}}Go.localconceptsArray=[];var jo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Vo(){return jo(this,void 0,void 0,(function*(){var e=yield U("localconcept");if(Array.isArray(e))for(var t=0;t<e.length;t++){let n=e[t];Go.AddConceptToMemory(n)}}))}var Mo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Ho{}Ho.isUpdated=!1,Ho.isOnlineSync=!1;var Wo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Ko{constructor(){this.accessCache=new Map,this.accessIndex=new Map,this.entityIndex=new Map,this.setCounter=0}generateKey(e,t,n){return`${e}:${t.toLowerCase()}:${null!=n?n:0}`}get(e,t,n){const r=this.generateKey(e,t,n),o=this.accessCache.get(r);return void 0===o?null:Date.now()>o.expiresAt?(this.accessCache.delete(r),null):o.value}set(e,t,n,r){const o=this.generateKey(e,t,n);this.accessCache.set(o,{value:r,expiresAt:Date.now()+3e5}),this.accessIndex.has(e)||this.accessIndex.set(e,new Set),this.accessIndex.get(e).add(o);const i=null!=n?n:0;this.entityIndex.has(i)||this.entityIndex.set(i,new Set),this.entityIndex.get(i).add(o),this.setCounter++,this.setCounter>=100&&(this.setCounter=0,this.sweepExpired())}remove(e,t,n){const r=this.generateKey(e,t,n);this.accessCache.delete(r);const o=this.accessIndex.get(e);o&&o.delete(r);const i=null!=n?n:0,c=this.entityIndex.get(i);c&&c.delete(r)}clear(){this.accessCache.clear(),this.accessIndex.clear(),this.entityIndex.clear(),this.setCounter=0}sweepExpired(){const e=Date.now();for(const[t,n]of this.accessCache)if(e>n.expiresAt){this.accessCache.delete(t);const e=t.split(":"),n=parseInt(e[0]),r=parseInt(e[2]),o=this.accessIndex.get(n);o&&(o.delete(t),0===o.size&&this.accessIndex.delete(n));const i=this.entityIndex.get(r);i&&(i.delete(t),0===i.size&&this.entityIndex.delete(r))}for(const[t,n]of Ko.superAdminCache)e>n.expiresAt&&Ko.superAdminCache.delete(t)}getPermissionsByAccessAndEntity(e,t){const n=new Map,r=this.accessIndex.get(e),o=Date.now();if(r){const e=null!=t?t:0;for(const t of r){const r=this.accessCache.get(t);if(r&&o<=r.expiresAt){const o=t.split(":");parseInt(o[2])===e&&n.set(o[1],r.value)}}}return n}getPermissionsByAccess(e){const t=new Map,n=this.accessIndex.get(e),r=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&r<=n.expiresAt){const r=e.split(":"),o=parseInt(r[2]),i=r[1];t.set(`${o}:${i}`,n.value)}}return t}getPermissionsByEntity(e){const t=new Map,n=this.entityIndex.get(e),r=Date.now();if(n)for(const e of n){const n=this.accessCache.get(e);if(n&&r<=n.expiresAt){const r=e.split(":"),o=parseInt(r[0]),i=r[1];t.set(`${o}:${i}`,n.value)}}return t}getSuperAdmin(e){const t=Ko.superAdminCache.get(e);return void 0===t?null:Date.now()>t.expiresAt?(Ko.superAdminCache.delete(e),null):t.value}setSuperAdmin(e,t){Ko.superAdminCache.set(e,{value:t,expiresAt:Date.now()+6e5})}clearSuperAdminCache(){Ko.superAdminCache.clear()}}Ko.superAdminCache=new Map;var Xo,qo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class zo{constructor(e){if(this.baseUrl=e||process.env.ACCESS_CONTROL_BASE_URL||"http://localhost:3000/api/access-control",!this.baseUrl)throw new Error("Access Control base URL is not configured")}getAsync(e){return qo(this,void 0,void 0,(function*(){const t=yield fetch(`${this.baseUrl}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`GET '${e}' failed with status ${t.status}`);const n=yield t.json();if(null==n)throw new Error(`The response for GET '${e}' returned null.`);return n}))}postAsync(e,t){return qo(this,void 0,void 0,(function*(){const n=yield fetch(`${this.baseUrl}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`POST '${e}' failed with status ${n.status}`);const r=yield n.json();if(null==r)throw new Error(`The response for POST '${e}' returned null.`);return r}))}deleteAsync(e,t){return qo(this,void 0,void 0,(function*(){const n={method:"DELETE",headers:{"Content-Type":"application/json"}};null!=t&&(n.body=JSON.stringify(t));const r=yield fetch(`${this.baseUrl}/${e}`,n);if(!r.ok)throw new Error(`DELETE '${e}' failed with status ${r.status}`);const o=yield r.json();if(null==o)throw new Error(`The response for DELETE '${e}' returned null.`);return o}))}assignAccessAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/assign",e)}))}checkAccessAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/check",e)}))}revokeAccessAsync(e){return qo(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke",e)}))}assignAccessBulkAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/assign/bulk",e)}))}revokeAccessBulkAsync(e){return qo(this,void 0,void 0,(function*(){return this.deleteAsync("access/revoke/bulk",e)}))}checkAccessBulkAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/check/bulk",e)}))}getAccessByIdAsync(e){return qo(this,void 0,void 0,(function*(){return this.getAsync(`access/${e}`)}))}setAccessInheritanceAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance",e)}))}getAccessInheritanceStatusAsync(e){return qo(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/status?accessId=${e}&connectionTypeId=${t}`)}))}assignSuperAdminAccessAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin",e)}))}revokeSuperAdminAccessAsync(e){return qo(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin",e)}))}checkSuperAdminStatusAsync(e){return qo(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin?accessId=${e}`)}))}setParentAccessInheritanceAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent",e)}))}removeParentAccessInheritanceAsync(e,t){return qo(this,void 0,void 0,(function*(){let n=`access/inheritance/parent?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.deleteAsync(n)}))}hasParentAccessInheritanceAsync(e,t){return qo(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/status?accessId=${e}`;return null!=t&&(n+=`&parentAccessId=${t}`),this.getAsync(n)}))}getParentAccessIdAsync(e){return qo(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent?accessId=${e}`)}))}setParentAccessInheritanceByConceptAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept",e)}))}setParentAccessInheritanceBulkByConceptAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/parent/concept/bulk",e)}))}removeParentAccessInheritanceByConceptAsync(e,t){return qo(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.deleteAsync(n)}))}removeParentAccessInheritanceBulkByConceptAsync(e){return qo(this,void 0,void 0,(function*(){return this.deleteAsync("access/inheritance/parent/concept/bulk",e)}))}hasParentAccessInheritanceByConceptAsync(e,t){return qo(this,void 0,void 0,(function*(){let n=`access/inheritance/parent/concept/status?childConceptId=${e}`;return null!=t&&(n+=`&parentConceptId=${t}`),this.getAsync(n)}))}getParentAccessIdByConceptAsync(e){return qo(this,void 0,void 0,(function*(){return this.getAsync(`access/inheritance/parent/concept?childConceptId=${e}`)}))}assignSuperAdminByConceptAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/super-admin/concept",e)}))}revokeSuperAdminByConceptAsync(e){return qo(this,void 0,void 0,(function*(){return this.deleteAsync("access/super-admin/concept",e)}))}checkSuperAdminByConceptAsync(e){return qo(this,void 0,void 0,(function*(){return this.getAsync(`access/super-admin/concept?conceptId=${e}`)}))}setAccessInheritanceByConceptAsync(e){return qo(this,void 0,void 0,(function*(){return this.postAsync("access/inheritance/concept",e)}))}getAccessInheritanceStatusByConceptAsync(e){return qo(this,arguments,void 0,(function*(e,t=999){return this.getAsync(`access/inheritance/concept/status?conceptId=${e}&connectionTypeId=${t}`)}))}}!function(e){e[e.None=0]="None",e[e.Read=1]="Read",e[e.Write=2]="Write",e[e.Execute=4]="Execute",e[e.Delete=8]="Delete"}(Xo||(Xo={}));var Jo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};class Yo{static initialize(){console.log("AccessControlService initialized with access control disabled by default.")}static setEnabled(e){this.isAccessControlEnabled=e}static getEnabled(){return this.isAccessControlEnabled}static setBaseUrl(e){this.apiClient=new zo(e)}static checkAccess(e,t,n){return Jo(this,void 0,void 0,(function*(){var r;if(t===Xo.None)throw new Error("Permission is required");return null!==(r=(yield this.checkAccessBulk([e],t,n)).get(e))&&void 0!==r&&r}))}static checkAccessBulk(e,t,n){return Jo(this,void 0,void 0,(function*(){var r,o,i,c,a,l;if(t===Xo.None)throw new Error("Permission is required");const u=this.permissionSetToString(t),d=new Map;if(!e||0===e.length)return d;if(!this.isAccessControlEnabled){for(const t of e)d.set(t,!0);return d}if(null!=n&&n>0)try{if(yield this.isSuperAdmin(n)){for(const t of e)d.set(t,!0);return d}}catch(e){}const h=[],f=new Set,p=new Map;let y=null;if(null!=n&&n>0)try{y=yield Qt(n)}catch(e){}let v=0;try{const e=yield function(){return e=this,t=void 0,r=function*(){let e=H();try{var t=yield ee("application/x-www-form-urlencoded");const n=yield C(s.GetConceptByCharacterAndCategoryUrl(),{method:"POST",headers:t,body:"character_value=the_parent_access_inheritance"});return n.ok?(e=yield n.json(),z.AddConcept(e)):(console.log("This is the concept by category and character error",n.status),re(n)),e}catch(e){throw e instanceof Error?console.log(" This is the concept by category and character error message: ",e.message):console.log(" This is the concept by category and character unexpected error: ",e),e}},new((n=void 0)||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}));var e,t,n,r}();e&&e.id&&(v=e.id)}catch(e){}const g=yield ve(e),m=new Map;for(const e of g)m.set(e.id,e);const w=new Map;for(const t of e){const e=null!==(r=m.get(t))&&void 0!==r?r:yield Qt(t);if(!e||0===e.id){d.set(t,!1);continue}const n=null!==(o=e.accessId)&&void 0!==o?o:0,s=null!==(i=e.typeId)&&void 0!==i?i:0;if(y&&y.userId&&y.userId===e.userId){d.set(t,!0);continue}if(n<1e4){d.set(t,!0);continue}let a=0;if(s>0){let e=w.get(s);if(!e)try{e=yield Qt(s),w.set(s,e)}catch(e){}e&&(a=null!==(c=e.accessId)&&void 0!==c?c:0)}h.push({conceptId:t,accessId:n,typeAccessId:a}),n>0&&(f.add(n),p.set(n,t)),a>0&&f.add(a)}if(0===h.length)return d;const T=yield this.resolveBulkInheritanceGraph(f,v,p),I=[],N=new Set;for(const e of T.values())for(const t of e)N.has(t)||(N.add(t),I.push(t));const A=yield this.resolveSubjects(n),E=yield this.resolveBulkDecisions(I,u,A);for(const e of h){const t=null!==(a=T.get(e.accessId))&&void 0!==a?a:[e.accessId],n=e.typeAccessId>0?null!==(l=T.get(e.typeAccessId))&&void 0!==l?l:[e.typeAccessId]:[],r=this.hasAnyGrant(t,n,A,E);d.set(e.conceptId,r)}return d}))}static getConceptIdsWithPermission(e,t,n){return Jo(this,void 0,void 0,(function*(){if(e===Xo.None)throw new Error("Permission is required");if(!t||0===t.length)return[];if(!this.isAccessControlEnabled)return t;const r=yield this.checkAccessBulk(t,e,n);return t.filter((e=>!0===r.get(e)))}))}static resolveBulkInheritanceGraph(e,t,n){return Jo(this,void 0,void 0,(function*(){var r;const o=new Map,i=new Set;let c=new Set(e),s=0;for(;c.size>0;){if(s>=10){console.warn("[AccessControl] BFS depth limit (10) reached. Stopping inheritance traversal.");break}s++;const e=new Set;for(const e of c)i.add(e);const a=Array.from(c);if(t>0)for(const t of a)try{const n=yield wo(t,["the_parent_access_inheritance"]);if(n&&n.length>0){const r=yield Jn(n);for(const n of r){const r=n.toTheConceptId;r&&r>0&&!i.has(r)&&(o.has(t)||o.set(t,[]),o.get(t).push(r),e.add(r))}}}catch(e){}for(const t of a)try{const n=yield this.apiClient.getParentAccessIdAsync(t);if(!0===(null==n?void 0:n.status)&&void 0!==n.data&&null!==n.data){const r=this.parseIntData(n);null!==r&&r>0&&!i.has(r)&&(o.has(t)||o.set(t,[]),o.get(t).push(r),e.add(r))}}catch(e){}for(const c of a)try{const s=yield this.apiClient.getAccessInheritanceStatusAsync(c);if(!this.parseBoolData(s))continue;const a=n.get(c);if(!a||0===a)continue;const l=yield Pn(a);if(!l||0===l.length)continue;for(const s of l){if(s.ofTheConceptId!==a)continue;if(t>0&&s.typeId!==t)continue;const l=s.toTheConceptId;if(l&&0!==l)try{const t=yield Qt(l),s=null!==(r=null==t?void 0:t.accessId)&&void 0!==r?r:0;s>0&&!i.has(s)&&(o.has(c)||o.set(c,[]),o.get(c).push(s),n.set(s,l),e.add(s))}catch(e){}}}catch(e){}for(const t of i)e.delete(t);c=e}const a=new Map;for(const t of e){const e=[t],n=new Set([t]),r=[t];for(;r.length>0&&e.length<100;){const t=r.shift(),i=o.get(t);if(i)for(const t of i)n.has(t)||(n.add(t),e.push(t),r.push(t))}a.set(t,e)}return a}))}static resolveBulkDecisions(e,t,n){return Jo(this,void 0,void 0,(function*(){var r;const o=new Map,i=new Map;for(let r=0;r<n.length;r++){const c=n[r];for(const n of e){const e=this.cacheService.get(n,t,c),s=`${n}:${null!=c?c:0}`;null!==e?o.set(s,e):(i.has(r)||i.set(r,[]),i.get(r).push(n))}}for(const[e,c]of i){if(0===c.length)continue;const i=n[e];try{const e={accessIds:c,permission:t,entityId:i},n=yield this.apiClient.checkAccessBulkAsync(e);if(!0===(null==n?void 0:n.status)&&n.data&&Array.isArray(n.data)){const e=new Map;for(const t of n.data)e.set(t.accessId,t.hasAccess);for(const n of c){const c=null!==(r=e.get(n))&&void 0!==r&&r;this.cacheService.set(n,t,i,c),o.set(`${n}:${null!=i?i:0}`,c)}}else for(const e of c)this.cacheService.set(e,t,i,!1),o.set(`${e}:${null!=i?i:0}`,!1)}catch(e){for(const e of c)o.set(`${e}:${null!=i?i:0}`,!1)}}return o}))}static resolveSubjects(e){return Jo(this,void 0,void 0,(function*(){const t=[null];if(null!=e&&e>0){t.push(e);try{const n=yield wo(e,["the_entity_s_group"]);if(n&&n.length>0){const e=yield Jn(n);for(const n of e)n.toTheConceptId&&n.toTheConceptId>0&&t.push(n.toTheConceptId)}}catch(e){}}return t}))}static hasAnyGrant(e,t,n,r){for(const t of e)for(const e of n){const n=`${t}:${null!=e?e:0}`;if(!0===r.get(n))return!0}for(const e of t)for(const t of n){const n=`${e}:${null!=t?t:0}`;if(!0===r.get(n))return!0}return!1}static assignAccess(e,t,n){return Jo(this,void 0,void 0,(function*(){var r;if(t===Xo.None)throw new Error("Permission is required");try{const o=null!==(r=(yield Qt(e)).accessId)&&void 0!==r?r:0,i=this.permissionSetToString(t),c=yield this.apiClient.assignAccessAsync({accessId:o,permission:i,entityId:n});if(!0===(null==c?void 0:c.status)&&c.data){const e=c.data;return this.cacheService.set(e.accessId,e.permission,e.entityId,e.hasAccess),!0}return!1}catch(r){throw new Error(`Error assigning access for conceptId ${e}, permission '${t}', entityId ${n}: ${r}`)}}))}static assignAccessBulk(e){return Jo(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{const n=yield this.apiClient.assignAccessBulkAsync(e);if(!0!==(null==n?void 0:n.status))throw new Error((null==n?void 0:n.message)||"Failed to assign bulk access");const r=[];for(const n of e.targets)for(const o of n.permissions){const i=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(i,o,n.entityId,!0),r.push({accessId:i,permission:o,entityId:n.entityId,hasAccess:!0})}return r}catch(e){throw console.error("Failed to assign bulk access:",e),e}}))}static revokeAccess(e,t,n){return Jo(this,void 0,void 0,(function*(){var r;try{const o=null!==(r=(yield Qt(e)).accessId)&&void 0!==r?r:0,i=this.permissionSetToString(t);if(0===o)throw new Error(`Concept with ID ${e} does not have a valid accessId`);const c=yield this.apiClient.revokeAccessAsync({accessId:o,permission:i,entityId:n}),s=!0===(null==c?void 0:c.status);return this.cacheService.set(o,i,n,!s),s}catch(r){throw new Error(`Error revoking access for concept ${e}, permission '${t}', entityId ${n}: ${r}`)}}))}static revokeAccessBulk(e){return Jo(this,void 0,void 0,(function*(){var t;if(!e||!e.targets||0===e.targets.length)throw new Error("Request must contain at least one target");try{yield this.apiClient.revokeAccessBulkAsync(e);const n=[];for(const r of e.targets)for(const o of r.permissions){const i=null!==(t=e.accessId)&&void 0!==t?t:0;this.cacheService.set(i,o,r.entityId,!1),n.push({accessId:i,permission:o,entityId:r.entityId,hasAccess:!1})}return n}catch(e){throw console.error("Failed to revoke bulk access:",e),e}}))}static setAccessInheritance(e){return Jo(this,void 0,void 0,(function*(){var t;try{const n=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,connectionTypeId:999});return null!==(t=null==n?void 0:n.status)&&void 0!==t&&t}catch(t){throw new Error(`Error setting access inheritance for conceptId ${e}: ${t}`)}}))}static getAccessInheritanceStatus(e){return Jo(this,arguments,void 0,(function*(e,t=999){try{const n=yield this.apiClient.getAccessInheritanceStatusByConceptAsync(e,t);return this.parseBoolData(n)}catch(n){throw new Error(`Error getting access inheritance status for conceptId ${e}, connectionTypeId ${t}: ${n}`)}}))}static setAccessInheritanceStatus(e,t){return Jo(this,arguments,void 0,(function*(e,t,n=999){var r;try{const o=yield this.apiClient.setAccessInheritanceByConceptAsync({conceptId:e,enable:t,connectionTypeId:n});return null!==(r=null==o?void 0:o.status)&&void 0!==r&&r}catch(t){throw new Error(`Error setting access inheritance status for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritance(e,t){return Jo(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceByConceptAsync({parentConceptId:t,childConceptId:e});if(!0===(null==n?void 0:n.status)){const e=this.parseIntData(n);if(null!==e&&e>0)return e}return 0}catch(t){throw new Error(`Error setting parent access inheritance for conceptId ${e}: ${t}`)}}))}static removeParentAccessInheritance(e,t){return Jo(this,void 0,void 0,(function*(){var n;try{const r=yield this.apiClient.removeParentAccessInheritanceByConceptAsync(e,t);return null!==(n=null==r?void 0:r.message)&&void 0!==n?n:"Parent access inheritance removal failed"}catch(t){throw new Error(`Error removing parent access inheritance for conceptId ${e}: ${t}`)}}))}static hasParentAccessInheritance(e,t){return Jo(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.hasParentAccessInheritanceByConceptAsync(e,t);return this.parseBoolData(n)}catch(t){throw new Error(`Error checking parent access inheritance for conceptId ${e}: ${t}`)}}))}static getParentAccessId(e){return Jo(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.getParentAccessIdByConceptAsync(e);return this.parseIntData(t)}catch(t){throw new Error(`Error getting parent access ID for conceptId ${e}: ${t}`)}}))}static setParentAccessInheritanceBulk(e,t){return Jo(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.setParentAccessInheritanceBulkByConceptAsync({parentConceptId:t,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error setting bulk parent access inheritance for parentConceptId ${t}: ${e}`)}}))}static removeParentAccessInheritanceBulk(e,t){return Jo(this,void 0,void 0,(function*(){try{const n=yield this.apiClient.removeParentAccessInheritanceBulkByConceptAsync({parentConceptId:null!=t?t:0,childConceptIds:e});return!0===(null==n?void 0:n.status)&&Array.isArray(n.data)?n.data:[]}catch(e){throw new Error(`Error removing bulk parent access inheritance: ${e}`)}}))}static isSuperAdmin(e){return Jo(this,void 0,void 0,(function*(){try{if(0===e)return!1;const t=this.cacheService.getSuperAdmin(e);if(null!==t)return t;const n=yield this.apiClient.checkSuperAdminByConceptAsync(e);if(!0===(null==n?void 0:n.status)&&void 0!==n.data){const t=this.parseBoolData(n);return this.cacheService.setSuperAdmin(e,t),t}return!1}catch(t){throw new Error(`Error checking super admin status for entityId ${e}: ${t}`)}}))}static assignSuperAdmin(e){return Jo(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.assignSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&void 0!==t.data?(this.cacheService.setSuperAdmin(e,!0),e):0}catch(t){throw new Error(`Failed to assign super admin for entityId ${e}: ${t}`)}}))}static revokeSuperAdmin(e){return Jo(this,void 0,void 0,(function*(){try{const t=yield this.apiClient.revokeSuperAdminByConceptAsync({conceptId:e});return!0===(null==t?void 0:t.status)&&t.message?(this.cacheService.setSuperAdmin(e,!1),t.message):"Super admin access deletion failed"}catch(t){throw new Error(`Failed to revoke super admin for entityId ${e}: ${t}`)}}))}static parseBoolData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return!1;const t=e.data;if("boolean"==typeof t)return t;if("string"==typeof t)return"true"===t.toLowerCase();if("number"==typeof t)return 0!==t;if("object"==typeof t)for(const e of["enabled","Enabled","isEnabled","IsEnabled","status","Status","hasAccess","HasAccess"])if(e in t){const n=t[e];if("boolean"==typeof n)return n;if("string"==typeof n)return"true"===n.toLowerCase()}return!1}static parseIntData(e){if(!(null==e?void 0:e.status)||void 0===e.data||null===e.data)return null;const t=e.data;if("number"==typeof t)return t;if("string"==typeof t){const e=parseInt(t,10);return isNaN(e)?null:e}if("object"==typeof t)for(const e of["id","Id","accessId","AccessId","parentAccessId","ParentAccessId"])if(e in t){const n=t[e];if("number"==typeof n)return n;if("string"==typeof n){const e=parseInt(n,10);if(!isNaN(e))return e}}return null}static permissionSetToString(e){return function(e){const t=[];return e&Xo.Read&&t.push("read"),e&Xo.Write&&t.push("write"),e&Xo.Execute&&t.push("execute"),e&Xo.Delete&&t.push("delete"),t}(e)[0]||"read"}static clearCache(){this.cacheService.clear()}static clearSuperAdminCache(){this.cacheService.clearSuperAdminCache()}static updateAccessCache(e,t,n,r){this.cacheService.set(e,t,n,r)}static updateSuperAdminCache(e,t){this.cacheService.setSuperAdmin(e,t)}}Yo.cacheService=new Ko,Yo.apiClient=new zo,Yo.isAccessControlEnabled=!1,Yo.initialize();var Qo=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};const Zo=1,ei=2,ti=3,ni=4,ri=5,oi=6,ii=7,ci=8;class si{constructor(){this.conceptId=0,this.connectionTypeId=0,this.connectionType="",this.count=0}}var ai=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function li(e){return ai(this,void 0,void 0,(function*(){let t={};for(let n=0;n<e.length;n++){let r=yield Se(e[n].connectionTypeId);e[n].connectionType=r.characterValue,t[e[n].conceptId]||(t[e[n].conceptId]=[]),t[e[n].conceptId].push(e[n])}return t}))}function ui(e){const t=e.split("_");if(3===t.length){let e=new si;return e.conceptId=Number(t[0]),e.connectionTypeId=Number(t[1]),e.count=Number(t[2]),e}throw new Error("Input string must contain exactly three parts separated by underscores.")}function di(e){return e.startsWith("the_")?e.slice(4):e}var hi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function fi(e,t,n){if(e in t){const r=Array.isArray(t[e])?t[e]:[t[e]];for(const e of r)e&&(n[e.connectionType+"_count"]=e.count)}}var pi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))},yi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function vi(e,t,n){return yi(this,void 0,void 0,(function*(){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1;n.includes(e[d].id)&&(h=!0);let f=yield Qt(e[d].ofTheConceptId),p=yield Qt(e[d].toTheConceptId);if(1==h){if(0!=f.id&&0!=p.id){let n,s=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?n=t[e[d].toTheConceptId]:(n={},n[s]={},t[e[d].toTheConceptId]=n);let a=yield Qt(e[d].typeId);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",n=f.characterValue;a.characterValue,a.characterValue.includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[p.id]={}}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?n=t[e[d].ofTheConceptId]:(n={},n[r]={},t[e[d].ofTheConceptId]=n);let o=yield Qt(e[d].typeId);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",n=p.characterValue;o.characterValue.includes("_s_")&&(p.id in t||(t[p.id]={}),t[p.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}var gi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function mi(e,t="DESC"){return"ASC"==t?e.sort((function(e,t){return e.id-t.id})):e.sort((function(e,t){return t.id-e.id})),e}var Ci=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};var wi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ti(e,t){return wi(this,void 0,void 0,(function*(){let n=e.outputFormat;e.outputFormat=oi;let r,o=yield function(e){return Qo(this,arguments,void 0,(function*(e,t=""){var n=yield te("application/json",t);const r=s.FreeschemaQueryUrl(),o=JSON.stringify(e);try{const e=yield C(r,{method:"POST",headers:n,body:o});if(e.ok)return yield e.json();re(e)}catch(e){!function(e,t=""){if(e.status){let n=new ne(e.message,!1,e.status,e.stack);throw n.setUrl(t),n}{let n=new ne(e.message,!1,500,e.stack);throw n.setUrl(t),n}}(e,r)}}))}(e,t),i=o.conceptIds,c=(o.internalConnections,o.linkers),a=o.reverse,l=o.mainCompositionIds,u=o.countinfo,d=e.order,h=function(e=[]){let t=[];if(e.length>0)for(let n=0;n<(null==e?void 0:e.length);n++){let r=ui(e[n]);t.push(r)}return t}(u);return r=n==ei?yield function(e,t,n,r,o){return Ci(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield tr(e),s=yield li(o);c=mi(c,i);let a=[];a=yield function(e,t){return pi(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Qt(e[d].ofTheConceptId),p=yield Qt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Qt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?n=t[e[d].toTheConceptId]:(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(s.characterValue+"_reverse").includes("_s_")&&(f.id in t||(t[f.id]={}),t[f.id][e]=n),t[p.id]={}}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield Qt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?n=t[e[d].ofTheConceptId]:(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",n=p.characterValue;r.characterValue.includes("_s_")&&(p.id in t||(t[p.id]={}),t[p.id][e]=n),t[f.id]={}}catch(e){}}}return t}))}(c,a,r),a=yield function(e,t){return pi(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Qt(e[d].ofTheConceptId),p=yield Qt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Qt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=s.characterValue;""==r&&(r=e,r=di(r));let o={id:f.id,data:{[e]:t}},l=r+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield Qt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",t=p.characterValue,i=r.characterValue,c=!1;""==i&&(i=e,i=di(i),c=!0);let s={id:p.id,data:{[e]:t}};isNaN(Number(i))?i.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][i]=s):(Array.isArray(n[o])||(n[o]=[]),n[o].push(s))}catch(e){}}}return t}))}(c,a,r);let l=yield function(e,t,n,r){return pi(this,arguments,void 0,(function*(e,t,n,r,o=[],i){var c,s,a,l,u,d,h;(new Date).getTime();let f=[],p=[];for(let t=0;t<e.length;t++)p.push(e[t].toTheConceptId),p.push(e[t].ofTheConceptId),p.push(e[t].typeId);for(let n=0;n<e.length;n++){let r=!1,f=yield Qt(e[n].ofTheConceptId),p=yield Qt(e[n].toTheConceptId);if(o.includes(e[n].id)&&(r=!0),1==r){if(0!=f.id&&0!=p.id&&p.id in t){let r,o=yield Qt(e[n].typeId),a=null!==(s=null===(c=p.type)||void 0===c?void 0:c.characterValue)&&void 0!==s?s:"self",l=!1;e[n].toTheConceptId in t&&(l=!0),e[n].toTheConceptId in t?(r=t[e[n].toTheConceptId],"string"==typeof r[a]&&(r[a]={})):(r={},r[a]={},t[e[n].toTheConceptId]=r),fi(p.id,i,r);try{if(t[e[n].ofTheConceptId]){let i={id:f.id,data:t[e[n].ofTheConceptId],created_on:e[n].entryTimeStamp},c=o.characterValue+"_reverse";Array.isArray(r[a][c])?r[a][c].push(i):c.includes("_s_")?(r[a][c]=[],r[a][c].push(i)):r[a][c]=i}}catch(e){}}}else if(0!=f.id&&0!=p.id&&f.id in t){let r,o=yield Qt(e[n].typeId),c=null!==(l=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==l?l:"self",s=!1;e[n].toTheConceptId in t&&(s=!0),e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[c]&&(r[c]={})):(r={},r[c]={},t[e[n].ofTheConceptId]=r),fi(f.id,i,r);let y=!0,v=o.characterValue;""==v&&(v=p.characterValue,y=!0),""==v&&(v=null!==(d=null===(u=null==p?void 0:p.type)||void 0===u?void 0:u.characterValue)&&void 0!==d?d:"");try{null===(h=null==p?void 0:p.type)||void 0===h||h.characterValue;let s=t[e[n].toTheConceptId];if(s){let a={id:p.id,data:t[e[n].toTheConceptId],created_on:e[n].entryTimeStamp};Array.isArray(r[c])?r[c].push(s):Array.isArray(r[c][v])?r[c][o.characterValue].push(a):v.includes("_s_")?(r[c][v]=[],r[c][v].push(a)):r[c][v]=a,fi(p.id,i,a)}}catch(e){}}}for(let e=0;e<r.length;e++){let n={};n.id=r[e];let o=yield Qt(n.id);n.data=t[r[e]],n.created_on=o.entryTimeStamp,f.push(n)}return f}))}(c,a,[],n,r,s);return l}))}(c,i,l,a,h,d):n==ti?yield function(e,t,n,r,o){return Ci(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield tr(e),s=yield li(o);c=mi(c,i);let a=[];a=yield vi(c,a,r),a=yield function(e,t){return hi(this,arguments,void 0,(function*(e,t,n=[]){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);for(let d=0;d<e.length;d++){let h=!1,f=yield Qt(e[d].ofTheConceptId),p=yield Qt(e[d].toTheConceptId);if(n.includes(e[d].id)&&(h=!0),1==h){if(0!=f.id&&0!=p.id){let n,s=yield Qt(e[d].typeId),a=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},t[e[d].toTheConceptId]=n);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=s.characterValue;""==r&&(r=e,r=di(r));let o={id:f.id,[e]:t},l=r+"_reverse";l.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=yield Qt(e[d].typeId),o=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},t[e[d].ofTheConceptId]=n);try{let t=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",i=p.characterValue,c=r.characterValue,s=!1;""==c&&(c=t,c=di(c),s=!0);let a={};a[t]={id:p.id,data:i,created_on:e[d].entryTimeStamp},isNaN(Number(c))?c.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][c]=s?a[t]:a):(Array.isArray(n[o])||(n[o]=[]),n[o].push(a[t]))}catch(e){}}}return t}))}(c,a,r);let l=yield function(e,t,n){return hi(this,arguments,void 0,(function*(e,t,n,r=[],o){var i,c,s,a,l,u,d,h;(new Date).getTime();let f=[],p=[];for(let t=0;t<e.length;t++)p.push(e[t].toTheConceptId),p.push(e[t].ofTheConceptId),p.push(e[t].typeId);for(let n=0;n<e.length;n++){let f=!1,p=yield Qt(e[n].ofTheConceptId),y=yield Qt(e[n].toTheConceptId);if(r.includes(e[n].id)&&(f=!0),1==f){if(0!=p.id&&0!=y.id&&y.id in t){let r,o=yield Qt(e[n].typeId),s=null!==(c=null===(i=y.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self",a=!1;e[n].toTheConceptId in t&&(a=!0),e[n].toTheConceptId in t?(r=t[e[n].toTheConceptId],"string"==typeof r[s]&&(r[s]={})):(r={},r[s]={},t[e[n].toTheConceptId]=r);try{if(t[e[n].ofTheConceptId]){let i=t[e[n].ofTheConceptId];i&&(i.id=p.id,i.created_on=p.entryTimeStamp);let c=o.characterValue+"_reverse";Array.isArray(r[s][c])?r[s][c].push(i):c.includes("_s_")?(r[s][c]=[],r[s][c].push(i)):r[s][c]=i}}catch(e){}}}else if(0!=p.id&&0!=y.id&&p.id in t){let r,i=yield Qt(e[n].typeId),c=null!==(a=null===(s=p.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self",f=!1;e[n].toTheConceptId in t&&(f=!0),e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[c]&&(r[c]={})):(r={},r[c]={},t[e[n].ofTheConceptId]=r),fi(p.id,o,r);let v=!1,g=i.characterValue;""==g&&(g=y.characterValue,v=!0),""==g&&(g=null!==(u=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"");try{let i=null!==(h=null===(d=null==y?void 0:y.type)||void 0===d?void 0:d.characterValue)&&void 0!==h?h:"none",s=t[e[n].toTheConceptId];if(s){let t={};t[i]={data:s[i],id:y.id,created_on:e[n].entryTimeStamp},Array.isArray(r[c])?v?r[c].push(s[g]):r[c].push(s):Array.isArray(r[c][g])?r[c][g].push(t):g.includes("_s_")?(r[c][g]=[],v?r[c][g].push(t[i]):r[c][g].push(t)):r[c][g]=v?t[i]:t,fi(y.id,o,t)}}catch(e){}}}for(let e=0;e<n.length;e++){let r={};r=t[n[e]],r&&(r.id=n[e]),f.push(r)}return f}))}(c,a,n,r,s);return l}))}(c,i,l,a,h,d):n==ci?yield function(e,t,n,r,o){return Ci(this,arguments,void 0,(function*(e,t,n,r,o,i="DESC"){let c=yield tr(e),s=yield li(o);c=mi(c,i);let a={};a=yield function(e){return gi(this,arguments,void 0,(function*(e,t={},n=[]){var r,o,i,c,s;for(const a of e){const e=n.includes(a.id),l=yield Qt(a.ofTheConceptId),u=yield Qt(a.toTheConceptId),d=yield Qt(a.typeId);if(0===l.id||0===u.id)continue;const h=e?u:l,f=e?l:u,p=null!==(o=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self",y=null!==(c=null===(i=f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null===(s=d.characterValue)||void 0===s?void 0:s.includes("_s_");t[h.id]||(t[h.id]={}),t[h.id][p]||(t[h.id][p]={}),g&&(t[f.id]||(t[f.id]={}),t[f.id][y]=v)}return t}))}(c,a,r),a=yield function(e){return gi(this,arguments,void 0,(function*(e,t={},n=[]){var r,o,i,c,s;for(const a of e){const e=n.includes(a.id),l=yield Qt(a.ofTheConceptId),u=yield Qt(a.toTheConceptId),d=yield Qt(a.typeId);if(0===l.id||0===u.id)continue;const h=e?u:l,f=e?l:u,p=null!==(o=null===(r=h.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self",y=null!==(c=null===(i=f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",v=f.characterValue,g=null!==(s=d.characterValue)&&void 0!==s?s:"";let m=""===g?di(y):g;const C=m.includes("_s_"),w=!isNaN(Number(m)),T={id:f.id,data:{[y]:v}};t[h.id]||(t[h.id]={}),p in t[h.id]&&"string"!=typeof t[h.id][p]||(t[h.id][p]=w?[]:{});try{if(C)continue;w?t[h.id][p].push(T):t[h.id][p][e?`${m}_reverse`:m]=T}catch(e){console.error("Error formatting concept data:",e)}}return t}))}(c,a,r);let l=yield function(e,t,n){return gi(this,arguments,void 0,(function*(e,t,n,r=[],o){var i,c,s;const a=[];for(const n of e){const e=r.includes(n.id),a=yield Qt(n.ofTheConceptId),l=yield Qt(n.toTheConceptId),u=yield Qt(n.typeId);if(0===a.id||0===l.id)continue;const d=e?l:a,h=e?a:l,f=d.id,p=h.id,y=null!==(c=null===(i=d.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self",v=u.characterValue+"_reverse",g=u.characterValue||h.characterValue||(null===(s=h.type)||void 0===s?void 0:s.characterValue)||"";if(t[f]){const r=t[f][y],i=t[p],c={id:h.id,data:i,created_on:n.entryTimeStamp};fi(f,o,t[f]);try{e?Array.isArray(r[v])?r[v].push(c):r[v]=[c]:Array.isArray(r)?r.push(i):Array.isArray(r[g])?r[g].push(c):g.includes("_s_")?(r[g]=[],r[g].push(c)):r[g]=[c],fi(p,o,c)}catch(e){console.error("Error processing connection:",e)}}}for(const e of n){const n=yield Qt(e);a.push({id:e,data:t[e],created_on:n.entryTimeStamp})}return a}))}(c,a,n,r,s);return l}))}(c,i,l,a,h,d):yield function(e,t,n,r){return Ci(this,void 0,void 0,(function*(){let t=yield tr(e);t=mi(t);let o=[];o=yield vi(t,o,r),o=yield function(e,t,n){return yi(this,void 0,void 0,(function*(){var r,o,i,c,s,a,l,u;let d=[];for(let t=0;t<e.length;t++)d.push(e[t].toTheConceptId),d.push(e[t].ofTheConceptId),d.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let d=0;d<e.length;d++){let h=!1;n.includes(e[d].id)&&(h=!0);let f=yield Qt(e[d].ofTheConceptId),p=yield Qt(e[d].toTheConceptId);if(1==h){if(0!=f.id&&0!=p.id){let n,s=null!==(o=null===(r=p.type)||void 0===r?void 0:r.characterValue)&&void 0!==o?o:"self";e[d].toTheConceptId in t?(n=t[e[d].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},t[e[d].toTheConceptId]=n);let a=yield Qt(e[d].typeId);try{let e=null!==(c=null===(i=null==f?void 0:f.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"none",t=f.characterValue,r=a.characterValue;""==r&&(r=e,r=di(r));let o={[e]:t},l=r+"_reverse";a.characterValue.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][l]=o)}catch(e){}}}else if(0!=f.id&&0!=p.id){let n,r=null!==(a=null===(s=f.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[d].ofTheConceptId in t?(n=t[e[d].ofTheConceptId],r in n||(n[r]={})):(n={},n[r]={},t[e[d].ofTheConceptId]=n);let o=yield Qt(e[d].typeId);try{let e=null!==(u=null===(l=null==p?void 0:p.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"none",t=p.characterValue,i=o.characterValue,c=(o.characterValue,!1);""==i&&(i=e,i=di(i),c=!0);let s={[e]:t};isNaN(Number(i))?o.characterValue.includes("_s_")||("string"==typeof n[r]&&(n[r]={}),n[r][i]=c?t:s):(Array.isArray(n[r])||(n[r]=[]),n[r].push(t))}catch(e){}}}return t}))}(t,o,r);let i=yield function(){return yi(this,arguments,void 0,(function*(e=[],t=[],n=[],r,o=[]){var i,c,s,a,l,u;let d=[],h=[];for(let t=0;t<e.length;t++)h.push(e[t].toTheConceptId),h.push(e[t].ofTheConceptId),h.push(e[t].typeId);e.sort((function(e,t){return t.id-e.id}));for(let n=0;n<e.length;n++){let r=!1;o.includes(e[n].id)&&(r=!0);let d=yield Qt(e[n].ofTheConceptId),h=yield Qt(e[n].toTheConceptId);if(1==r){if(0!=d.id&&0!=h.id&&h.id in t){let r,o=null!==(c=null===(i=h.type)||void 0===i?void 0:i.characterValue)&&void 0!==c?c:"self";e[n].toTheConceptId in t?r=t[e[n].toTheConceptId]:(r={},r[o]={},t[e[n].toTheConceptId]=r);let s=yield Qt(e[n].typeId);try{let i=s.characterValue+"_reverse",c=t[e[n].ofTheConceptId];c&&(Array.isArray(r[o][i])?r[o][i].push(c):s.characterValue.includes("_s_")?(r[o][i]=[],r[o][i].push(c)):r[o][i]=c)}catch(e){}}}else if(0!=d.id&&0!=h.id&&d.id in t){let r,o=null!==(a=null===(s=d.type)||void 0===s?void 0:s.characterValue)&&void 0!==a?a:"self";e[n].ofTheConceptId in t?(r=t[e[n].ofTheConceptId],"string"==typeof r[o]&&(r[o]={})):(r={},r[o]={},t[e[n].ofTheConceptId]=r);let i=!1,c=(yield Qt(e[n].typeId)).characterValue;""==c&&(c=h.characterValue,i=!0),""==c&&(c=null!==(u=null===(l=null==h?void 0:h.type)||void 0===l?void 0:l.characterValue)&&void 0!==u?u:"");try{let s=t[e[n].toTheConceptId];s&&(Array.isArray(r[o])?i?r[o].push(s[c]):r[o].push(s):Array.isArray(r[o][c])?r[o][c].push(s):c.includes("_s_")?(r[o][c]=[],i?r[o][c].push(s[c]):r[o][c].push(s)):r[o][c]=i?s[c]:s)}catch(e){}}}for(let e=0;e<n.length;e++){let r=t[n[e]];r&&(r.id=n[e],d.push(r))}return d}))}(t,o,n,[],r);return i}))}(c,0,l,a),r}))}class Ii{constructor(){this.type="",this.inpage=10,this.page=1,this.concepts=[],this.conceptIds=[],this.selectors=[],this.freeschemaQueries=[],this.filters=[],this.filterLogic="",this.typeConnection="",this.order="DESC",this.outputFormat=Zo,this.name="",this.reverse=!1,this.limit=!1,this.filterAncestor="",this.includeInFilter=!1,this.isOldConnectionType=!1,this.usePipelineQuery=!1}}var Ni=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ai(e,t){return Ni(this,arguments,void 0,(function*(e,t,n=!1){let r=[];if(n){let n=yield Un(e),o=yield nt(t);for(let e=0;e<n.length;e++)n[e].typeId==o.id&&r.push(n[e])}else{let n=yield Pn(e);for(let e=0;e<n.length;e++)pe.AddConnection(n[e]);let o=yield nt(t);for(let e=0;e<n.length;e++)n[e].typeId==o.id&&r.push(n[e])}return r}))}function Ei(e,t,n){return Ni(this,arguments,void 0,(function*(e,t,n,r=!1){let o=[],i=[];if(o=r?yield Ai(t,n,r):yield Ai(e,n,r),r)for(let t=0;t<o.length;t++)o[t].ofTheConceptId==e&&i.push(o[t]);else for(let e=0;e<o.length;e++)o[e].toTheConceptId==t&&i.push(o[e]);return i}))}var Si=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,s)}a((r=r.apply(e,t||[])).next())}))};function Ri(e=""){a.BearerAccessToken=e}function ki(){return Si(this,arguments,void 0,(function*(e="",t="",n="CCSApp",r){var o,i;const c=r||new So;Yo.setBaseUrl(c.accessControlBaseUrl),Yo.setEnabled(c.enableAccessControl),s.BASE_URL=e,s.AI_URL=c.aiUrl,t&&(s.NODE_URL=t);const l=c.cacheServers.length>0?c.cacheServers:Eo(null!==(i=null===(o=c.parameters)||void 0===o?void 0:o.cacheServers)&&void 0!==i?i:c.getParameter("cacheServers",""));s.setCacheServers(l);const u=c.cacheServerUrl||c.getParameter("cacheServerUrl","");if(u?s.setNodeCacheUrl(u):0===l.length&&s.setNodeCacheUrl(""),c.hasOAuthCredentials()){const e=c.applicationName||n;a.setOAuthCredentials(c.clientId,c.clientSecret,e);const t=yield d(c.clientId,c.clientSecret,e,!0);if(!t.success)throw new Error(`OAuth token request failed: ${t.error||"unknown error"}`)}else c.hasAccessToken()&&(a.BearerAccessToken=c.accessToken);B.isDataLoaded=!1,B.isCharacterLoaded=!1,B.isTypeLoaded=!1,B.isLocalDataLoaded=!1,B.isLocalTypeLoaded=!1,B.isLocalCharacterLoaded=!1,B.isConnectionLoaded=!1,B.isConnectionTypeLoaded=!1,B.isLocalConnectionLoaded=!1,yield function(){return Wo(this,void 0,void 0,(function*(){return yield $("settings")[0]||new k(!0),yield function(){return Mo(this,void 0,void 0,(function*(){}))}(),!0}))}(),yield Promise.all([Y().then((()=>{B.isDataLoaded=!0,B.isCharacterLoaded=!0,B.isTypeLoaded=!0})),Vo().then((()=>{B.isLocalDataLoaded=!0,B.isLocalTypeLoaded=!0,B.isLocalCharacterLoaded=!0})),$o().then((()=>{B.isLocalConnectionLoaded=!0})),bo().then((()=>{B.isConnectionLoaded=!0,B.isConnectionTypeLoaded=!0}))])}))}var xi=o.BG,bi=o.$e,$i=o.TR,Li=o.Tc,_i=o.U3,Pi=o.Wg,Oi=o.g2,Ui=o.BO,Bi=o.WW,Di=o.BS,Fi=o.ji,Gi=o.Ij,ji=o.Ng,Vi=o.du,Mi=o.RC,Hi=o.d4,Wi=o.Cd,Ki=o.IM,Xi=o.oI,qi=o.u9,zi=o.B7,Ji=o.mF,Yi=o.Q9,Qi=o.wT,Zi=o.hZ,ec=o.y0,tc=o.iw,nc=o.pU,rc=o.qN,oc=o.mZ,ic=o.Ec,cc=o.L0,sc=o.Te,ac=o.vw,lc=o.z8,uc=o.k9,dc=o.sP,hc=o.Y3,fc=o.WC,pc=o.Nj,yc=o.dF,vc=o.cw,gc=o.p8,mc=o.rv,Cc=o.pX,wc=o.iD,Tc=o.Mb,Ic=o.bq,Nc=o.ke,Ac=o.w1,Ec=o.yz,Sc=o.RW,Rc=o.WL,kc=o.rh,xc=o.nW,bc=o.RH,$c=o.Aj,Lc=o.cV,_c=o.jM,Pc=o.nS,Oc=o.Yu,Uc=o.xf,Bc=o.KS,Dc=o.L6,Fc=o.Z9,Gc=o.Ny,jc=o.qY,Vc=o.jQ,Mc=o.NT,Hc=o.Xr,Wc=o.ab,Kc=o.SV,Xc=o.EA,qc=o.M2,zc=o.OY,Jc=o.ry,Yc=o.cS,Qc=o.ZJ,Zc=o.RA,es=o.BH,ts=o.SL,ns=o.Ne,rs=o.fg,os=o.M4,is=o.UG,cs=o.CT,ss=o.yv,as=o.vI,ls=o.oe,us=o.XZ,ds=o.ZE,hs=o.pi,fs=o.B8,ps=o.yx,ys=o.br,vs=o.eU,gs=o.cf,ms=o.jy,Cs=o.cm,ws=o.qn,Ts=o.ss,Is=o.pf,Ns=o.pZ,As=o.l4,Es=o.f8,Ss=o.Y6,Rs=o.FS,ks=o.bM,xs=o.ZX,bs=o.CE,$s=o.Sf,Ls=o.tp,_s=o.Ry,Ps=o.jh,Os=o.dp,Us=o.a2,Bs=o.C$,Ds=o.J5,Fs=o.sc,Gs=o.x9,js=o.Py,Vs=o.Xc,Ms=o.Ts,Hs=o.P$,Ws=o.xX,Ks=o.ae,Xs=o.zN,qs=o.dU,zs=o.mA,Js=o.En,Ys=o.eD,Qs=o.$Q;export{xi as ALLID,bi as AccessControlService,$i as AddGhostConcept,Li as AddGhostConnection,_i as BaseUrl,Pi as BinaryTree,Oi as CCSConfig,Ui as Composition,Bi as CompositionBinaryTree,Di as CompositionNode,Fi as Concept,Gi as ConceptsData,ji as Connection,Vi as ConnectionData,Mi as CreateComposition,Hi as CreateConnection,Wi as CreateConnectionBetweenTwoConcepts,Ki as CreateConnectionBetweenTwoConceptsGeneral,Xi as CreateDefaultConcept,qi as CreateDefaultLConcept,zi as CreateSession,Ji as CreateSessionVisit,Yi as CreateTheCompositionWithCache,Qi as CreateTheConnectionGeneral,Zi as CreateTypeConcept,ec as DATAID,tc as DATAIDDATE,nc as DATAV2,rc as DeleteConceptById,oc as DeleteConnectionById,ic as DeleteConnectionByIdBulk,cc as DeleteConnectionByTypeBulk,sc as FilterSearch,ac as FormatFromConnections,lc as FreeSchemaResponse,uc as FreeschemaQuery,dc as GetAllConnectionsOfComposition,hc as GetAllConnectionsOfCompositionBulk,fc as GetAllTheConnectionsByTypeAndOfTheConcept,pc as GetComposition,yc as GetCompositionBulk,vc as GetCompositionBulkWithDataId,gc as GetCompositionFromConnectionsWithDataId,mc as GetCompositionFromConnectionsWithDataIdInObject,Cc as GetCompositionList,wc as GetCompositionListWithId,Tc as GetCompositionWithAllIds,Ic as GetCompositionWithCache,Nc as GetCompositionWithDataIdBulk,Ac as GetCompositionWithDataIdWithCache,Ec as GetCompositionWithId,Sc as GetCompositionWithIdFromMemory,Rc as GetCompositionWithIdFromMemoryFromConnections,kc as GetConceptBulk,xc as GetConceptByCharacter,bc as GetConceptByCharacterAndCategoryDirectApi,$c as GetConceptByCharacterAndType,Lc as GetConceptByTypeBulk,_c as GetConnectionBulk,Pc as GetConnectionById,Oc as GetConnectionByTypeBulk,Uc as GetConnectionOfTheConcept,Bc as GetConnectionsBetweenApi,Dc as GetLink,Fc as GetLinkRaw,Gc as GetLinkerConnectionFromConcepts,jc as GetLinkerConnectionToConcepts,Vc as GetRelation,Mc as GetRelationRaw,Hc as GetRequestHeader,Wc as GetRequestHeaderWithAuthorization,Kc as GetTheConcept,Xc as GetUserGhostConnectionId,qc as GetUserGhostId,zc as GiveConnection,Jc as HandleHttpError,Yc as HttpResponse,Qc as JUSTDATA,Zc as LConcept,es as LConnection,ts as LISTNORMAL,ns as LoginToBackend,rs as MakeTheInstanceConcept,os as MakeTheTimestamp,is as MakeTheTypeConcept,cs as MakeTheTypeConceptApi,ss as NORMAL,as as PatcherStructure,ls as PermissionSet,us as RAW,ds as RecursiveSearchApi,hs as ReservedConnectionIds,fs as ReservedIds,ps as SchemaQueryListener,ys as SearchAllConcepts,vs as SearchLinkInternal,gs as SearchLinkMultipleAll,ms as SearchLinkMultipleApi,Cs as SearchQuery,ws as SearchStructure,Ts as SearchWithLinker,Is as SessionData,Ns as Signin,As as Signup,Es as SplitStrings,Ss as SyncData,Rs as TokenRefreshError,ks as TokenStorage,xs as Transaction,bs as TrashTheConcept,$s as UpdateComposition,Ls as UserBinaryTree,_s as ViewInternalData,Ps as buildFetchConnection,Os as convertFromLConceptToConcept,Us as deleteWithRetry,Bs as fetchWithCacheServerFallback,Ds as fetchWithRetry,Fs as getFromDatabaseWithType,Gs as getFromDatabaseWithTypeOld,js as getOAuthToken,Vs as getWithRetry,Ms as init,Hs as patchWithRetry,Ws as postWithRetry,Ks as putWithRetry,Xs as recursiveFetch,qs as recursiveFetchNew,zs as refreshOAuthToken,Js as requestWithRetry,Ys as storeToDatabase,Qs as updateAccessToken};