mftsccs-browser 1.1.21 → 1.1.22

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.js CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ADMIN:()=>Ki,ALLID:()=>yi,AddGhostConcept:()=>si,Anomaly:()=>Pr,BaseUrl:()=>o,BinaryTree:()=>g,Composition:()=>Uo,CompositionBinaryTree:()=>Go,CompositionNode:()=>Ro,Concept:()=>m,ConceptsData:()=>k,Connection:()=>O,ConnectionData:()=>Z,CreateComposition:()=>Pe,CreateConnectionBetweenTwoConcepts:()=>un,CreateConnectionBetweenTwoConceptsGeneral:()=>yn,CreateConnectionBetweenTwoConceptsLocal:()=>Wi,CreateDefaultConcept:()=>C,CreateDefaultLConcept:()=>Nt,CreateSession:()=>Ko,CreateSessionVisit:()=>Yo,CreateTheCompositionLocal:()=>Ke,CreateTheCompositionWithCache:()=>Do,CreateTheConnection:()=>Ce,CreateTheConnectionGeneral:()=>en,CreateTheConnectionLocal:()=>Me,DATAID:()=>di,DATAIDDATE:()=>ui,DelayFunctionExecution:()=>Zi,DeleteConceptById:()=>qn,DeleteConceptLocal:()=>qi,DeleteConnectionById:()=>sn,DeleteConnectionByType:()=>Mr,DependencyObserver:()=>or,FilterSearch:()=>Ar,FormatFromConnections:()=>ki,FormatFromConnectionsAltered:()=>Ii,FreeschemaQuery:()=>Hr,FreeschemaQueryApi:()=>$r,GetAllConnectionsOfComposition:()=>_t,GetAllConnectionsOfCompositionBulk:()=>it,GetComposition:()=>Ft,GetCompositionBulk:()=>eo,GetCompositionBulkWithDataId:()=>no,GetCompositionFromConnectionsWithDataId:()=>oo,GetCompositionFromConnectionsWithDataIdInObject:()=>ao,GetCompositionFromConnectionsWithDataIdIndex:()=>io,GetCompositionFromConnectionsWithIndex:()=>ro,GetCompositionList:()=>ne,GetCompositionListAll:()=>oe,GetCompositionListAllWithId:()=>ie,GetCompositionListListener:()=>hr,GetCompositionListLocal:()=>fe,GetCompositionListLocalWithId:()=>ye,GetCompositionListWithId:()=>re,GetCompositionListWithIdUpdated:()=>ce,GetCompositionListener:()=>sr,GetCompositionLocal:()=>le,GetCompositionLocalWithId:()=>de,GetCompositionWithAllIds:()=>Dt,GetCompositionWithCache:()=>$o,GetCompositionWithDataIdBulk:()=>zo,GetCompositionWithDataIdWithCache:()=>Jo,GetCompositionWithId:()=>Ht,GetCompositionWithIdAndDateFromMemory:()=>Mt,GetConceptBulk:()=>X,GetConceptByCharacter:()=>Kt,GetConceptByCharacterAndCategoryLocal:()=>te,GetConceptByCharacterAndType:()=>Ie,GetConnectionBetweenTwoConceptsLinker:()=>Qi,GetConnectionBulk:()=>Yn,GetConnectionById:()=>cn,GetConnectionDataPrefetch:()=>co,GetConnectionOfTheConcept:()=>Ye,GetLink:()=>Nn,GetLinkListListener:()=>Nr,GetLinkListener:()=>yr,GetLinkRaw:()=>Tn,GetLinkerConnectionFromConcepts:()=>Mn,GetLinkerConnectionToConcepts:()=>Hn,GetRelation:()=>ei,GetRelationLocal:()=>Pi,GetRelationRaw:()=>ni,GetTheConcept:()=>dn,GetTheConceptLocal:()=>Ri,GetUserGhostId:()=>ai,JUSTDATA:()=>hi,LConcept:()=>Tr,LConnection:()=>Ir,LISTNORMAL:()=>pi,LocalConceptsData:()=>Lt,LocalSyncData:()=>kt,LoginToBackend:()=>go,MakeTheInstanceConcept:()=>_e,MakeTheInstanceConceptLocal:()=>Qe,MakeTheTimestamp:()=>Zn,MakeTheTypeConcept:()=>_n,MakeTheTypeConceptApi:()=>Dn,MakeTheTypeConceptLocal:()=>Je,NORMAL:()=>li,PRIVATE:()=>Xi,PUBLIC:()=>Yi,PatcherStructure:()=>wr,RAW:()=>fi,RecursiveSearchApi:()=>uo,RecursiveSearchApiNewRawFullLinker:()=>po,RecursiveSearchApiRaw:()=>fo,RecursiveSearchApiRawFullLinker:()=>yo,RecursiveSearchListener:()=>gr,SchemaQueryListener:()=>zr,SearchAllConcepts:()=>jo,SearchLinkInternal:()=>ji,SearchLinkInternalAll:()=>Mi,SearchLinkMultipleAll:()=>Ti,SearchLinkMultipleAllObservable:()=>ir,SearchLinkMultipleApi:()=>U,SearchQuery:()=>Kn,SearchStructure:()=>xr,SearchWithLinker:()=>Ho,SearchWithTypeAndLinker:()=>mi,SearchWithTypeAndLinkerApi:()=>er,SessionData:()=>kr,Signin:()=>To,Signup:()=>Co,SplitStrings:()=>F,StatefulWidget:()=>Vr,SyncData:()=>me,TrashTheConcept:()=>zn,UpdateComposition:()=>Oo,UpdateCompositionLocal:()=>Gi,UserBinaryTree:()=>ri,Validator:()=>Fr,ViewInternalData:()=>Ei,ViewInternalDataApi:()=>Fi,convertFromConceptToLConcept:()=>Ai,convertFromLConceptToConcept:()=>xi,createFormFieldData:()=>Dr,getFromDatabaseWithType:()=>gn,getObjectsFromIndexDb:()=>mn,init:()=>Kr,recursiveFetch:()=>qt,recursiveFetchNew:()=>Bo,searchLinkMultipleListener:()=>rr,storeToDatabase:()=>vn,updateAccessToken:()=>Zr});class n{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}class o{static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.BASE_URL+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.BASE_URL+"/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 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 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 SearchAllTypeWithLinker(t=!0){return t?this.BASE_URL+"/api/search-all-with-linker-ccs":this.BASE_URL+"/api-search-compositions-internal-clean-ccs"}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 SearchInternalWithCcsUrl(){return this.BASE_URL+"/api-search-compositions-internal-clean-ccs"}static CreateGhostConceptApiUrl(){return o.NODE_URL+"/api/v1/local-concepts"}static CreateGhostConnectionApiUrl(){return o.NODE_URL+"/api/v1/local-connections"}static GetRealConceptById(){return o.NODE_URL+"/api/v1/local-concepts-translate"}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 DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}}o.BASE_URL="https://localhost:7053/",o.AI_URL="https://ai.freeschema.com",o.MQTT_URL="192.168.1.249",o.NODE_URL="http://localhost:5001",o.BASE_APPLICATION="",o.BASE_RANDOMIZER=999;var i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},r=9;class c{}function a(t){return new Promise((function(e,n){c.db&&e(c.db);let i=o.BASE_URL+"_FreeSchema"+o.BASE_APPLICATION;const s=indexedDB.open(i,r);s.onerror=e=>{console.error("Why didn't you allow my web app to use IndexedDB?!",e),indexedDB.deleteDatabase(i),a(t),n(e)},s.onsuccess=function(t){let n=t.target;c.db=n.result,e(c.db)},s.onupgradeneeded=t=>{let n=t.target.result,o="concept",i="connection",c="settings";console.log("this is the version update for index",r),n.objectStoreNames.contains(o)&&n.deleteObjectStore(o),n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.objectStoreNames.contains(c)&&n.deleteObjectStore(c),n.objectStoreNames.contains(o)||(n.createObjectStore(o,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(i)||(n.createObjectStore(i,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(c)||(n.createObjectStore(c,{keyPath:"id"}).transaction.oncomplete=t=>{}),e(n)}}))}function s(t,e){return new Promise((function(n,o){console.log("this is storing to the database",e),a(t).then((i=>{if(0!=e.id){const r=i.transaction(t,"readwrite").objectStore(t).add(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot store to the database"+t,data:n,body:e})}}})).catch((t=>{o({status:400,ok:!1,message:"Cannot store to the database because you cannot open the database",data:t})}))}))}function l(t,e){return new Promise((function(n,o){console.log("this is wriring to the database",e),a(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).put(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot Update to the database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot update to database because you cannot open the database",data:t})}))}))}function d(t){return i(this,void 0,void 0,(function*(){return new Promise((function(e,n){a(t).then((n=>{let o=[],i=n.transaction(t,"readwrite").objectStore(t).getAll();i.onsuccess=()=>{const t=i.result;for(let e=0;e<t.length;e++)o.push(t[e]);e(o)}})).catch((t=>{n({status:400,ok:!1,message:"Cannot get objects from the database because you cannot open the database",data:t})}))}))}))}function h(t,e){return new Promise((function(n,o){a(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).delete(Number(e));r.onsuccess=function(t){n(e)},r.onerror=e=>{o({status:400,ok:!1,message:"Cannot remove from the database"+t,data:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot remove from the database because you cannot open the database",data:t,body:e})}))}))}class u{}u.isTypeLoaded=!1,u.isCharacterLoaded=!1,u.isDataLoaded=!1,u.isLocalDataLoaded=!1,u.isLocalCharacterLoaded=!1,u.isLocalTypeLoaded=!1,u.isConnectionLoaded=!1,u.isConnectionTypeLoaded=!1,u.isLocalConnectionLoaded=!1;class f{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;let n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}checkIfIdsInNode(t,e,n,o){if(t){if(e.includes(t.key)){n.push(t.value);let o=e.indexOf(t.key);e.splice(o,1)}t.leftNode&&this.checkIfIdsInNode(t.leftNode,e,n,o),t.rightNode&&this.checkIfIdsInNode(t.rightNode,e,n,o)}}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key){return this.rightRotate(e)}if(t.key>e.leftNode.key){return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key){return this.leftRotate(e)}if(t.key<e.rightNode.key){return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return console.log("adding the type node to the tree",t),t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return console.log("adding the type node to the tree down",t),e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),console.log("adding the type node to the tree last",e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key){return this.rightRotate(e)}if(t.key>e.leftNode.key){return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key){return this.leftRotate(e)}if(t.key<e.rightNode.key){return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getCharacterFromNodeUpdated(t,e){var n;return e?t==e.key||51==(null===(n=e.value)||void 0===n?void 0:n.typeId)?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNode(t.rightNode,e.key),t}}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){let e=t.variants[0];if(e)return t.value=e.value,t.key=e.key,t.currentNode=e.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,e.key,n),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var y=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class p{static waitForDataToLoad(){return y(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isCharacterLoaded)return t("done");setTimeout(p.checkFlag,1e3,t)}static addNodeToTree(t){return y(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=t,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(t,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(t,e){return y(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,t,e)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(t){if(""!=t.characterValue){var e=new f(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(t,e){return y(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return y(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(t,e,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(t){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,t))}}p.characterRoot=null;var v=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class g{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return v(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isDataLoaded)return t("done");setTimeout(g.checkFlag,1e3,t)}static addConceptToTree(t){let e=new f(t.id,t,null,null),n=new f(t.characterValue,t,null,null);p.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return v(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return v(this,void 0,void 0,(function*(){if(this.root){let e=new Event(`${t}`);console.log("this is the fired event after delete",e),dispatchEvent(e),this.root=this.root.removeNode(this.root,t)}}))}static getConceptListFromIds(t,e,n){return v(this,void 0,void 0,(function*(){this.root&&this.root.checkIfIdsInNode(this.root,t,e,n)}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}g.root=null;class m{constructor(t,e,n,i,r,c,a,s=!1,l,d,h){this.count=0,this.typeCharacter="",this.isComposition=!1,this.isTemp=!1,this.isSynced=!1,this.applicationId=o.BASE_RANDOMIZER,this.x=0,this.y=0,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=i,this.referentId=r,this.characterValue=`${c}`,this.accessId=a,this.typeCharacter=h,this.type=null,this.isNew=s,this.entryTimeStamp=l,this.updatedTimeStamp=d}getType(){console.log(this.typeId)}}function C(){let t=new Date,e=new Date;return new m(0,0,0,0,0,"0",0,!1,t,e,"0")}class N{constructor(t,e){this.value=[],this.height=1,this.key=t,this.value.push(e),this.leftNode=null,this.rightNode=null,this.currentNode=null}addType(t,e,n){var o,i,r,c;if(null==t)return new N(e,n);if(e<t.key)t.leftNode=this.addType(t.leftNode,e,n);else{if(!(e>t.key))return t.value.push(n),t;t.rightNode=this.addType(t.rightNode,e,n)}t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1;const a=this.getBalanceFactor(t);return a>1&&e<(null===(o=t.leftNode)||void 0===o?void 0:o.key)?this.rightRotate(t):a<-1&&e>(null===(i=t.rightNode)||void 0===i?void 0:i.key)?this.leftRotate(t):a>1&&e>(null===(r=t.leftNode)||void 0===r?void 0:r.key)?(t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)):a<-1&&e<(null===(c=t.rightNode)||void 0===c?void 0:c.key)?(t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)):t}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.value.length>0)for(let e=0;e<t.value.length;e++)if(n==t.value[e])return t.value.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.currentNode=e.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,e.key,n),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var T=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class I{static addType(t){return T(this,void 0,void 0,(function*(){if(null==this.root)return this.root=t,this.root;{let e=new CustomEvent(`${t.key}`,{detail:t.value[0]});dispatchEvent(e),this.root=this.root.addType(this.root,t.key,t.value[0])}return this.root}))}static addConceptToTree(t){if(0!=t.typeId){let e=new N(t.typeId,t.id);this.addType(e)}}static removeTypeConcept(t,e){this.root&&(this.root=this.root.removeNodeWithVariants(this.root,t,e))}static getNodeFromTreeNew(t){return this.root?this.root.getFromNode(t,this.root):this.root}static getTypeVariantsFromTreeNew(t){return T(this,void 0,void 0,(function*(){let e=this.getNodeFromTreeNew(t),n=[],o=[];if(e){n=e.value;for(let t=0;t<n.length;t++){let e=!1;for(let i=0;i<o.length;i++)o[i].id==n[t]&&(e=!0);e||o.push(yield dn(n[t]))}}return o}))}static waitForDataToLoad(){return T(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isTypeLoaded)return t("done");setTimeout(I.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserIdNew(t,e){return T(this,void 0,void 0,(function*(){let n=[],o=yield this.getTypeVariantsFromTreeNew(t);console.log("these are all the concepts",o);for(let t=0;t<o.length;t++)o[t].userId==e&&n.push(o[t]);return n}))}static getTypeVariantsWithCharacterValueNew(t,e){return T(this,void 0,void 0,(function*(){let n=yield this.getTypeVariantsFromTreeNew(e);console.log("this is all the concepts for character",n);let o=C();for(let e=0;e<n.length;e++)n[e].characterValue==t&&(o=n[e]);return o}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}I.typeRoot=null,I.root=null;var w=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class k{constructor(){this.name="conceptsArray"}static CheckContains(t){for(var e=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==t.id&&(e=!0);return e}static AddNpc(t){this.NPC.includes(t)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(t))}static GetNpc(t){return!!this.NPC.includes(t)}static AddConceptToStorage(t){t.id>0&&l("concept",t)}static GetConceptBulkData(t,e,n){return w(this,void 0,void 0,(function*(){yield g.getConceptListFromIds(t,e,n)}))}static AddConcept(t){t.id>0&&(g.addConceptToTree(t),I.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(g.addConceptToTree(t),I.addConceptToTree(t))}static AddConceptTemporary(t){var e=this.CheckContains(t);this.conceptDictionary[t.id]=t,e&&this.RemoveConcept(t),this.conceptsArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsArray.length;e++)this.conceptsArray[e].id==t.id&&this.conceptsArray.splice(e,1);h("concept",t.id)}static GetConcept(t){return w(this,void 0,void 0,(function*(){var e=C(),n=yield g.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return w(this,void 0,void 0,(function*(){var e=C(),n=p.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return w(this,void 0,void 0,(function*(){var e=C(),n=p.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return w(this,void 0,void 0,(function*(){return C(),yield I.getTypeVariantsWithCharacterValueNew(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return w(this,void 0,void 0,(function*(){var n=C(),o=yield p.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==t&&e.push(this.conceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return w(this,void 0,void 0,(function*(){let n=[];return n=yield I.getTypeVariantsFromTreeWithUserIdNew(t,e),n}))}static GetBinaryCharacterTree(){return p.characterRoot}getName(){return this.name}}k.conceptsArray=[],k.NPC=[],k.conceptDictionary=[];var A=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function x(){return A(this,void 0,void 0,(function*(){try{let t=yield d("concept");if(Array.isArray(t))for(let e=0;e<t.length;e++){let n=t[e];k.AddConceptToMemory(n)}u.isDataLoaded=!0,u.isCharacterLoaded=!0,u.isTypeLoaded=!0}catch(t){throw yield Zi(2e3,x()),{message:"Cannot create Binary Tree Concept",ok:!1,status:400,data:t}}}))}class S{constructor(t,e,n,i){this.url=o.BASE_URL,this.message=t,this.ok=e,this.status=n,this.data=i}getMessage(){return this.message}setMessage(t){return this.message=t,this}getStatus(){return this.status}setStatus(t){return this.status=t,this}getData(){return this.data}setData(t){return this.data=t,this}getOk(){return this.ok}setOk(t){return this.ok=t,this}getUrl(){return this.url}setUrl(t){return this.url=t,this}}function L(t){if(401==t.status||406==t.status){let e=new S(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}if(500==t.status){let e=new S(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}}function R(t,e=""){if(t.status){let n=new S(t.message,!1,t.status,t.stack);throw n.setUrl(e),n}{let n=new S(t.message,!1,500,t.stack);throw n.setUrl(e),n}}class b{}function G(t="application/json",e="application/json"){return{"Content-Type":t,Authorization:"Bearer "+b.BearerAccessToken,Accept:e}}function _(t="application/json",e="",n="application/json"){return""==e&&(e=b.BearerAccessToken),{"Content-Type":t,Authorization:"Bearer "+e,Accept:n}}function B(){let t=b.BearerAccessToken;const e=new Headers;return e.append("Authorization","Bearer "+t),e}b.BearerAccessToken="";var P=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function U(t){return P(this,arguments,void 0,(function*(t,e=""){var n=_("application/json",e);const i=o.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(L(t),console.log("This is the searching multiple error",t.status),[])}catch(t){console.log("This is the searching multiple error",t),R(t,i)}}))}function F(t){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}var D=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function E(t,e){return D(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",t),n.append("user_id",e.toString());var i=G("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:n});if(c.ok){const t=yield c.json();for(var r=0;r<t.length;r++)k.AddConcept(t[r])}else console.log("GetAllConceptsByType error",c.status),L(c)}catch(t){t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),R(t,o.GetAllConceptsByTypeUrl())}}))}class O{constructor(t=0,e,n,i,r,c,a){this.count=0,this.isTemp=!1,this.toUpdate=!1,this.applicationId=o.BASE_RANDOMIZER,this.type=C(),this.ofConcept=C(),this.toConcept=C(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.userId=i,this.typeId=r,this.ghostId=t,this.orderId=c,this.accessId=a,this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date,this.typeCharacter=""}}class V{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;let n=!1;t.value.id==e.value.id&&(n=!0);for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key){return this.rightRotate(e)}if(t.key>e.leftNode.key){return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key){return this.leftRotate(e)}if(t.key<e.rightNode.key){return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?(e.value.count?e.value.count++:e.value.count=1,e):t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}checkIfIdsInNode(t,e,n,o){if(t){if(e.includes(t.key)){n.push(t.value);let o=e.indexOf(t.key);e.splice(o,1)}t.leftNode&&this.checkIfIdsInNode(t.leftNode,e,n,o),t.rightNode&&this.checkIfIdsInNode(t.rightNode,e,n,o)}}traverse(t){let e=0;return t&&(e+=1,(null==t?void 0:t.leftNode)&&(e+=this.traverse(t.leftNode)),t.rightNode&&(e+=this.traverse(t.rightNode))),e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;let n=new Event(`${t.value.ofTheConceptId}`);if(dispatchEvent(n),null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNode(t.rightNode,e.key),t}}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){let e=t.variants[0];if(e)return t.value=e.value,t.key=e.key,t.currentNode=e.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,e.key,n),t}}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var j=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class M{static addNodeToTree(t){if(null==this.connectionroot)return this.connectionroot=t,this.connectionroot;this.connectionroot=this.connectionroot.addNode(t,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(t){let e=new V(t.id,t,null,null);this.addNodeToTree(e)}static traverse(){var t;return null===(t=this.connectionroot)||void 0===t?void 0:t.traverse(this.connectionroot)}static waitForDataToLoad(){return j(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isConnectionLoaded)return t("done");setTimeout(M.checkFlag,1e3,t)}static removeNodeFromTree(t){return j(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return j(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}static getConnectionListFromIds(t,e,n){return j(this,void 0,void 0,(function*(){this.connectionroot&&this.connectionroot.checkIfIdsInNode(this.connectionroot,t,e,n)}))}}M.connectionroot=null;class H{constructor(t,e,n,o){this.key="",this.value=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNode(t.rightNode,e.key),t}}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}class W extends H{constructor(t,e,n,o){super(t,e,n,o),this.key="",this.value=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}addNode(t,e,n){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}}var $=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class q{static CreateCompositionKey(t,e){return t}static GetConnectionByOfTheConceptAndTypeId(t,e){let n=this.CreateCompositionKey(t,e);if(this.node){let t=this.node.getFromNode(n,this.node);if(t)return t.value}return null}static addConnection(t){if(t.id>0){let e=this.CreateCompositionKey(t.ofTheConceptId,t.typeId);if(this.node){let n=this.node.getFromNode(e,this.node);if(n){let e=null==n?void 0:n.value;0==e.length&&(n.value=[]),e.includes(t.id)||e.push(t.id)}else{let n=[];n.push(t.id);let o=new W(e,n,null,null);this.addNodeToTree(o)}}else{let n=[];n.push(t.id);let o=new W(e,n,null,null);this.addNodeToTree(o)}let n=new Event(`${e}`);dispatchEvent(n)}else console.log("cannot insert key id with n 0 to the connection tree",t)}static addNodeToTree(t){return $(this,void 0,void 0,(function*(){return null==this.node?(this.node=t,this.node):(this.node=this.node.addNode(t,this.node,this.node.height),this.node)}))}static removeNodeFromTree(t){return $(this,void 0,void 0,(function*(){this.node&&(this.node=this.node.removeNode(this.node,t))}))}}q.node=null;class J extends H{constructor(t,e,n,o){super(t,e,n,o),this.key="",this.value=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}addNode(t,e,n){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}}class z{static CreateCompositionKey(t){return t}static addNodeToTree(t){return e=this,n=void 0,i=function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=t,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addNode(t,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)},new((o=void 0)||(o=Promise))((function(t,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}));var e,n,o,i}static addConnectionToTree(t){if(t.id>0){let e=this.CreateCompositionKey(t.typeId);if(this.connectionTypeRoot){let n=this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot);if(n){let e=null==n?void 0:n.value;0==e.length&&(n.value=[]),e.includes(t.id)||e.push(t.id)}else{let n=[];n.push(t.id);let o=new J(e,n,null,null);this.addNodeToTree(o)}}else{let n=[];n.push(t.id);let o=new J(e,n,null,null);this.addNodeToTree(o)}}else console.log("cannot insert key id with n 0 to the connection tree",t)}static GetConnectionByOfTheConceptAndTypeId(t,e){let n=this.CreateCompositionKey(e);if(this.connectionTypeRoot){let t=this.connectionTypeRoot.getFromNode(n,this.connectionTypeRoot);if(t)return t.value}return null}}z.connectionTypeRoot=null;var Q=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Z{constructor(){this.name="Connection Array"}static CheckContains(t){let e=!1;for(let n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnectionToStorage(t){l("connection",t)}static AddConnection(t){M.addConnectionToTree(t),z.addConnectionToTree(t),q.addConnection(t)}static AddConnectionToMemory(t){t.isTemp||(M.addConnectionToTree(t),z.addConnectionToTree(t),q.addConnection(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(h("connection",t.id),M.removeNodeFromTree(t.id),q.removeNodeFromTree(t.id))}static GetConnectionTypeOfTree(){q.node}static GetConnectionByOfTheConceptAndType(t,e){return q.GetConnectionByOfTheConceptAndTypeId(t,e)||[]}static GetConnectionByOfType(t,e){return z.GetConnectionByOfTheConceptAndTypeId(t,e)||[]}static GetConnectionTree(){return M.connectionroot}static GetConnectionTypeTree(){return z.connectionTypeRoot}static GetConnectionBulkData(t,e,n){return Q(this,void 0,void 0,(function*(){yield M.getConnectionListFromIds(t,e,n)}))}static GetConnection(t){return Q(this,void 0,void 0,(function*(){let e=new O(0,0,0,0,0,0,0),n=yield M.getNodeFromTree(t);if(null==n?void 0:n.value){let t=n.value;t&&(e=t)}return e}))}static GetConnectionsOfCompositionLocal(t){return Q(this,void 0,void 0,(function*(){let e=[],n=[];n=Z.GetConnectionByOfType(t,t);for(let t=0;t<n.length;t++){let o=yield M.getNodeFromTree(n[t]);o&&e.push(o.value)}return e}))}static GetConnectionsOfConcept(t){return Q(this,void 0,void 0,(function*(){let e=[],n=[];e=Z.GetConnectionByOfTheConceptAndType(t,t);for(let t=0;t<e.length;t++){let o=yield M.getNodeFromTree(e[t]);o&&n.push(o.value)}return n}))}getName(){return this.name}}Z.connectionArray=[],Z.connectionDictionary=[];var K=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function X(t){return K(this,void 0,void 0,(function*(){let e=[],n=((new Date).getTime(),Array.from(new Set(t)));try{if(n.length>0){let t=[];for(let e=0;e<n.length;e++)0==(yield k.GetConcept(n[e])).id&&t.push(n[e]);if(0==t.length)return e;{let n=G();const i=yield fetch(o.GetConceptBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){if(e=yield i.json(),console.log("got all the concepts",e),e.length>0)for(let t=0;t<e.length;t++){let n=e[t];k.AddConcept(n)}console.log("added the concepts")}else console.log("Get Concept Bulk error",i.status),L(i)}}}catch(t){t instanceof Error?console.log("Get Concept Bulk error message: ",t.message):console.log("Get Concept Bulk unexpected error: ",t),R(t,o.GetConceptBulkUrl())}return e}))}var Y=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function tt(){return Y(this,arguments,void 0,(function*(t=[]){let e=[];if(t.length>0){for(let n=0;n<t.length;n++)e.includes(t[n].ofTheConceptId)||e.push(t[n].ofTheConceptId),e.includes(t[n].toTheConceptId)||e.push(t[n].toTheConceptId);yield X(e)}}))}var et=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function nt(){return et(this,arguments,void 0,(function*(t=[]){let e=[];for(let n=0;n<t.length;n++){let o=yield Z.GetConnectionsOfConcept(t[n]);e.push(...o)}return e}))}var ot=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function it(){return ot(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length<=0)return e;yield nt(t);var n=yield function(){return ot(this,arguments,void 0,(function*(t=[]){var e=[];try{var n=G();const r=yield fetch(o.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)Z.AddConnection(t[i]),e.push(t[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),L(r);return e}catch(t){t instanceof Error?console.log("Get all connections of composition bulk error message: ",t.message):console.log("Get all connections of composition bulk unexpected error: ",t),R(t,o.GetAllConnectionsOfCompositionBulkUrl())}}))}(t);return e=n,yield tt(e),e}))}var rt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},ct=9;class at{}function st(t){return new Promise((function(e,n){at.db&&e(at.db);let i=o.BASE_URL+"_FreeSchemaLocal"+o.BASE_APPLICATION;const r=indexedDB.open(i,ct);r.onerror=e=>{console.error("Why didn't you allow my web app to use IndexedDB?!",e),indexedDB.deleteDatabase(i),st(t),n(e)},r.onsuccess=function(t){var n=t.target;at.db=n.result,e(at.db)},r.onupgradeneeded=t=>{var n=t.target.result,i="localconcept",r="localconnection",c="localid";console.log("this is the version upgrade",ct),n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.objectStoreNames.contains(r)&&n.deleteObjectStore(r),n.objectStoreNames.contains(c)&&n.deleteObjectStore(c),n.objectStoreNames.contains(i)||(n.createObjectStore(i,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(r)||(n.createObjectStore(r,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(c)||(n.createObjectStore(c,{keyPath:"id"}).transaction.oncomplete=t=>{dt(c,{id:0,value:-100}),dt(c,{id:1,value:-200}),dt(c,{id:3,value:o.BASE_RANDOMIZER})}),e(n)}}))}function lt(t){return rt(this,void 0,void 0,(function*(){return new Promise((function(e,n){st(t).then((n=>{var o=[],i=n.transaction(t,"readwrite").objectStore(t).getAll();i.onsuccess=()=>{const t=i.result;for(var n=0;n<t.length;n++)o.push(t[n]);e(o)}})).catch((t=>{n({status:400,ok:!1,message:"Cannot get objects from database because you cannot open the Local database",data:t})}))}))}))}function dt(t,e){return new Promise((function(n,o){st(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).add(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot store to the Local database "+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot store to database because you cannot open the Local database",data:t})}))}))}function ht(t,e){return new Promise((function(n,o){console.log("this is wriring to the database local",e),st(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).put(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot Update to the Local database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot update to database because you cannot open the Local database",data:t})}))}))}function ut(t,e){return new Promise((function(n,o){st(t).then((i=>{let r=i.transaction(t,"readwrite").objectStore(t).delete(e);r.onsuccess=function(t){n(e)},r.onerror=function(n){o({status:400,ok:!1,message:"Cannot Update to the Local database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot remove object from database because you cannot open the Local database",data:t})}))}))}class ft{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}updateNodeSyncStatus(t,e,n){if(n){if(t==n.key){let t=n.value;return t.isSynced=e,n.value=t,n}return t<n.key?this.updateNodeSyncStatus(t,e,n.leftNode):t>n.key?this.updateNodeSyncStatus(t,e,n.rightNode):n}return n}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var yt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class pt{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new ft(t.id,t,null,null);new ft(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return yt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalDataLoaded)return t("done");setTimeout(pt.checkFlag,1e3,t)}static getNodeFromTree(t){return yt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static getCharacterAndTypeFromTree(t,e){return this.root?this.root.getFromNodeWithCharacterAndType(t,e,this.root):this.root}static updateSyncStatus(t){return this.root?this.root.updateNodeSyncStatus(t,!0,this.root):this.root}static removeNodeFromTree(t){return yt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}pt.root=null;var vt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class gt{static waitForDataToLoad(){return vt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalCharacterLoaded)return t("done");setTimeout(gt.checkFlag,1e3,t)}static addNodeToTree(t){return vt(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=t,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(t,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(t){if(""!=t.characterValue){var e=new ft(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(t,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(t,e){return vt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static getCharacterAndCategoryFromTree(t,e){return vt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndCategory(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(t,e){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,t,e))}}gt.LocalCharacterRoot=null;var mt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ct{static addNodeToTree(t){return mt(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=t,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(t,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(t){if(0!=t.typeId){var e=new ft(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeConceptType(t,e){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,t,e))}static getNodeFromTree(t){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(t,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return mt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalTypeLoaded)return t("done");setTimeout(Ct.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return mt(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad()}catch(t){return n}var o=this.getNodeFromTree(t);if(o){console.log("this is the node to type",o),o.value.userId!=e&&999!=o.value.userId||n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId!=e&&999!=o.value.userId||n.push(o.variants[t].value)}return n}))}}function Nt(){let t=new Date,e=new Date;return new m(0,0,0,0,0,"0",0,!1,t,e,"0")}Ct.LocalTypeRoot=null;var Tt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class It{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new ft(t.ghostId,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return Tt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalDataLoaded)return t("done");setTimeout(It.checkFlag,1e3,t)}static getNodeFromTree(t){return Tt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return Tt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}It.root=null;var wt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class kt{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){try{let e=!1;0!=kt.CheckIfTheConceptIdExists(t.id,this.conceptsSyncArray).id&&(e=!0),e||this.conceptsSyncArray.push(t)}catch(t){throw t}}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static SyncDataOnline(){return wt(this,void 0,void 0,(function*(){try{let t=this.conceptsSyncArray.slice(),e=this.connectionSyncArray.slice();this.connectionSyncArray=[],this.conceptsSyncArray=[];let n=[];for(let e=0;e<t.length;e++)n.push(t[e]),yield Lt.UpdateConceptSyncStatus(t[e].id);yield this.UpdateConceptListToIncludeRelatedConcepts(e,n);let i=yield function(t,e){return n=this,i=void 0,c=function*(){let n={concepts:[],connections:[]};try{const i=new Headers;let r={concepts:t,connections:e};i.set("Content-Type","application/json"),i.set("Authorization","Bearer "+b.BearerAccessToken),i.set("Accept","application/json"),i.set("Randomizer",o.BASE_RANDOMIZER.toString());const c=yield fetch(o.CreateGhostConceptApiUrl(),{method:"POST",headers:i,body:JSON.stringify(r)});if(!c.ok)throw L(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();return n.concepts=a.concepts,n.connections=a.connections,n}catch(t){throw t instanceof Error?console.log("Create the concept api error message: ",t.message):console.log("Create the concept api unexpected error: ",t),t}},new((r=void 0)||(r=Promise))((function(t,e){function o(t){try{s(c.next(t))}catch(t){e(t)}}function a(t){try{s(c.throw(t))}catch(t){e(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(o,a)}s((c=c.apply(n,i||[])).next())}));var n,i,r,c}(n,e),r=i.concepts,c=i.connections;for(let t=0;t<r.length;t++)Lt.AddPermanentConcept(r[t]);for(let t=0;t<c.length;t++)xt.AddPermanentConnection(c[t]);return t}catch(t){throw t}}))}static ConvertGhostIdsInConnections(t){var e,n,o;for(let i=0;i<t.length;i++){let r=t[i].ofTheConceptId,c=t[i].toTheConceptId,a=t[i].typeId,s=null!==(e=kt.ghostIdMap.get(r))&&void 0!==e?e:r,l=null!==(n=kt.ghostIdMap.get(c))&&void 0!==n?n:c,d=null!==(o=kt.ghostIdMap.get(a))&&void 0!==o?o:a;t[i].ofTheConceptId=s,t[i].toTheConceptId=l,t[i].typeId=d}}static UpdateConceptListToIncludeRelatedConcepts(t,e){return wt(this,void 0,void 0,(function*(){for(let n=0;n<t.length;n++){let o=t[n].ofTheConceptId,i=t[n].toTheConceptId,r=t[n].typeId;if(o<0){let i=this.CheckIfTheConceptIdExists(o,e);0==i.id&&(i=yield Lt.GetConceptByGhostId(o),0!=i.id?i.id!=i.ghostId&&(t[n].ofTheConceptId=i.id):(i=yield Lt.GetConcept(o),this.AddConceptIfDoesNotExist(i,e)))}if(i<0){let o=this.CheckIfTheConceptIdExists(i,e);0==o.id&&(o=yield Lt.GetConceptByGhostId(i),0!=o.id?o.id!=o.ghostId&&(t[n].toTheConceptId=o.id):(o=yield Lt.GetConcept(i),this.AddConceptIfDoesNotExist(o,e)))}if(r<0){let o=this.CheckIfTheConceptIdExists(r,e);0==o.id&&(o=yield Lt.GetConceptByGhostId(r),0!=o.id?o.id!=o.ghostId&&(t[n].typeId=o.id):(o=yield Lt.GetConcept(r),this.AddConceptIfDoesNotExist(o,e)))}}}))}static AddConceptIfDoesNotExist(t,e=[]){let n=!1;for(let o=0;o<e.length;o++)t.ghostId==e[o].ghostId&&(n=!0);n||e.push(t)}static CheckIfTheConceptIdExists(t,e=[]){let n=Nt();for(let o=0;o<e.length;o++)t!=e[o].ghostId&&t!=e[o].id||(n=e[o]);return n}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static RemoveConnectionById(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t&&this.connectionSyncArray.splice(e,1)}static syncDataLocalDb(){return wt(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)ht("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)ht("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}kt.conceptsSyncArray=[],kt.connectionSyncArray=[],kt.ghostIdMap=new Map;var At=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class xt{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnection(t){this.CheckContains(t)&&this.RemoveConnection(t),0!=t.id&&ht("localconnection",t),this.connectionArray.push(t)}static AddConnectionToMemory(t){this.CheckContains(t)&&this.RemoveConnection(t),this.connectionArray.push(t)}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t.id&&this.connectionArray.splice(e,1);t.id}static RemoveConnectionById(t){for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t&&this.connectionArray.splice(e,1);kt.RemoveConnectionById(t)}static AddPermanentConnection(t){t.id>0&&(ut("localconnection",t.ghostId),Z.AddConnection(function(t){let e=new O(0,0,0,0,0,0,0);return e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.typeId=t.typeId,e.orderId=t.orderId,e.id=t.id,e}(t)))}static GetConnection(t){var e;e=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t&&(e=this.connectionArray[n]);return e}static waitForDataToLoad(){return At(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalConnectionLoaded)return t("done");setTimeout(xt.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return At(this,void 0,void 0,(function*(){var e=[];try{yield this.waitForDataToLoad();for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==t&&e.push(this.connectionArray[n]);return e}catch(t){return e}}))}static GetConnectionOfCompositionAndTypeLocal(t,e){return At(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad(),console.log("this is the connections",this.connectionArray,t,e);for(var o=0;o<this.connectionArray.length;o++)this.connectionArray[o].typeId==t&&this.connectionArray[o].ofTheConceptId==e&&n.push(this.connectionArray[o]);return n}catch(t){return n}}))}getName(){return this.name}}xt.connectionArray=[],xt.connectionDictionary=[];var St=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Lt{constructor(){this.name="conceptsArray"}static AddConcept(t){0!=t.id&&(ht("localconcept",t),pt.addConceptToTree(t),gt.addConceptToTree(t),Ct.addConceptToTree(t),this.localconceptsArray.push(t))}static AddPermanentConcept(t){0!=t.id&&(pt.removeNodeFromTree(t.ghostId),gt.removeConceptType(t.characterValue,t.ghostId),Ct.removeConceptType(t.typeId,t.ghostId),It.addConceptToTree(t),ut("localconcept",t.ghostId),k.AddConcept(t))}static RemoveConcept(t){return St(this,void 0,void 0,(function*(){try{0!=t.id&&(pt.removeNodeFromTree(t.ghostId),gt.removeConceptType(t.characterValue,t.ghostId),Ct.removeConceptType(t.typeId,t.ghostId),yield ut("localconcept",t.ghostId))}catch(t){throw t}}))}static RemoveConceptById(t){return St(this,void 0,void 0,(function*(){try{let e=yield Lt.GetConcept(t);0!=e.id&&(pt.removeNodeFromTree(t),gt.removeConceptType(e.characterValue,e.ghostId),Ct.removeConceptType(e.typeId,e.ghostId),kt.RemoveConcept(e))}catch(t){throw t}}))}static AddConceptToMemory(t){0!=t.id&&(pt.addConceptToTree(t),gt.addConceptToTree(t),Ct.addConceptToTree(t))}static GetConcept(t){return St(this,void 0,void 0,(function*(){var e=Nt(),n=yield pt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static UpdateConceptSyncStatus(t){return St(this,void 0,void 0,(function*(){pt.updateSyncStatus(t)}))}static GetConceptByGhostId(t){return St(this,void 0,void 0,(function*(){var e=Nt(),n=yield It.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return St(this,void 0,void 0,(function*(){var e=Nt(),n=gt.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return St(this,void 0,void 0,(function*(){var n=Nt(),o=yield gt.getCharacterAndTypeFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptByCharacterAndCategoryLocal(t,e){return St(this,void 0,void 0,(function*(){var n=Nt(),o=yield gt.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==t&&e.push(this.localconceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return St(this,void 0,void 0,(function*(){let n=[];return n=yield Ct.getTypeVariantsFromTreeWithUserId(t,e),n}))}static ClearData(){return St(this,void 0,void 0,(function*(){this.localconceptsArray=[],xt.connectionArray=[]}))}getName(){return this.name}}Lt.localconceptsArray=[];var Rt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bt(t){return Rt(this,void 0,void 0,(function*(){try{let n=C();var e=yield k.GetConcept(t);let i=k.GetNpc(t);if(0!=e.id||i)return e;{G(),console.log("this is the url",o.GetConceptUrl());const e=new FormData;e.append("id",t.toString());const i=yield fetch(o.GetConceptUrl(),{method:"POST",body:e});return i.ok?(n=yield i.json(),n.id>0?k.AddConcept(n):k.AddNpc(t)):(console.log("Get the concept error",i.status),L(i)),n}}catch(t){t instanceof Error?console.log("Get the concept error message: ",t.message):console.log("Get the concept unexpected error: ",t),R(t,o.GetConceptUrl())}}))}var Gt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _t(t){return Gt(this,void 0,void 0,(function*(){var e=[];0==(e=yield Z.GetConnectionsOfConcept(t)).length?e=yield Bt(t):e=yield Bt(t);return e}))}function Bt(t){return Gt(this,void 0,void 0,(function*(){var e=[];try{G("application/json");const i=new Headers,r=new FormData;r.append("composition_id",t.toString());const c=yield fetch(o.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:i,body:r});if(console.log("this is getting connection from online",o.GetAllConnectionsOfCompositionUrl(),t),!c.ok)throw L(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();for(var n=0;n<a.length;n++)Z.AddConnection(a[n]),e.push(a[n]);return e}catch(t){t instanceof Error?console.log("Get all connection of composition error : ",t.message):console.log("Get all connection of composition error : ",t),R(t,o.GetAllConnectionsOfCompositionUrl())}}))}var Pt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ut(t,e,n){return Pt(this,void 0,void 0,(function*(){var o,i;let r={},c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,e,n);return r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a,r}))}function Ft(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield _t(t),console.log("this is the connection list online",o);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,o,r);return i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a,i}))}function Dt(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield _t(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield Jt(t,o,r);return i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a,i}))}function Et(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield Z.GetConnectionsOfCompositionLocal(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield Wt(c,o,r);return i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a,i}))}function Ot(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield Z.GetConnectionsOfCompositionLocal(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield $t(c,o,r);return i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a,i}))}function Vt(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield Z.GetConnectionsOfCompositionLocal(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield Wt(c,o,r);i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a;let s={};return s.created_at=c.entryTimeStamp,s.data=i,s.id=t,s}))}function jt(t){return Pt(this,void 0,void 0,(function*(){var e;let n=[],o={};n=yield Z.GetConnectionsOfCompositionLocal(t);let i=[];for(let t=0;t<n.length;t++)i.includes(n[t].ofTheConceptId)||i.push(n[t].ofTheConceptId);let r=yield k.GetConcept(t);0==r.id&&null!=t&&null!=t&&(console.log("this concept you cannot find ",t),r=yield bt(t));let c=(new Date).getTime(),a=yield function(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a,s,l,d,h;let u={},f=t.id,y=((new Date).getTime(),null!==(r=null===(i=null==t?void 0:t.type)||void 0===i?void 0:i.characterValue)&&void 0!==r?r:"");if(!n.includes(f)){let e=y;return{[e]:null==t?void 0:t.characterValue}}if(o.includes(f))return"";o.push(f);for(let t=0;t<e.length;t++){let n=yield dn(e[t].ofTheConceptId),o=yield dn(e[t].toTheConceptId);e[t].ofConcept=n,e[t].toConcept=o;let i=n.id,r="the_",s=(null!==(a=null===(c=null==o?void 0:o.type)||void 0===c?void 0:c.characterValue)&&void 0!==a?a:"").replace(r,"");null!=u[i]&&null!=u[i]||(u[i]={}),u[i][s]=o.characterValue}let p={};for(let t=0;t<e.length;t++){let n=e[t].ofConcept,o=e[t].toConcept,i=null!==(l=null===(s=null==n?void 0:n.type)||void 0===s?void 0:s.characterValue)&&void 0!==l?l:"",r="the_",c=(null!==(h=null===(d=null==o?void 0:o.type)||void 0===d?void 0:d.characterValue)&&void 0!==h?h:"").replace(r,"");null!=p[n.id]&&null!=p[n.id]||(p[n.id]={});let a=p[n.id];null!=a[i]&&null!=a[i]||(a[i]={}),null!=u[e[t].ofTheConceptId]&&null!=u[e[t].toTheConceptId]?a[i][c]=u[o.id]:a[i][c]=o.characterValue}return p[t.id]}))}(r,n,i);console.log("this is the time for the data to be made",(new Date).getTime()-c),null===(e=null==r?void 0:r.type)||void 0===e||e.characterValue,o=a;let s={};return s.created_at=r.entryTimeStamp,s.data=o,s.id=t,s}))}function Mt(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield Z.GetConnectionsOfCompositionLocal(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,o,r);i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a;let s={};return s.data=i,s.id=t,s.created_at=c.entryTimeStamp,s}))}function Ht(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield _t(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,o,r);i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a;let s={};return s.data=i,s.id=t,s}))}function Wt(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;let a={},s=[],l=t.id;if(null===(i=null==t?void 0:t.type)||void 0===i?void 0:i.characterValue,!n.includes(l))return null==t?void 0:t.characterValue;if(o.includes(l))return"";o.push(l);for(let t=0;t<e.length;t++)if(e[t].ofTheConceptId==l)if(l!=e[t].toTheConceptId){let i=e[t].toTheConceptId,l=yield k.GetConcept(i);if(null!=l&&0!=l.id||null==i||null==i||(l=yield bt(i)),0!=l.id&&null==(null==l?void 0:l.type)){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}let d="the_",h=(null!==(c=null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(d,"");if(isNaN(Number(h))){if(h){const t=yield Wt(l,e,n,o);a[h]=t}}else{const t=yield Wt(l,e,n,o);s[h]=t,a=s}}else console.log("this is the faulty connection ",e[t]);return a}))}function $t(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;(new Date).getTime();let a={},s=[],l=t.id;if(a.id=l,null===(i=null==t?void 0:t.type)||void 0===i?void 0:i.characterValue,!n.includes(l))return null==t?void 0:t.characterValue;if(o.includes(l))return"";o.push(l);for(let t=0;t<e.length;t++)if(e[t].ofTheConceptId==l)if(l!=e[t].toTheConceptId){let i=e[t].toTheConceptId,l=yield k.GetConcept(i);if(null!=l&&0!=l.id||null==i||null==i||(l=yield bt(i)),0!=l.id&&null==(null==l?void 0:l.type)){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}let d="the_",h=(null!==(c=null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(d,"");if(isNaN(Number(h))){if(h){const t=yield Wt(l,e,n,o);a[h]=t}}else{const t=yield Wt(l,e,n,o);s[h]=t,a=s}}else console.log("this is the faulty connection ",e[t]);return a}))}function qt(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;let a={},s=[];if(0==t)return null;let l=yield k.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield bt(t)),0!=l.id&&null==l.type){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(let i=0;i<e.length;i++)if((new Date).getTime(),e[i].ofTheConceptId==t)if(t!=e[i].toTheConceptId){let t=e[i].toTheConceptId,l=yield k.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield bt(t)),0!=l.id&&null==(null==l?void 0:l.type)){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}let d="the_",h=(null!==(c=null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(d,"");if(isNaN(Number(h))){if(h){const i=yield qt(t,e,n,o);a[h]=i}}else{const i=yield qt(t,e,n,o);s[h]=i,a=s}}else console.log("this is the faulty connection ",e[i]);return a}))}function Jt(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;let a={},s=[];if(0==t)return null;let l=yield k.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield bt(t)),0!=l.id&&null==l.type){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t),a.id=t;for(let o=0;o<e.length;o++)if(e[o].ofTheConceptId==t){let t=e[o].toTheConceptId,i=yield k.GetConcept(t);if(null!=i&&0!=i.id||null==t||null==t||(i=yield bt(t)),i&&null==(null==i?void 0:i.type)){let t=i.typeId,e=yield k.GetConcept(t);i.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),i.type=e)}let l="the_",d=(null!==(c=null===(r=null==i?void 0:i.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(d))){if(d){const o=yield Jt(t,e,n);a[d]=o}}else{const o=yield Jt(t,e,n);s[d]=o,a=s}}return a}))}var zt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Qt(t){return zt(this,void 0,void 0,(function*(){let e=C();try{const n=new FormData;n.append("character_value",t);const i=yield fetch(o.GetConceptByCharacterValueUrl(),{method:"POST",body:n});i.ok?(e=yield i.json(),e.id>0&&k.AddConcept(e)):(L(i),console.log("Error in Getting concept by character value Error",i.status))}catch(t){t instanceof Error?console.log("Error in Getting concept by character value error message: ",t):console.log("Error in Getting concept by character value unexpected error: ",t),R(t,o.GetConceptByCharacterValueUrl())}return e}))}var Zt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Kt(t){return Zt(this,void 0,void 0,(function*(){let e=yield k.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Qt(t),e=yield k.GetConceptByCharacterAndTypeLocal(t,51),0==e.id&&(e=yield k.GetConceptByCharacter(t))),e}))}var Xt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yt(t){return Xt(this,void 0,void 0,(function*(){return yield Lt.GetConceptByCharacterAndTypeLocal(t,51)}))}function te(t){return Xt(this,void 0,void 0,(function*(){let e=Nt();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=F(t);if(n.length>1){let o=1,i=yield te(n[0]);0!=i.id&&(o=i.id),e=yield function(t,e){return Xt(this,void 0,void 0,(function*(){return Lt.GetConceptByCharacterAndCategoryLocal(t,e)}))}(t,o)}else n[0]==t&&(e=yield Yt(t));return e}))}var ee=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ne(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=yield Kt(t),r=[];if(i){yield E(t,e);let c=yield k.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[];for(let t=a;t<a+n;t++)c[t]&&s.push(c[t].id);yield it(s);for(let t=a;t<a+n;t++)if(c[t]){let e=yield Et(c[t].id);r.push(e)}}return r}))}function oe(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=fe(t,e),r=ne(t,e),c=[];return Promise.race([i,r]).then((t=>{console.log("Promise result",t),c.push(...t)})).catch((t=>{console.log("error in handling",t)})),r.then((t=>{console.log("This is the second promise result",t),c.push(...t)})),c}))}function ie(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=yield Yt(t),r=yield Kt(t),c=[],a=[],s=[],l=[];0!=i.id&&(a=yield Lt.GetConceptsByTypeIdAndUser(i.id,e)),0!=r.id&&(yield E(t,e),l=yield k.GetConceptsByTypeIdAndUser(r.id,e),c=l);for(let t=0;t<a.length;t++){let e=!1;for(let n=0;n<l.length;n++)a[t].ghostId==l[n].ghostId&&(e=!0);e||s.push(a[t])}console.log("This is the all list",s);let d=[];return d=yield function(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=[],r=n*(o-1),c=[],a=e.length;for(let e=r;e<r+n-a;e++)t[e]&&c.push(t[e].id);for(let t=0;t<e.length;t++){let n=yield de(e[t].id);i.push(n)}yield it(c);for(let e=r;e<r+n-a;e++)if(t[e]){let n=yield Vt(t[e].id);i.push(n)}return i}))}(c,s,n,o),d}))}function re(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=yield Kt(t),r=[];if(i){yield E(t,e);let c=yield k.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[];for(let t=a;t<a+n;t++)c[t]&&s.push(c[t].id);yield it(s);for(let t=a;t<a+n;t++)if(c[t]){let e=yield Vt(c[t].id);r.push(e)}}return r}))}function ce(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=yield function(t){return Zt(this,void 0,void 0,(function*(){let e=yield k.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Qt(t),e=yield k.GetConceptByCharacter(t)),e}))}(t),r=[];if(i){yield E(t,e);let c=yield k.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[];for(let t=a;t<a+n;t++)c[t]&&s.push(c[t].id);yield it(s);for(let t=a;t<a+n;t++)if(c[t]){let e=yield Vt(c[t].id);r.push(e)}}return r}))}var ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},se=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function le(t){return se(this,void 0,void 0,(function*(){var e,n;try{let i=[],r={};i=yield xt.GetConnectionsOfCompositionLocal(t);let c=[];for(let t=0;t<i.length;t++)c.includes(i[t].ofTheConceptId)||c.push(i[t].ofTheConceptId);let a=yield Lt.GetConcept(t);if(0==a.id){let e=yield function(t){return ae(this,void 0,void 0,(function*(){let e=C();try{var n=_("application/x-www-form-urlencoded");const i=yield fetch(o.GetRealConceptById(),{method:"POST",headers:n,body:`id=${t}`});if(i.ok)return e=yield i.json(),e.id>0&&k.AddConcept(e),e;console.log("Error in Getting Translating concept Error",i.status),L(i)}catch(t){t instanceof Error?console.log("Error in Getting Translating concept error message: ",t):console.log("Error in Getting Translating concept unexpected error: ",t),R(t,o.GetRealConceptById())}return e}))}(t);if(e.id>0)return yield Ft(e.id)}let s=yield he(t,i,c);return r[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=s,r}catch(t){throw t}}))}function de(t){return se(this,void 0,void 0,(function*(){var e,n;try{let o=[],i={},r={};o=yield xt.GetConnectionsOfCompositionLocal(t);let c=[];for(let t=0;t<o.length;t++)c.includes(o[t].ofTheConceptId)||c.push(o[t].ofTheConceptId);let a=yield Lt.GetConcept(t);if(0!=a.id){let r=yield he(t,o,c);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=r}return r.data=i,r.id=t,r}catch(t){throw t}}))}function he(t,e,n){return se(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;let a={},s=[],l=yield Lt.GetConcept(t);if(0!=l.id&&null==l.type){let t=l.typeId,e=yield Lt.GetConcept(t);l.type=e}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(let o=0;o<e.length;o++)if(e[o].ofTheConceptId==t){let t=e[o].toTheConceptId,i=yield Lt.GetConcept(t);if(0!=i.id&&null==(null==i?void 0:i.type)){let t=i.typeId,e=yield Lt.GetConcept(t);i.type=e}let l="the_",d=(null!==(c=null===(r=null==i?void 0:i.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"top").replace(l,"");if(isNaN(Number(d))){if(d){const o=yield he(t,e,n);a[d]=o}}else{const o=yield he(t,e,n);s[d]=o,a=s}}return a}))}var ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function fe(t,e){return ue(this,void 0,void 0,(function*(){try{let n=yield Yt(t),o=[];if(0!=n.id){let t=yield Lt.GetConceptsByTypeIdAndUser(n.id,e);for(let e=0;e<t.length;e++){let n=yield le(t[e].id);o.push(n)}}return o}catch(t){throw t}}))}function ye(t,e){return ue(this,void 0,void 0,(function*(){try{let n=yield Yt(t),o=[];if(0!=n.id){let t=yield Lt.GetConceptsByTypeIdAndUser(n.id,e);for(let e=0;e<t.length;e++){let n=yield de(t[e].id);o.push(n)}}return o}catch(t){throw t}}))}var pe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ve(t){return pe(this,void 0,void 0,(function*(){let e=C();try{var n=G();const i=yield fetch(o.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(!i.ok)throw L(i),new Error(`Error! status: ${i.status}`);return e=yield i.json(),e}catch(t){t instanceof Error?console.log("Create the concept api error message: ",t.message):console.log("Create the concept api unexpected error: ",t),R(t,o.CreateTheConceptUrl())}}))}var ge=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class me{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){this.conceptsSyncArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static SyncDataOnline(){return ge(this,void 0,void 0,(function*(){for(let t=0;t<this.conceptsSyncArray.length;t++)k.AddConcept(this.conceptsSyncArray[t]);for(let t=0;t<this.connectionSyncArray.length;t++)Z.AddConnection(this.connectionSyncArray[t]);if(this.conceptsSyncArray.length>0){let t=this.conceptsSyncArray.slice();this.conceptsSyncArray=[],ve(t)}if(this.connectionSyncArray.length>0){let t=this.connectionSyncArray.slice();this.connectionSyncArray=[],yield function(t){return e=this,n=void 0,r=function*(){let e=new O(0,0,0,0,0,0,0);try{var n=G(),i=JSON.stringify(t);const r=yield fetch(o.CreateTheConnectionUrl(),{method:"POST",headers:n,body:i});return r.ok?yield r.json():(console.log("Create the connection error message: ",r.status),L(r)),e}catch(t){throw t instanceof Error?console.log("Create the connection error message: ",t.message):console.log(" Create the connection unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,o){function c(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r.throw(t))}catch(t){o(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,n||[])).next())}));var e,n,i,r}(t)}return"done"}))}static syncDataLocalDb(){return ge(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)s("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)s("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}function Ce(t,e,n,o){var i=new O(0,t,n,e,o,1,4);if(t==n)return i.ofTheConceptId=0,i.toTheConceptId=1,i;try{i.isTemp=!0,i.id=Math.floor(1e8*Math.random()),me.AddConnection(i)}catch(t){R(t)}return i}me.conceptsSyncArray=[],me.connectionSyncArray=[];var Ne=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Te=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ie(t,e){return Te(this,void 0,void 0,(function*(){let n=yield k.GetConceptByCharacterAndTypeLocal(t,e);try{if(null==n||0==n.id){var i={character_value:`${t}`,type_id:e},r=JSON.stringify(i),c=G();const a=yield fetch(o.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:r});a.ok?(n=yield a.json(),k.AddConcept(n)):(L(a),console.log("This is the concept by type and character error",a.status))}return n}catch(t){t instanceof Error?console.log(" This is the concept by type and character error message: ",t.message):console.log(" This is the concept by type and character unexpected error: ",t),R(t,o.GetConceptByCharacterAndTypeUrl())}}))}var we=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ke{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.userId=t,this.data=e,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.entryTimestamp=s,this.isNew=l}}var Ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class xe{static getId(){return Ae(this,void 0,void 0,(function*(){this.ids.length<5&&(yield function(){return t=this,e=void 0,i=function*(){try{let t=G("application/x-www-form-urlencoded");const e=yield fetch(o.GetReservedIdUrl(),{method:"GET",headers:t});if(!e.ok)throw L(e),new Error(`Error! status: ${e.status}`);const n=yield e.json();for(let t=0;t<n.length;t++)xe.AddId(n[t])}catch(t){t instanceof Error?console.log("get reserved ids error message: ",t.message):console.log("get reserved ids unexpected error: ",t),R(t,o.GetReservedIdUrl())}},new((n=void 0)||(n=Promise))((function(o,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((i=i.apply(t,e||[])).next())}));var t,e,n,i}());var t=this.ids[0];return this.ids.shift(),t}))}static AddId(t){this.ids.includes(t)||this.ids.push(t)}}xe.ids=[];class Se{static getId(){return Ae(this,void 0,void 0,(function*(){this.connectionIds.length<5&&(yield function(){return t=this,e=void 0,i=function*(){try{let t=G("application/x-www-form-urlencoded");const e=yield fetch(o.GetReservedConnectionIdUrl(),{method:"GET",headers:t});if(!e.ok)throw L(e),new Error(`Error! status: ${e.status}`);const n=yield e.json();for(let t=0;t<n.length;t++)Se.AddId(n[t])}catch(t){t instanceof Error?console.log("get reserved connection ids error message: ",t.message):console.log("get reserved connection ids unexpected error: ",t),R(t,o.GetReservedConnectionIdUrl())}},new((n=void 0)||(n=Promise))((function(o,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((i=i.apply(t,e||[])).next())}));var t,e,n,i}());var t=this.connectionIds[0];return this.connectionIds.shift(),t}))}static AddId(t){this.connectionIds.includes(t)||this.connectionIds.push(t)}}Se.connectionIds=[];var Le=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Re(t,e,n,o,i,r,c){return Le(this,void 0,void 0,(function*(){let a=yield xe.getId(),s=new Date,l=new Date,d=new m(a,e,o,n,i,t,r,!0,s,l,c);return d.isTemp=!1,me.AddConcept(d),d}))}function be(t,e,n,o,i,r,c){return Le(this,void 0,void 0,(function*(){let a=yield xe.getId(),s=new Date,l=new Date,d=new m(a,e,o,n,i,t,r,!1,s,l,c);return k.AddConcept(d),ve([d]),d}))}var Ge=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _e(t,e){return Ge(this,arguments,void 0,(function*(t,e,n=!1,i,r=4,c=999,a=0){let s,l=c,d=i,h=i,u=r,f=i,y="",p=e.length,v=C();if(y=t.startsWith("the_")?t:"the_"+t,n)v=yield Dn(t),s=yield Re(e,i,4,v.id,a,u,t);else if(p>255)v=yield Dn(y),s=yield Re(e,i,4,v.id,a,u,y),function(t){Ne(this,void 0,void 0,(function*(){try{var e=G();const n=yield fetch(o.CreateTheTextDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!n.ok)throw L(n),new Error(`Error! status: ${n.status}`);return yield n.json()}catch(t){throw t instanceof Error?console.log("Create the text error message: ",t.message):console.log("Create the text unexpected error: ",t),t}}))}(new ke(i,e,999,d,u,f,l,h,Date.now().toString(),!0));else{v=yield Dn(y);let t=yield Ie(e,v.id);s=t,0==t.id&&0==t.userId&&(s=yield be(e,i,4,v.id,12,u,y),function(t,e,n,i){we(this,void 0,void 0,(function*(){try{let r={newConceptId:t,referent:e,typeId:n,typeUserId:i},c=G(),a=JSON.stringify(r);const s=yield fetch(o.MakeTheNameInBackendUrl(),{method:"POST",headers:c,body:a});s.ok||L(s)}catch(t){t instanceof Error?console.log("make the name in backend error message: ",t.message):console.log("make the name in backend unexpected error: ",t),R(t,o.MakeTheNameInBackendUrl())}}))}(s.id,`${e}`,v.id,i))}return s.type=v,s}))}var Be=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pe(t){return Be(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null){let a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,h=C();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){let e=d,n=yield _e(o,"",!0,a,s,l);h=n,e=n.id,d=n.id,yield Pe(t[o],n.id,n.userId,e,i,r,c)}else{let u=null!=e?e:999,f=null!=n?n:999,y=d,p=yield _e(o,"",!0,a,s,l);h=p,yield Ce(u,f,p.id,y),yield Pe(t[o],p.id,p.userId,y,i,r,c)}else{let i=null!=e?e:999,r=null!=n?n:10267,c=d,h=yield _e(o,t[o].toString(),!1,a,s,l);yield Ce(i,r,h.id,c)}return h}))}var Ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Fe(){return Ue(this,void 0,void 0,(function*(){console.log("this is trying to create local binary tree");try{let t=yield lt("localconcept");if(Array.isArray(t))for(let e=0;e<t.length;e++){let n=t[e];Lt.AddConceptToMemory(n)}u.isLocalDataLoaded=!0,u.isLocalTypeLoaded=!0,u.isLocalCharacterLoaded=!0}catch(t){throw yield Zi(2e3,Fe()),{message:"Cannot create local binary tree from index db",data:t,ok:!1,status:400}}}))}function De(){return Ue(this,void 0,void 0,(function*(){try{yield navigator.locks.request("dblock",(t=>Ue(this,void 0,void 0,(function*(){let t=yield lt("localid");if(Array.isArray(t)){if(t[0]){let e=t[0].value;if(e)Ve.AddConceptId(t[0]);else{e=-Math.floor(1e8*Math.random());let t={id:0,value:e},n={id:0,value:e-10};Ve.AddConceptId(t),yield ht("localid",n)}}t[2]&&(o.BASE_RANDOMIZER=t[2].value)}}))))}catch(t){throw{message:"Cannot populate Local Ids from the Index Db",data:t,ok:!1,status:400}}}))}function Ee(){return Ue(this,void 0,void 0,(function*(){try{yield navigator.locks.request("dblock",(t=>Ue(this,void 0,void 0,(function*(){let t=yield lt("localid");if(Array.isArray(t)){if(t[1]){let e=t[1].value;if(e)Ve.AddConnectionId(t[1]),yield ht("localid",{id:1,value:e-10});else{e=-Math.floor(1e8*Math.random());let t={id:0,value:e},n={id:0,value:e-10};Ve.AddConnectionId(t),yield ht("localid",n)}}t[2]&&(o.BASE_RANDOMIZER=t[2].value)}}))))}catch(t){throw{message:"Cannot populate Local Ids from the Index Db",data:t,ok:!1,status:400}}}))}var Oe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ve{static AddConceptId(t){this.localId=t.value,ht("localid",t)}static getConceptId(){return Oe(this,void 0,void 0,(function*(){try{if(this.localId){if(this.ReservedLocalId.length<5){yield De().then((()=>{let t=this.localId;for(let e=1;e<10;e++){let n=this.localId-e;this.ReservedLocalId.push(n),t=n}this.AddConceptId({id:0,value:t})})).catch((t=>(console.log(" getid: cannot get the id from indexdb"),-Math.floor(1e8*Math.random()))));let t=this.ReservedLocalId[0];return this.ReservedLocalId.shift(),t}{let t=this.ReservedLocalId[0];return this.ReservedLocalId.shift(),t}}return yield De().then((()=>{let t=this.localId;for(let e=1;e<10;e++){let n=this.localId-e;this.ReservedLocalId.push(n),t=n}this.AddConceptId({id:0,value:t})})),this.getConceptId()}catch(t){return console.log(" getid: this is the eror in concept",t),-Math.floor(1e8*Math.random())}}))}static AddConnectionId(t){this.localConnectionId=t.value}static getConnectionId(){return Oe(this,void 0,void 0,(function*(){try{if(this.localConnectionId){if(this.ReservedConnectionId.length<5){yield Ee().then((()=>{let t=this.localConnectionId;for(let e=1;e<10;e++){let n=this.localConnectionId-e;this.ReservedConnectionId.push(n),t=n}})).catch((t=>(console.log("this is the new event",t),-Math.floor(1e8*Math.random()))));let t=this.ReservedConnectionId[0];return this.ReservedConnectionId.shift(),t}{let t=this.ReservedConnectionId[0];return this.ReservedConnectionId.shift(),t}}return yield Ee().then((()=>{let t=this.localConnectionId;for(let e=1;e<10;e++){let n=this.localConnectionId-e;this.ReservedConnectionId.push(n),t=n}this.AddConnectionId({id:1,value:t})})),this.getConnectionId()}catch(t){return-Math.floor(1e8*Math.random())}}))}}Ve.ReservedLocalId=[],Ve.ReservedConnectionId=[];var je=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Me(t,e,n){return je(this,arguments,void 0,(function*(t,e,n,o=1,i="",r=999){try{let c=4,a=yield Ve.getConnectionId(),s=0,l=0,d=0;s=t,l=e,d=n;let h=new O(0,0,0,0,0,0,0);return t!=e&&(h=new O(a,s,l,r,n,o,c),h.isTemp=!0,h.typeCharacter=i,yield kt.AddConnection(h),xt.AddConnection(h)),h}catch(t){throw t}}))}var He=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function We(t,e,n,o,i,r){return He(this,arguments,void 0,(function*(t,e,n,o,i,r,c=!1,a=0){try{let s=yield Ve.getConceptId();console.log("this is the getting id type connection",s);let l=!0,d=new Date,h=new Date;if("the"==t)return new m(1,999,5,5,a,t,r,l,d,h,e);let u=new m(s,n,i,o,a,t,r,l,d,h,e);return u.isTemp=!0,u.isComposition=c,Lt.AddConcept(u),u}catch(t){throw t}}))}var $e=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},qe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Je(t,e,n,o){return qe(this,void 0,void 0,(function*(){let i=yield te(t);if(i&&(0==i.id||0==i.userId)){let r=F(t);if(r[0]==t){let e=yield function(t,e,n,o){return $e(this,void 0,void 0,(function*(){let e=yield Lt.GetConceptByCharacterAndTypeLocal(t,51),i=e;return o=1,0==i.id&&(e=yield We(t,"the",n,o,51,4),i=e),i}))}(t,0,o,1);i=e}else{let c=yield Je(r[0],e,n,o),a=yield Je(r[1],e,n,o);i=yield We(t,r[1],o,c.id,a.id,4)}}return i}))}var ze=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Qe(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0){try{let i,r,a=999,s=4,l=o,d=4,h="",u=e.length;if(h=t.startsWith("the_")?t:"the_"+t,n)i=yield Je(t,a,o,o),r=yield We(e,t,o,s,i.id,d,!0,c);else if(u>255)i=yield Je(h,a,l,o),r=yield We(e,h,o,s,i.id,d);else{i=yield Je(h,a,l,o);let t=yield Lt.GetConceptByCharacterAndTypeLocal(e,i.id);r=t,0==t.id&&0==t.userId&&(r=yield We(e,h,o,s,i.id,d))}return r.type=i,kt.AddConcept(r),r}catch(t){throw t}}))}var Ze=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ke(t){return Ze(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=!1){let s=null!=i?i:999,l=null!=r?r:999,d=null!=c?c:999,h=null!=o?o:0,u=Nt();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){let e=h,n=yield Qe(o,"",!0,s,l,d);u=n,e=n.id,h=n.id,yield Ke(t[o],n.id,n.userId,e,i,r,c)}else{let n=null!=e?e:999,a=h,u=yield Qe(o,"",!0,s,l,d);yield Me(n,u.id,a),yield Ke(t[o],u.id,u.userId,a,i,r,c)}else{let n=null!=e?e:999,i=h,r=yield Qe(o,t[o].toString(),!1,s,l,d);yield Me(n,r.id,i)}return u}))}var Xe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ye(t,e,n){return Xe(this,arguments,void 0,(function*(t,e,n,i=10,r=1){let c=[];try{let a=new URLSearchParams;a.append("typeId",`${t}`),a.append("ofTheConceptId",`${e}`),a.append("userId",`${n}`),a.append("inpage",`${i}`),a.append("page",`${r}`);let s=G("application/x-www-form-urlencoded");const l=yield fetch(o.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(L(l),console.log("Get connection of concept error",l.status)),c}catch(t){t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),R(t,o.GetAllConnectionsOfConceptUrl())}}))}var tn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function en(t,e,n,o){return tn(this,arguments,void 0,(function*(t,e,n,o,i=1,r=4){if(t>0&&n>0){var c=e,a=yield Se.getId(),s=new O(a,t,n,c,o,i,r);return t==n?(s.ofTheConceptId=0,s.toTheConceptId=1,s):(s.toUpdate=!0,s.isTemp=!1,me.AddConnection(s),s)}throw new S("cannot create connection because id are negative ",!1,400,"")}))}var nn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},on=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},rn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function cn(t){return rn(this,void 0,void 0,(function*(){let e=yield Z.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){let n=yield function(t){return on(this,void 0,void 0,(function*(){let e=yield Z.GetConnection(t);try{if(0!=e.id)return e;{let n=G("application/x-www-form-urlencoded");const i=new FormData;i.append("id",t.toString());const r=yield fetch(o.GetConnectionUrl(),{method:"POST",headers:n,body:i});return r.ok?(e=yield r.json(),Z.AddConnection(e)):(L(r),console.log("Get Connection Error",r.status)),e}}catch(t){t instanceof Error?console.log("Get Connection error message: ",t.message):console.log("Get Connection unexpected error: ",t),R(t,o.GetConnectionUrl())}}))}(t);e=n}return e}))}var an=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function sn(t){return an(this,void 0,void 0,(function*(){t>0?(yield cn(t),yield function(t){return nn(this,void 0,void 0,(function*(){try{const e=new FormData;e.append("id",t.toString());let n=B();const i=yield fetch(o.DeleteTheConnectionUrl(),{method:"POST",headers:n,body:e,redirect:"follow"});i.ok||(console.log("Delete connection error status: ",i.status),L(i))}catch(t){t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),R(t,o.DeleteTheConnectionUrl())}}))}(t),M.removeNodeFromTree(t)):xt.RemoveConnectionById(t)}))}var ln=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function dn(t){return ln(this,arguments,void 0,(function*(t,e=999){try{let n=C();if(t<0)return n=xi(yield ai(e,t)),n;if(n=yield k.GetConcept(t),null!=n&&0!=n.id||null==t||null==t||(n=yield bt(t)),0!=n.id&&null==n.type&&null==(yield k.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){let t=yield bt(n.typeId);n.type=t}return n}catch(t){throw console.error("this is the error in the getting concept",t),t}}))}var hn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function un(t,e,n){return hn(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c;let a=t.userId;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield fn(o,e,a));let s=yield _e("connection",c,!1,999,999,999),l=new O(0,e.id,t.id,a,s.id,1e3,4);me.AddConnection(l)}let s=n+"_s",l=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+s;i&&(yield fn(s,t,a));let d=yield _e("connection",l,!1,999,999,999),h=new O(0,t.id,e.id,a,d.id,1e3,4);return me.AddConnection(h),h}))}function fn(t,e){return hn(this,arguments,void 0,(function*(t,e,n=null){var o;let i=e,r=null!=n?n:e.userId,c=t+"_count",a=(null===(o=e.type)||void 0===o?void 0:o.characterValue)+"_s_"+c,s=yield _e("connection",a,!1,r,4,999),l=yield Ye(s.id,e.id,r,10,1),d=[],h=C();for(let t=0;t<l.length;t++){let e=yield dn(l[t].toTheConceptId);d.push(e)}if(d.length<1)h=yield _e("count","1",!1,r,4,999);else{let t=d[0],e=0;try{e=Number(t.characterValue)}catch(t){e=0}e+=1,h=yield _e("count",e.toString(),!1,r,4,999);for(let t=0;t<l.length;t++)sn(l[t].id)}let u=new O(0,i.id,h.id,i.userId,s.id,1e3,4);yield me.AddConnection(u)}))}function yn(t,e,n){return hn(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c;let a=t.userId;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield fn(o,e,a));let s=yield _e("connection",c,!1,999,999,999),l=new O(0,e.id,t.id,a,s.id,1e3,4);me.AddConnection(l)}let s=n+"_s",l=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+s;i&&(yield fn(s,t,a));let d=yield _e("connection",l,!1,999,999,999);return yield en(t.id,t.userId,e.id,d.id,1e3,4)}))}var pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function vn(t,e){}function gn(t,e,n){return pn(this,void 0,void 0,(function*(){}))}function mn(t){return pn(this,void 0,void 0,(function*(){}))}var Cn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Nn(t,e){return Cn(this,arguments,void 0,(function*(t,e,n=10,o=1){var i;let r=[],c=yield dn(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield Ie(a,16);if(s.id>0){let t=yield Ye(s.id,c.id,c.userId,n,o),e=[];for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield it(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield dn(n),i=yield Mt(o.id);r.push(i)}}return r}))}function Tn(t,e){return Cn(this,arguments,void 0,(function*(t,e,n=10,o=1){var i;let r=[],c=yield dn(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield Ie(a,16);if(s.id>0){let t=yield Ye(s.id,c.id,c.userId,n,o),e=[];for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield dn(n);r.push(o)}}return r}))}class In{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.isNew=!1,this.userId=t,this.data=`${e}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.isNew=l}}class wn{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new In(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==t&&(e=this.characterData[n]);return e}}wn.characterData=[];class kn{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}var An=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},xn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Sn(t,e,n,i,r){return xn(this,void 0,void 0,(function*(){return new In(e,t,n,e,i,e,r,e,"",!1),yield function(){return An(this,void 0,void 0,(function*(){var t;try{if(0==(t=wn.GetCharacter(t.data)).id){var e=G();const i=yield fetch(o.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!i.ok)throw L(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var n=new In(r.userId,t.data,0,0,4,4,999,999,"",!1);return n.id=r.id,wn.AddCharacter(n),r}return new kn(t.id,t.userId,0,!1)}catch(t){throw t instanceof Error?console.log("create the character error message: ",t.message):console.log("create the character unexpected error: ",t),t}}))}()}))}var Ln=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Rn(t,e,n,o,i,r,c){return Ln(this,void 0,void 0,(function*(){let a=yield Ie(t,o),s=a;return 0==s.id&&(a=yield Re(t,e,n,o,i,r,c),s=a),s}))}var bn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Gn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _n(t,e,n,o){return Gn(this,void 0,void 0,(function*(){let i=yield Kt(t);if(i&&(0==i.id||0==i.userId)){let r=F(t);if(r.length>0)if(r[0]==t){let n=yield function(t,e,n,o,i,r){return bn(this,void 0,void 0,(function*(){let n;if(1==t.length){let i=t.charCodeAt(0),c=49;yield Sn(t,e,999,o,r),n=Rn(t,e,4,c,i,o,"the_character")}else{let i=yield Sn(t,e,999,o,r);i.isNew,n=yield Rn(t,e,4,51,i.id,o,"the_characters")}return n}))}(t,o,0,999,0,e);i=n}else{let c=yield _n(r[0],e,n,o),a=yield _n(r[1],e,n,o);a&&(i=yield be(t,o,c.id,a.id,999,999,r[1]))}}return i}))}var Bn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Un(t){return Pn(this,void 0,void 0,(function*(){let e=C();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=F(t);if(n.length>1){let i=1,r=yield Un(n[0]);0!=r.id&&(i=r.id),e=yield function(t,e){return Pn(this,void 0,void 0,(function*(){let n=yield k.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield function(t,e){return Bn(this,void 0,void 0,(function*(){let n=C();try{var i=G("application/x-www-form-urlencoded");const r=yield fetch(o.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${t}&category_id=${e}`});r.ok?(n=yield r.json(),k.AddConcept(n)):(console.log("This is the concept by category and character error",r.status),L(r))}catch(t){t instanceof Error?console.log(" This is the concept by category and character error message: ",t.message):console.log(" This is the concept by category and character unexpected error: ",t),R(t,o.GetConceptByCharacterAndCategoryDirectUrl())}return n}))}(t,e)),n}))}(t,i)}else n[0]==t&&(e=yield function(t){return Pn(this,void 0,void 0,(function*(){let e=yield k.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield Qt(t)),e}))}(t));return e}))}var Fn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Dn(t,e){return Fn(this,void 0,void 0,(function*(){let e=C();try{if(e=yield Un(t),0==e.id||4==e.typeId){let n=G("application/x-www-form-urlencoded");const i=yield fetch(o.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${t}`});if(!i.ok)throw L(i),new Error(`Error! status: ${i.status}`);e=yield i.json()}}catch(t){t instanceof Error?console.log("Make The Type Concept Api error : ",t.message):console.log("Make The Type Concept Api error : ",t),R(t,o.MakeTheTypeConceptUrl())}return e}))}var En=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function On(t){return En(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=G("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),L(c)}catch(t){t instanceof Error?console.log("Get all linker connection from the concepts error: ",t.message):console.log("Get all linker connection from the concepts error(Unexpected): ",t),R(t,o.GetAllLinkerConnectionOfConceptUrl())}return e}))}var Vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},jn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Mn(t){return jn(this,void 0,void 0,(function*(){let e=yield On(t);for(let t=0;t<e.length;t++){let n=e[t],o=n.typeId,i=yield dn(o);n.type=i}return e}))}function Hn(t){return jn(this,void 0,void 0,(function*(){let e=yield function(t){return Vn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=G("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),L(c)}catch(t){t instanceof Error?console.log("Get all linker connection To the concepts error: ",t.message):console.log("Get all linker connection To the concepts error(Unexpected): ",t),R(t,o.GetAllLinkerConnectionToConceptUrl())}return e}))}(t);for(let t=0;t<e.length;t++){let n=e[t],o=n.typeId,i=yield dn(o);n.type=i}return e}))}var Wn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},$n=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qn(t){return $n(this,void 0,void 0,(function*(){if(t>0){var e=yield dn(t),n=e.typeId,i=e.characterValue;yield I.removeTypeConcept(n,t),yield p.removeNodeByCharacter(i,t),yield function(t){return Wn(this,void 0,void 0,(function*(){try{const e=new FormData;e.append("id",t.toString());let n=B();const i=yield fetch(o.DeleteConceptUrl(),{method:"POST",headers:n,body:e});i.ok||(console.log("Delete concept error",i.status),L(i))}catch(t){t instanceof Error?console.log("Delete concept error message: ",t.message):console.log("Delete concept unexpected error: ",t),R(t,o.DeleteConceptUrl())}}))}(t),yield g.removeNodeFromTree(t),yield q.removeNodeFromTree(t)}else Lt.RemoveConceptById(t)}))}var Jn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function zn(t,e){return Jn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+e);const i=new FormData;i.append("id",t.toString());const r=yield fetch(o.DeleteConceptUrl(),{method:"POST",body:i,headers:n});if(!r.ok)throw L(r),new Error(`Delete composition Error! status: ${r.status}`)}catch(t){t instanceof Error?console.log("Delete composition error message: ",t.message):console.log("Delete composition unexpected error: ",t),R(t,o.DeleteConceptUrl())}}))}var Qn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Zn(t,e,n){return Qn(this,arguments,void 0,(function*(t,e,n,o=4,i=999){let r,c="",a=t.startsWith("the_"),s=C();return c=a?t:"the_"+t,s=yield Dn(c),r=yield Rn(e,n,4,s.id,0,o,c),r}))}class Kn{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=[],this.ofCompositions=[]}}var Xn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yn(){return Xn(this,arguments,void 0,(function*(t=[]){let e=[];try{if(t.length>0){let n=[];for(let o=0;o<t.length;o++){let i=yield Z.GetConnection(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{let t=G();const i=yield fetch(o.GetConnectionBulkUrl(),{method:"POST",headers:t,body:JSON.stringify(n)});if(i.ok){const t=yield i.json();if(t.length>0)for(let n=0;n<t.length;n++){let o=t[n];e.push(o),Z.AddConnection(o)}}else L(i),console.log("Get Connection Bulk error",i.status)}}}catch(t){t instanceof Error?console.log("Get Connection Bulk error message: ",t):console.log("Get Connection Bulk unexpected error: ",t),R(t,o.GetConnectionBulkUrl())}return yield tt(e),e}))}var to=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function eo(){return to(this,arguments,void 0,(function*(t=[]){yield it(t);let e=[];for(let n=0;n<t.length;n++){let o=yield Et(t[n]);e.push(o)}return e}))}function no(){return to(this,arguments,void 0,(function*(t=[]){yield it(t);let e=[];for(let n=0;n<t.length;n++){let o=yield Vt(t[n]);e.push(o)}return e}))}function oo(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e),yield nt(t);let n=[];for(let e=0;e<t.length;e++){let o=yield Vt(t[e]);n.push(o)}return n}))}function io(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e),yield nt(t);let n={};for(let e=0;e<t.length;e++){let o=yield Vt(t[e]);n[t[e]]=o}return n}))}function ro(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e),yield nt(t);let n={};for(let e=0;e<t.length;e++){let o=yield Et(t[e]);n[t[e]]=o}return n}))}function co(t){return to(this,void 0,void 0,(function*(){let e=[],n=[],o={};for(let o=0;o<t.length;o++){let i=yield Z.GetConnection(t[o]);0==i.id?e.push(t[o]):n.push(i)}for(let e=0;e<t.length;e++)o[t[e]]=!1;let i=[],r=yield Yn(e);n=[...n,...r];for(let t=0;t<n.length;t++)i.push(n[t].ofTheConceptId),i.push(n[t].toTheConceptId);return yield X(i),n}))}function ao(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e);let n={};for(let e=0;e<t.length;e++){let o=yield Vt(t[e]);n[t[e]]=o}return n}))}function so(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e);let n={};for(let e=0;e<t.length;e++){let o=yield Et(t[e]);n[t[e]]=o}return n}))}function lo(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e);let n={};for(let e=0;e<t.length;e++){let o=yield Ot(t[e]);n[t[e]]=o}return n}))}var ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function uo(){return ho(this,arguments,void 0,(function*(t=0,e=[],n=""){let i=[];try{let r=new Kn;r.composition=t,r.listLinkers=e,r.textSearch=n;let c=JSON.stringify(r),a=G();const s=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:a,body:c});if(s.ok){const t=yield s.json();let e=t.compositionIds,n=t.internalConnections;t.externalConnections,i=yield oo(e,n)}else console.log("recursive search error ",s.status),L(s)}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),R(t,o.RecursiveSearchUrl())}return i}))}function fo(){return ho(this,arguments,void 0,(function*(t=0,e=[],n=""){try{let i=new Kn;i.composition=t,i.listLinkers=e,i.textSearch=n;let r=JSON.stringify(i),c=G();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),L(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),R(t,o.RecursiveSearchUrl())}}))}function yo(){return ho(this,arguments,void 0,(function*(t=0,e=[],n=""){try{let i=new Kn;i.composition=t,i.fullLinkers=e,i.textSearch=n;let r=JSON.stringify(i),c=G();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),L(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),R(t,o.RecursiveSearchUrl())}}))}function po(){return ho(this,arguments,void 0,(function*(t=0,e=[],n=""){try{let i=new Kn;i.composition=t,i.fullLinkers=e,i.textSearch=n;let r=JSON.stringify(i),c=G();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),L(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),R(t,o.RecursiveSearchUrl())}}))}var vo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function go(t,e){return vo(this,void 0,void 0,(function*(){try{let n={email:t,password:e},i=new Headers;i.append("Content-Type","application/json");let r=JSON.stringify(n);const c=yield fetch(o.LoginUrl(),{method:"POST",headers:i,body:r});if(c.ok){const t=yield c.json();return console.log(t.data),b.BearerAccessToken=t.data.token,console.log("this is the token",b.BearerAccessToken),t}console.log("Login tsccs error message: ",c.status),L(c)}catch(t){t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),R(t,o.LoginUrl())}}))}var mo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Co(t){return mo(this,void 0,void 0,(function*(){const e=yield function(){return mo(this,arguments,void 0,(function*(t="",e={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(t,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(e)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:L(o),n}catch(e){console.log("Signup Error: ",e),R(e,t)}}))}(o.SignupUrl(),t);return e}))}var No=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function To(t){return No(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.password});let n={message:"success",status:!1,statusCode:200,data:""};const i=new Headers;i.append("Content-Type","application/json");const r=o.LoginUrl();try{const t=yield fetch(r,{method:"POST",headers:i,body:e,redirect:"follow"}),o=yield t.json();return t.ok?n={message:"success",status:!0,statusCode:200,data:null==o?void 0:o.data}:L(t),n}catch(t){console.log("Sign in api error",t),R(t,r)}}))}function Io(t,e){return-1===t.indexOf(e)&&t.push(e),t}function wo(t=[],e){var n,o;let i=[],r=null===(n=e.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(t))for(let n=0;n<t.length;n++){let c=null===(o=t[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),e.typeId!=t[n].typeId&&r!=c||i.push(t[n])}return i}function ko(t=[],e){let n=[],o=e.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(t))for(let i=0;i<t.length;i++){let r=t[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),e.typeId!=t[i].typeId&&o!=r||n.push(t[i])}return n}function Ao(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function xo(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function So(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function Lo(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class Ro{constructor(t,e,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}isValid(){const t=new Date(Date.now());return!(this.expiryTime<t&&(Go.removeNodeFromTree(this.key),1))}saveToCache(t){this.value.cached=t}addNode(t,e,n){if(null==e)return t;const o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return this.isValid(),t;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));const r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return this.isValid(),e}rightRotate(t){if(t){const e=t.leftNode;if(e){const n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){const e=t.rightNode;if(e){const n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key&&e.isValid()?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){const e=t.rightNode;return t=null,e}if(null==t.rightNode){const e=t.leftNode;return t=null,e}{const e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.rightNode=this.removeNode(t.rightNode,e.key),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var bo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Go{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addCompositionToTree(t){const e=new Ro(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return bo(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return bo(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}Go.root=null;var _o=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Bo(t,e,n,o){return _o(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c;let a={};const s=[];if(0==t)return"";let l=Po(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield dn(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=Po(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield dn(t),l.type=e)}if(!o.includes(t))return null==l?void 0:l.characterValue;if(i.includes(t))return"";i.push(t);for(let l=0;l<e.length;l++)if(e[l].ofTheConceptId==t){const d=e[l].toTheConceptId;if(o.includes(t)){let t=Po(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield dn(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield k.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield dn(e),t.type=n)}const l="the_",h=(null!==(c=null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(h))){if(h){const t=yield Bo(d,e,n,o,i);a[h]=t}}else{const t=yield Bo(d,e,n,o,i);s[h]=t,a=s}}}return a}))}function Po(t,e){let n=C();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class Uo{constructor(){this.id=0,this.mainConcept=C(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return t=this,e=void 0,o=function*(){if(0==this.mainConcept.id)for(let t=0;t<this.concepts.length;t++)this.concepts[t].id==this.id&&(this.mainConcept=this.concepts[t]);this.cached=yield Bo(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}));var t,e,n,o}UpdateAcrossDistributedSystem(){var t,e;try{0!=this.id&&(e=null===(t=this.id)||void 0===t?void 0:t.toString(),o.MQTT_CONNECTION&&o.MQTT_CONNECTION.publish("compositionUpdate",e))}catch(t){console.log("Error while publishing message",t)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var t,e,n;const o={};o[null!==(n=null===(e=null===(t=this.mainConcept)||void 0===t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var Fo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Do(t){return Fo(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=null){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let h=null!=o?o:0,u=C();null==a&&(a=new Uo);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield _e(o,"",!0,s,l,d);if(null==e&&null==n){let e=h;u=f,e=f.id,h=f.id,a.concepts.push(f),a.id=f.id,yield Do(t[o],f.id,f.userId,e,i,r,c,a)}else{const s=null!=e?e:999,l=null!=n?n:999,d=h;u=f,a.concepts.push(f);const y=yield Ce(s,l,f.id,d);a.connections.push(y),yield Do(t[o],f.id,f.userId,d,i,r,c,a)}null!=t[o]&&null!=t[o]&&a.subcompositions.push(f.id)}else{const i=null!=e?e:999,r=null!=n?n:999,c=h,u=yield _e(o,t[o],!1,s,l,d);a.concepts.push(u);const f=yield Ce(i,r,u.id,c);a.connections.push(f)}return u}))}var Eo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Oo(t){return Eo(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=C(),a=C();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let h=[];if(l<0){let t=yield dn(l,e);if(!(t.id>0))return null;l=t.id}i=yield _t(l);const u=[],f=new Uo,y=[];f.id=l,f.isUpdating();let p=[];for(let t=0;t<i.length;t++)Io(y,i[t].ofTheConceptId),Io(u,i[t].ofTheConceptId),Io(u,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<u.length;t++){const e=yield dn(u[t]);l==u[t]&&(c=e),d==u[t]&&(a=e),r.push(e)}const v=t.patchObject;for(const t in v){let i=C();const l=v[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield _e(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=wo(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=Ao(f.connections,e[t].id);h=h.concat(n),s.push(e[t])}yield Do(v[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield _e(t,l,!1,e,o,n);const c=wo(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=Ao(f.connections,c[t].id);h=h.concat(e),s.push(c[t])}}const u=Ce(d.id,d.userId,i.id,c.id);r.push(i),f.connections.push(u)}for(let t=0;t<h.length;t++)Lo(f.connections,h[t]),sn(h[t].id);for(let t=0;t<s.length;t++)So(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),Go.addCompositionToTree(f),me.SyncDataOnline(),f.GetDataCache()}))}var Vo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function jo(t,e,n,i){return Vo(this,arguments,void 0,(function*(t,e,n,i,r=10,c=1){var a=_("application/x-www-form-urlencoded",i),s=new URLSearchParams;s.append("type",t),s.append("search",e),s.append("composition",n),s.append("inpage",r.toString()),s.append("page",c.toString());const l=o.SearchCompositionsUrl()+"?"+s.toString();try{const t=yield fetch(l,{method:"GET",headers:a});return t.ok?yield t.json():(L(t),[])}catch(t){console.log("This is the searching error",t),R(t,l)}}))}var Mo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ho(t){return Mo(this,arguments,void 0,(function*(t,e=""){var n=_("application/json",e);const i=o.SearchLinkMultipleAll(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(console.log("This is the searching error",t.status),L(t),[])}catch(t){console.log("This is the searching error",t),R(t,i)}}))}var Wo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function $o(t){return Wo(this,arguments,void 0,(function*(t,e=[]){var n,o;let i=[];const r=[];let c={},a={};const s=yield Go.getNodeFromTree(t),l=[];let d=yield k.GetConcept(t);if(0==d.id&&null!=t&&null!=t&&(d=yield bt(t)),null==s){let s=[];s=e.length>0?qo(t,e):yield _t(t),i=s;for(let t=0;t<i.length;t++)l.includes(i[t].ofTheConceptId)||(l.push(i[t].ofTheConceptId),r.push(i[t].ofTheConceptId)),r.includes(i[t].toTheConceptId)||r.push(i[t].toTheConceptId);Qo(d,i,r,l);let h=[];a=yield qt(t,i,l,h),c[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a}else a=s.value.GetDataCache(),c=a;return 0==d.id?"":c}))}function qo(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function Jo(t){return Wo(this,arguments,void 0,(function*(t,e=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=yield Go.getNodeFromTree(t),d=[];let h=yield k.GetConcept(t);if(0==h.id&&null!=t&&null!=t&&(h=yield bt(t)),null==l){let l=[];l=e.length>0?qo(t,e):yield _t(t),r=l;for(let t=0;t<r.length;t++)d.includes(r[t].ofTheConceptId)||(d.push(r[t].ofTheConceptId),c.push(r[t].ofTheConceptId)),c.includes(r[t].toTheConceptId)||c.push(r[t].toTheConceptId);Qo(h,r,c,d),a=yield qt(t,r,d),s[null!==(o=null===(n=null==h?void 0:h.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=h.entryTimeStamp,i.data=s,i.id=t}else a=l.value.GetDataCache(),i=a;return 0==h.id?"":i}))}function zo(t,e){return Wo(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Yn(e);for(let e=0;e<t.length;e++){const i=yield Jo(t[e],n);i&&o.push(i)}return o}))}function Qo(t,e,n,i){return Wo(this,void 0,void 0,(function*(){const r=new Uo,c=yield function(t){return Wo(this,void 0,void 0,(function*(){let e=[];const n=[];for(let o=0;o<(null==t?void 0:t.length);o++){const i=yield k.GetConcept(t[o]);0==i.id?n.push(t[o]):e.push(i)}return 0==(null==n?void 0:n.length)||(e=yield function(t){return K(this,void 0,void 0,(function*(){const e=[];if(t.length>0){const n={"Content-Type":"application/json"};try{const i=yield fetch(o.GetConceptBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){const t=yield i.json();if(t.length>0)for(let n=0;n<t.length;n++){const o=t[n];e.push(o),k.AddConcept(o)}}else console.log("bulk concept getter api error: ",i.status),L(i)}catch(t){t instanceof Error?console.log("bulk concept getter api error: ",t.message):console.log("bulk concept getter api error: ",t),R(t,o.GetConceptBulkUrl())}}return e}))}(n)),e}))}(n);r.connections=e,r.concepts=c,r.id=t.id,r.subcompositions=i,r.mainConcept=t;const a=yield Bo(t.id,e,c,i,[]);r.cached=a,Go.addCompositionToTree(r)}))}var Zo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ko(t){return Zo(this,void 0,void 0,(function*(){try{var e=G();const n=JSON.stringify(t),i=yield fetch(o.CreateSessionId(),{method:"POST",headers:e,body:n});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),L(i),null)}catch(t){console.log("Creating session failed",t),R(t,o.CreateSessionId())}}))}var Xo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yo(t,e){return Xo(this,void 0,void 0,(function*(){try{var n=G("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",t.toString()),i.append("url",e);const r=yield fetch(o.CreateSessionVisitUrl(),{method:"POST",headers:n,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),L(r),null)}catch(t){console.log("Creating session url failed",t),R(t,o.CreateSessionVisitUrl())}}))}var ti=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ei(t,e){return ti(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=[],r=yield dn(t),c=yield Un(e);if(c.id>0){let t=yield Ye(c.id,r.id,r.userId,n,o),e=[];for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield it(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield dn(n),r=yield Mt(o.id);i.push(r)}}return i}))}function ni(t,e){return ti(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=[],r=yield dn(t),c=yield Un(e);if(c.id>0){let t=yield Ye(c.id,r.id,r.userId,n,o),e=[];for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield dn(n);i.push(o)}}return i}))}class oi{constructor(t,e,n,o){this.value=[],this.height=1,this.key=t,this.value.push(e),this.leftNode=n,this.rightNode=o}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e.value.push(...t.value),e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.rightNode=this.removeNode(t.rightNode,n.key),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var ii=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ri{static compositeKey(t,e){return("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+e.toString(16).toUpperCase()).slice(-4)}static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return ii(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isDataLoaded)return t("done");setTimeout(ri.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){let o=this.compositeKey(e,n);var i=new oi(o,t,null,null);this.addNodeToTree(i)}static getNodeFromTree(t,e){return ii(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}let n=this.compositeKey(t,e);return this.root?this.root.getFromNode(n,this.root):null}))}static removeNodeFromTree(t){return ii(this,arguments,void 0,(function*(t,e=999){if(this.root){let n=this.compositeKey(t,e);this.root=this.root.removeNode(this.root,n)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}ri.root=null;var ci=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ai(t,e){return ci(this,arguments,void 0,(function*(t,e,n=999){let o=yield ri.getNodeFromTree(t,n);console.log("this is the ghost id",t,n);let i=Nt();if(o)for(let t=0;t<o.value.length;t++){let n=o.value[t];n.ghostId==e&&(i=n)}return i}))}function si(t,e){return ci(this,arguments,void 0,(function*(t,e,n=999){ri.addConceptToTree(t,e,n)}))}const li=1,di=2,hi=3,ui=4,fi=5,yi=6,pi=7;var vi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},gi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function mi(t,e){return gi(this,arguments,void 0,(function*(t,e,n=""){let o=yield er(t,e,n),i=o.compositionIds,r=o.internalConnections,c=o.linkers,a=o.reverse,s=o.mainCompositionIds,l=yield co(c),d=yield so(i,r);return yield wi(l,d,s,a)}))}function Ci(t,e,n,o,i){return gi(this,void 0,void 0,(function*(){let r=yield co(t),c=yield lo(e,n);return yield wi(r,c,o,i)}))}var Ni=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ti(t){return Ni(this,arguments,void 0,(function*(t,e="",n=null,o=di){var i,r,c,a,s,l,d,h;let u=[],f=[],y=[],p=[],v=t[0].composition,g={},m={};try{(null==n?void 0:n.isDataLoaded)?(g.compositionIds=null===(i=n.conceptIds)||void 0===i?void 0:i.slice(),g.internalConnections=null===(r=n.internalConnections)||void 0===r?void 0:r.slice(),g.linkers=null===(c=n.linkers)||void 0===c?void 0:c.slice(),g.reverse=null===(a=n.reverse)||void 0===a?void 0:a.slice(),m=g,u=m.compositionIds,y=m.internalConnections,f=m.linkers,p=m.reverse):(g=yield U(t,e),n&&(n.conceptIds=null===(s=g.compositionIds)||void 0===s?void 0:s.slice(),n.internalConnections=null===(l=g.internalConnections)||void 0===l?void 0:l.slice(),n.linkers=null===(d=g.linkers)||void 0===d?void 0:d.slice(),n.reverse=null===(h=g.reverse)||void 0===h?void 0:h.slice(),n.isDataLoaded=!0),m=g,u=m.compositionIds,y=m.internalConnections,f=m.linkers,p=m.reverse);let C=yield function(t,e,n,o,i,r){return Ni(this,arguments,void 0,(function*(t,e,n,o,i,r,c=di){(new Date).getTime();let a,s,l=yield co(t);return c==hi?(a=yield so(e,n),s=yield ki(t,a,i,o)):c==li?(a=yield lo(e,n),s=yield ki(t,a,i,o)):100==c?(a=yield function(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e);let n={};for(let e=0;e<t.length;e++){let o=yield jt(t[e]);n[t[e]]=o}return n}))}(e,n),s=yield Ii(l,a,i,o)):c==pi?s=yield Ci(t,e,n,r.ofCompositions,o):(a=yield ao(e,n),s=yield Ii(l,a,i,o)),s}))}(f,u,y,p,v,t[0],o);return C}catch(t){throw console.log("this is the error in the search link multiple",t),t}}))}function Ii(t,e,n){return Ni(this,arguments,void 0,(function*(t,e,n,o=[]){(new Date).getTime();let i={},r=[];for(let e=0;e<t.length;e++)r.push(t[e].toTheConceptId),r.push(t[e].ofTheConceptId),r.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let i=!1;if(o.includes(t[n].id)&&(i=!0),1==i){if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].toTheConceptId],i=yield dn(t[n].typeId),r=null==o?void 0:o.data,c=Object.keys(r)[0];try{let o=i.characterValue+"_reverse";"string"==typeof r&&(r={}),Array.isArray(r[c][o])||("string"==typeof r[c]&&(r[c]={}),r[c][o]=[]),r[c][o].push(e[t[n].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].ofTheConceptId],i=yield dn(t[n].typeId),r=null==o?void 0:o.data,c=Object.keys(r)[0];try{"string"==typeof r&&(r={}),Array.isArray(r[c][i.characterValue])||("string"==typeof r[c]&&(r[c]={}),r[c][i.characterValue]=[]),r[c][i.characterValue].push(e[t[n].toTheConceptId])}catch(t){console.log("this is error",t)}}}return i=e[n],i}))}function wi(t,e,n){return Ni(this,arguments,void 0,(function*(t,e,n,o=[]){let i=[],r=[];for(let e=0;e<t.length;e++)r.push(t[e].toTheConceptId),r.push(t[e].ofTheConceptId),r.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let i=!1;if(o.includes(t[n].id)&&(i=!0),1==i){if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].toTheConceptId],i=yield dn(t[n].typeId),r=Object.keys(o)[0];try{let c=i.characterValue+"_reverse";"string"==typeof o&&(o={}),Array.isArray(o[r][c])||("string"==typeof o[r]&&(o[r]={}),o[r][c]=[]),o[r][c].push(e[t[n].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].ofTheConceptId],i=yield dn(t[n].typeId),r=Object.keys(o)[0];try{"string"==typeof o&&(o={}),Array.isArray(o[r][i.characterValue])||("string"==typeof o[r]&&(o[r]={}),o[r][i.characterValue]=[]),o[r][i.characterValue].push(e[t[n].toTheConceptId])}catch(t){console.log("this is error",t)}}}for(let t=0;t<n.length;t++){let o=e[n[t]];i.push(o)}return i}))}function ki(t,e,n){return Ni(this,arguments,void 0,(function*(t,e,n,o=[]){let i={},r=yield Yn(t),c=[];for(let t=0;t<r.length;t++)c.push(r[t].toTheConceptId),c.push(r[t].ofTheConceptId),c.push(r[t].typeId);yield X(c),r.sort((function(t,e){return e.id-t.id}));for(let t=0;t<r.length;t++){let n=!1;if(o.includes(r[t].id)&&(n=!0),1==n){if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].toTheConceptId],o=yield dn(r[t].typeId),i=n,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(e[r[t].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].ofTheConceptId],o=yield dn(r[t].typeId),i=n,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(e[r[t].toTheConceptId])}catch(t){console.log("this is error",t)}}}return i=e[n],i}))}function Ai(t){var e,n;const o=Nt();return o.id=t.id,o.ghostId=t.ghostId,o.userId=t.userId,o.accessId=t.accessId,o.categoryId=t.categoryId,o.characterValue=t.characterValue,o.entryTimeStamp=t.entryTimeStamp,o.typeId=t.typeId,o.type=t.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(e=null==t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"",o}function xi(t){const e=C();return e.id=t.id,e.ghostId=t.ghostId,e.userId=t.userId,e.accessId=t.accessId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.categoryId=t.categoryId,e}function Si(t){const e=new O(0,0,0,0,0,0,0);return e.id=t.id,e.ghostId=t.ghostId,e.accessId=t.accessId,e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.isTemp=!1,e}var Li=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ri(t){return Li(this,void 0,void 0,(function*(){try{let e=Nt();if(t<0){if(e=yield Lt.GetConcept(t),0==e.id){let n=yield It.getNodeFromTree(t);if(null==n?void 0:n.value){let t=n.value;t&&(e=t)}}}else e=Ai(yield dn(t));return e}catch(t){throw t}}))}var bi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Gi(t){return bi(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=Nt(),a=Nt();const s=[],l=t.compositionId,d=t.ofTheCompositionId;let h=[],u=yield _t(l);for(let t=0;t<u.length;t++)i.push(Si(u[t]));const f=[],y=[];let p=[];for(let t=0;t<i.length;t++)Io(y,i[t].ofTheConceptId),Io(f,i[t].ofTheConceptId),Io(f,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);for(let t=0;t<f.length;t++){const e=yield dn(f[t]);l==f[t]&&(c=Ai(e)),d==f[t]&&(a=Ai(e)),r.push(Ai(e))}const v=t.patchObject;for(const t in v){let l=Nt();const d=v[t];let u=c;a.id>0&&(u=a),Array.isArray(d)||"object"==typeof d?(l=yield Qe(t,"",!0,c.userId,4,999),yield Ke(v[t],l.id,l.userId,c.id,c.userId,4,999)):l=yield Qe(t,d,!1,e,o,n);const f=ko(r,l);for(let t=0;t<f.length;t++)if(f[t].id>0){const e=xo(i,f[t].id);h=h.concat(e),s.push(f[t])}yield Me(u.id,l.id,c.id,2),r.push(l)}for(let t=0;t<h.length;t++)yield sn(h[t].id);yield kt.SyncDataOnline()}))}var _i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Bi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pi(t,e,n){return Bi(this,void 0,void 0,(function*(){try{let n=yield te(e),o=[];0!=n.id&&(o=yield function(t,e){return _i(this,void 0,void 0,(function*(){try{return yield xt.GetConnectionOfCompositionAndTypeLocal(e,t)}catch(t){throw t}}))}(t,n.id));let i=[];for(let t=0;t<o.length;t++){let e=yield le(o[t].toTheConceptId);i.push(e)}return i}catch(t){throw t}}))}var Ui=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Fi(t){return Ui(this,void 0,void 0,(function*(){let e=[];try{var n=G();const i=yield fetch(o.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){let t=yield i.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;X(i),n[r]=e}return n}return console.log("View Internal Data error",i.status),L(i),e}catch(t){throw t instanceof Error?console.log(" This is the view internal data error message: ",t.message):console.log(" This is the view internal data unexpected error: ",t),t}}))}var Di=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ei(t){return Di(this,void 0,void 0,(function*(){var e;try{let n=yield Fi(t),o=[];for(let i=0;i<t.length;i++){let r=t[i],c=n[r];if(r&&c){let t=[],e={};for(let e=0;e<c.length;e++)t.includes(c[e].ofTheConceptId)||t.push(c[e].ofTheConceptId);let n=yield qt(r,c,t);e.data=n,e.id=r,o.push(e)}else{let t={};t.id=r;let n=yield dn(r),i={};n.type&&(i[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=i,o.push(t))}}return o}catch(t){throw t}}))}var Oi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Vi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ji(t){return Vi(this,arguments,void 0,(function*(t,e=""){try{let n=yield function(t){return Oi(this,arguments,void 0,(function*(t,e=""){var n=_("application/json",e);let i=o.SearchInternalWithAuthenticatedCcsUrl();i=i+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(i,{method:"GET",headers:n});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),L(t),[])}catch(t){console.log("This is the searching internal error",t),R(t,i)}}))}(t,e);return yield Ei(n)}catch(t){throw t}}))}function Mi(t){return Vi(this,arguments,void 0,(function*(t,e=""){try{return yield function(t){return Oi(this,void 0,void 0,(function*(){var e=_("application/json","");let n=o.SearchInternalWithCcsUrl();n=n+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(n,{method:"GET",headers:e});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),L(t),[])}catch(t){console.log("This is the searching internal error",t),R(t,n)}}))}(t)}catch(t){throw t}}))}var Hi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Wi(t,e,n){return Hi(this,arguments,void 0,(function*(t,e,n,o=!1){var i,r;try{if(t.userId,o){let o=(null===(i=e.type)||void 0===i?void 0:i.characterValue)+"_s_"+n+"_by";var c=yield Qe("connection",o,!1,999,999,999);yield Me(e.id,t.id,c.id,1e3)}let s=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+n+"_s";var a=yield Qe("connection",s,!1,999,999,999);return yield Me(t.id,e.id,a.id,1e3)}catch(t){throw t}}))}var $i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qi(t){return $i(this,void 0,void 0,(function*(){let e=yield Ri(t);Lt.RemoveConcept(e)}))}var Ji=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},zi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Qi(t,e,n,i){return zi(this,arguments,void 0,(function*(t,e,n,i,r=!0){var c,a;let s=C();if(""!=n){let o="";o=r?(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+n+"_s":(null===(a=e.type)||void 0===a?void 0:a.characterValue)+"_s_"+n+"_by",s=yield _e("connection",o,!1,999)}""!=i&&(s=yield Dn(i));let l=yield function(t,e,n){return Ji(this,void 0,void 0,(function*(){var i=[];try{var r=new FormData;r.append("ofConceptId",t.toString()),r.append("mainKey",n.toString()),r.append("toConceptId",e.toString());const a=yield fetch(o.GetCompositionConnectionBetweenTwoConceptsUrl(),{method:"POST",body:r,redirect:"follow"});if(a.ok){const t=yield a.json();for(var c=0;c<t.length;c++)Z.AddConnection(t[c]),i.push(t[c])}else console.log("Get composition connection between two concepts",a.status),L(a)}catch(t){t instanceof Error?console.log("Get composition connection between two concepts error message: ",t.message):console.log("Get composition connection between two concepts unexpected error: ",t),R(t,o.GetCompositionConnectionBetweenTwoConceptsUrl())}return i}))}(t.id,e.id,s.id);return l}))}function Zi(t,e){return new Promise(((n,o)=>{setTimeout((()=>{n(e)}),t)}))}const Ki=3,Xi=4,Yi=5;var tr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function er(t,e){return tr(this,arguments,void 0,(function*(t,e,n=""){let i=o.SearchAllTypeWithLinker(t.auth);var r=_("application/json",n);i=i+"?search="+t.search+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;const c=JSON.stringify(e);try{const t=yield fetch(i,{method:"POST",headers:r,body:c});return t.ok?yield t.json():(L(t),console.log("This is the searching multiple error",t.status),[])}catch(t){console.log("This is the searching SearchWithTypeAndLinker error",t),R(t,i)}}))}var nr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class or{constructor(){this.subscribers=[],this.mainConcept=0,this.compositionIds=[],this.conceptIds=[],this.internalConnections=[],this.reverse=[],this.linkers=[],this.dependency=[],this.isDataLoaded=!1,this.isUpdating=!1,this.fetched=!1,this.format=li}listenToEventType(t){window.addEventListener(`${t}`,(t=>{if(this.isUpdating)console.log("rejected this");else{this.isUpdating=!0;let e=this;setTimeout((function(){return nr(this,void 0,void 0,(function*(){let n=t;e.compositionIds.includes(null==n?void 0:n.detail)||(e.compositionIds.unshift(null==n?void 0:n.detail),e.listenToEvent(null==n?void 0:n.detail)),e.isUpdating=!1,yield e.bind(),e.notify()}))}),200)}}))}listenToEvent(t){window.addEventListener(`${t}`,(e=>{if(this.isUpdating)console.log("rejected this");else{this.isUpdating=!0;let e=this;setTimeout((function(){return nr(this,void 0,void 0,(function*(){let n=yield Z.GetConnectionByOfTheConceptAndType(t,t);for(let t=0;t<n.length;t++)yield Z.GetConnection(n[t]).then((t=>{t.typeId==e.mainConcept?e.internalConnections.includes(t.id)||e.internalConnections.push(t.id):e.linkers.includes(t.id)||e.linkers.push(t.id),e.conceptIds.includes(t.toTheConceptId)||e.conceptIds.push(t.toTheConceptId),e.compositionIds.includes(t.ofTheConceptId)||e.compositionIds.push(t.ofTheConceptId)}));e.isUpdating=!1,yield e.bind(),e.notify()}))}),200)}}))}listenToEventConnectionType(t,e){window.addEventListener(`${t}`,(n=>{if(this.isUpdating)console.log("rejected this");else{this.isUpdating=!0;let n=this;setTimeout((function(){return nr(this,void 0,void 0,(function*(){let o=yield Z.GetConnectionByOfTheConceptAndType(t,t);for(let t=0;t<o.length;t++)o.typeId==e&&(yield Z.GetConnection(o[t]).then((t=>{t.typeId==n.mainConcept?n.internalConnections.includes(t.id)||n.internalConnections.push(t.id):n.linkers.includes(t.id)||n.linkers.push(t.id),n.conceptIds.includes(t.toTheConceptId)||n.conceptIds.push(t.toTheConceptId),n.compositionIds.includes(t.ofTheConceptId)||n.compositionIds.push(t.ofTheConceptId)})));n.isUpdating=!1,yield n.bind(),n.notify()}))}),200)}}))}bind(){return nr(this,void 0,void 0,(function*(){console.log("this is the old execute data")}))}subscribe(t){return nr(this,void 0,void 0,(function*(){return this.subscribers.push(t),console.log("again executing data"),yield this.bind(),t(this.data)}))}unsubscribe(t){return this.subscribers.filter((e=>e!=t)),this.subscribers.length}notify(){console.log("notifiers",this.subscribers),this.subscribers.map((t=>{console.log("notify"),t(this.data)}))}}class ir extends or{constructor(t,e,n=di){super(),this.searchQuery=[],this.format=di,this.searchQuery=t,this.format=n}bind(){return t=this,e=void 0,o=function*(){return this.data=yield Ti(this.searchQuery,"",this,this.format),this.mainConcept=this.searchQuery[0].composition,this.listenToEvent(this.mainConcept),console.log("this is the data",this.data),this.data},new((n=void 0)||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}));var t,e,n,o}}function rr(t,e,n=di){return new ir(t,null!=e?e:"",n)}var cr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ar extends or{constructor(t,e=hi){super(),this.id=t,this.format=e}bind(){return cr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){let t=yield function(t){return Pt(this,void 0,void 0,(function*(){let e=[];e=yield _t(t);let n=[];for(let t=0;t<e.length;t++)n.includes(e[t].ofTheConceptId)||n.push(e[t].ofTheConceptId);return{connectionList:e,compositionList:n}}))}(this.id);this.mainConcept=this.id,this.compositionIds=t.compositionList;let e=t.connectionList;for(let t=0;t<e.length;t++)this.internalConnections.push(e[t].id);this.isDataLoaded=!0,this.listenToEvent(this.mainConcept)}return yield this.build()}))}build(){return cr(this,void 0,void 0,(function*(){let t=[],e=this.internalConnections;for(let n=0;n<e.length;n++)t.push(yield Z.GetConnection(e[n]));return this.format==hi?(console.log("this is the data for the build layer",t,this.mainConcept,this.internalConnections,this.compositionIds),this.data=yield Ut(this.mainConcept,t,this.compositionIds)):this.format==di?this.data=yield function(t,e,n){return Pt(this,void 0,void 0,(function*(){var o,i;let r={},c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,e,n);r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a;let s={};return s.created_at=c.entryTimeStamp,s.data=r,s.id=t,s}))}(this.mainConcept,t,this.compositionIds):this.format==li?this.data=yield function(t,e,n){return Pt(this,void 0,void 0,(function*(){var o,i;let r={},c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield $t(c,e,n);return r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a,r}))}(this.mainConcept,t,this.compositionIds):this.data=yield Ut(this.mainConcept,t,this.compositionIds),this.data}))}}function sr(t,e=hi){return new ar(t,e)}var lr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class dr extends or{constructor(t,e,n,o,i){super(),this.data=[],this.startPage=0,this.compositionName=t,this.userId=e,this.inpage=n,this.page=o,this.format=i}bind(){return lr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){console.log("again data loading mechanism");var t=yield Kt(this.compositionName);if(t){yield E(this.compositionName,this.userId),console.log("getting the user data",t.id,this.userId);let o=yield k.GetConceptsByTypeIdAndUser(t.id,this.userId);console.log("this is the concept list",o);for(var e=this.inpage*(this.page-1),n=e;n<e+this.inpage;n++)o[n]&&this.compositionIds.push(o[n].id)}yield it(this.compositionIds),this.isDataLoaded=!0,this.listenToEventType(t.id);for(let t=0;t<this.compositionIds.length;t++)console.log("list listen",this.compositionIds[t]),this.listenToEvent(this.compositionIds[t])}return yield this.build()}))}build(){return lr(this,void 0,void 0,(function*(){if(this.data=[],console.log("this is building the data list"),this.format==hi){for(let t=this.startPage;t<this.startPage+this.inpage;t++)if(this.compositionIds[t]){let e=yield Et(this.compositionIds[t]);this.data.push(e)}}else if(this.format==di){for(let t=this.startPage;t<this.startPage+this.inpage;t++)if(this.compositionIds[t]){let e=yield Vt(this.compositionIds[t]);this.data.push(e)}}else if(this.format==li){for(let t=this.startPage;t<this.startPage+this.inpage;t++)if(this.compositionIds[t]){let e=yield Ot(this.compositionIds[t]);this.data.push(e)}}else for(let t=this.startPage;t<this.startPage+this.inpage;t++)if(this.compositionIds[t]){let e=yield Et(this.compositionIds[t]);this.data.push(e)}return this.data}))}}function hr(t,e,n,o,i=hi){return new dr(t,e,n,o,i)}var ur=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class fr extends or{constructor(t,e,n,o,i){super(),this.connections=[],this.data=[],this.mainConcept=t,this.linker=e,this.inpage=n,this.page=o,this.format=i}bind(){return ur(this,void 0,void 0,(function*(){var t;if(!this.isDataLoaded){let o=yield dn(this.mainConcept),i=(null===(t=o.type)||void 0===t?void 0:t.characterValue)+"_s_"+this.linker,r=yield Ie(i,16);if(r.id>0){let t=yield Ye(r.id,o.id,o.userId,this.inpage,this.page);this.connections=t;for(var e=[],n=0;n<this.connections.length;n++)e.push(this.connections[n].toTheConceptId),this.listenToEvent(this.connections[n].toTheConceptId);yield it(e)}this.isDataLoaded=!0,this.listenToEvent(this.mainConcept)}return yield this.build()}))}build(){return ur(this,void 0,void 0,(function*(){this.connections=yield Yn(this.linkers);for(var t=0;t<this.connections.length;t++){let e=this.connections[t].toTheConceptId,n=yield dn(e);if(console.log("this is the format",this.format),this.format==li){let t=yield Vt(n.id);this.data.push(t)}else if(this.format==hi){let t=yield Et(n.id);this.data.push(t)}else if(this.format==ui){let t=yield Mt(n.id);this.data.push(t)}else{let t=yield Mt(n.id);this.data.push(t)}}return this.data}))}}function yr(t,e,n,o,i=li){return new fr(t,e,n,o,i)}var pr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class vr extends or{constructor(t,e,n="",o){super(),this.searchText="",this.connections=[],this.externalConnectionIds=[],this.data=[],this.mainConcept=t,this.searchLinkers=e,this.textSearch=n,o&&(this.format=o)}bind(){return pr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){this.isDataLoaded=!0;const t=yield fo(this.mainConcept,this.searchLinkers,this.textSearch);this.compositionIds=t.compositionIds||[],this.internalConnections=t.internalConnections||[],this.externalConnectionIds=t.externalConnections||[],this.connections=yield Yn(this.externalConnectionIds);for(let t=0;t<this.compositionIds.length;t++)this.listenToEvent(this.compositionIds[t])}return yield this.build()}))}build(){return pr(this,void 0,void 0,(function*(){return this.format&&this.format==fi?this.data={compositionIds:this.compositionIds,internalConnections:this.internalConnections,externalConnections:this.externalConnectionIds}:this.data=yield oo(this.compositionIds,this.internalConnections),this.data}))}}function gr(t,e,n="",o){return new vr(t,e,n,o)}var mr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Cr extends or{constructor(t,e,n,o=di){super(),this.searchQuery=[],this.format=di,this.mainCompositionIds=[],this.searchCharacter="",this.token="",this.searchStructure=t,this.searchQuery=e,this.searchQuery[0].type=t.composition,this.searchCharacter=t.composition,this.format=o,this.token=b.BearerAccessToken}listenToEventType(t){window.addEventListener(`${t}`,(t=>{if(this.isUpdating)console.log("rejected this");else{this.isUpdating=!0;let e=this;setTimeout((function(){return mr(this,void 0,void 0,(function*(){let n=t;e.mainCompositionIds.includes(null==n?void 0:n.detail)||(e.mainCompositionIds.unshift(null==n?void 0:n.detail),e.conceptIds.push(null==n?void 0:n.detail),e.listenToEvent(null==n?void 0:n.detail),Z.GetConnectionsOfConcept(null==n?void 0:n.detail).then((t=>{for(let n=0;n<t.length;n++)e.linkers.push(t[n].id)}))),e.isUpdating=!1,yield e.bind(),e.notify()}))}),200)}}))}bind(){return mr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){this.isDataLoaded=!0;var t=yield Kt(this.searchCharacter);let e=yield er(this.searchStructure,this.searchQuery,this.token);this.conceptIds=e.compositionIds,this.internalConnections=e.internalConnections,this.linkers=e.linkers,this.reverse=e.reverse,this.mainCompositionIds=e.mainCompositionIds,this.listenToEventType(t.id);for(let t=0;t<this.mainCompositionIds.length;t++)this.listenToEvent(this.mainCompositionIds[t])}return yield this.build()}))}build(){return mr(this,void 0,void 0,(function*(){return yield X(this.conceptIds),this.format==di?this.data=yield function(t,e,n,o,i){return gi(this,void 0,void 0,(function*(){let r=yield co(t),c=yield ao(e,n),a=yield function(t,e,n,o){return Ni(this,arguments,void 0,(function*(t,e,n,o,i=[]){(new Date).getTime();let r=[],c=[];for(let e=0;e<t.length;e++)c.push(t[e].toTheConceptId),c.push(t[e].ofTheConceptId),c.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1;if(i.includes(t[n].id)&&(o=!0),1==o){if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].toTheConceptId],i=yield dn(t[n].typeId),r=null==o?void 0:o.data,c=Object.keys(r)[0];try{let o=i.characterValue+"_reverse";"string"==typeof r&&(r={}),Array.isArray(r[c][o])||("string"==typeof r[c]&&(r[c]={}),r[c][o]=[]),r[c][o].push(e[t[n].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].ofTheConceptId],i=yield dn(t[n].typeId),r=null==o?void 0:o.data,c=Object.keys(r)[0];try{"string"==typeof r&&(r={}),Array.isArray(r[c][i.characterValue])||("string"==typeof r[c]&&(r[c]={}),r[c][i.characterValue]=[]),r[c][i.characterValue].push(e[t[n].toTheConceptId])}catch(t){console.log("this is error",t)}}}for(let t=0;t<o.length;t++){let n=e[o[t]];r.push(n)}return r}))}(r,c,e,o,i);return a}))}(this.linkers,this.conceptIds,this.internalConnections,this.mainCompositionIds,this.reverse):this.data=yield Ci(this.linkers,this.conceptIds,this.internalConnections,this.mainCompositionIds,this.reverse),this.data}))}}function Nr(t,e,n,o=di){return new Cr(t,e,n,o)}class Tr{constructor(t,e,n,i,r,c,a,s=!1,l,d,h){this.structureType="lconcept",this.isComposition=!1,this.isTemp=!1,this.isSynced=!1,this.applicationId=o.BASE_RANDOMIZER,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=i,this.characterValue=c,this.accessId=r,this.type=null,this.isNew=s,this.typeCharacter=a,this.entryTimeStamp=l,this.updatedTimeStamp=d,this.isSynced=!1,this.referentId=h}getType(){console.log(this.typeId)}}class Ir{constructor(t,e,n,i,r,c){this.isTemp=!1,this.applicationId=o.BASE_RANDOMIZER,this.type=C(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.typeId=i,this.ghostId=t,this.orderId=r,this.typeCharacter="",this.accessId=c,this.typeCharacter="",this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date}}class wr{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class kr{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 Ar{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class xr{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1,this.auth=!0}}var Sr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Lr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Rr{}Rr.isUpdated=!1,Rr.isOnlineSync=!1;var br=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Gr(){return br(this,arguments,void 0,(function*(t=!0){try{if(yield a("concepts"),yield st("concepts"),t){var e=yield new Promise((function(t,e){let o="settings";a(o).then((i=>{let r=i.transaction(o,"readwrite").objectStore(o).getAll();r.onsuccess=()=>{let e=new n(!1),o=r.result;for(let t=0;t<o.length;t++)e=o[t];t(e)},r.onerror=t=>{e(t)}})).catch((t=>{e({status:400,ok:!1,message:"Cannot get last object from database because you cannot open the database",data:t})}))}));if(e.isOnlineSync)return!0;yield function(){return Lr(this,void 0,void 0,(function*(){try{const i=(new Date).getTime();var t=_("application/x-www-form-urlencoded");const r=yield fetch(o.GetAllAiData(),{method:"GET",headers:t});r.ok||(console.log("Ai Error Message: ","Cannot get response"),L(r));const c=yield r.json();for(var e=0;e<c.length;e++)k.AddConcept(c[e]);!function(){br(this,void 0,void 0,(function*(){Rr.isOnlineSync=!0;var t,e=new n(Rr.isOnlineSync);t=e,new Promise((function(e,n){let o="settings";a(o).then((i=>{const r=i.transaction(o,"readwrite").objectStore(o).put(t);r.onsuccess=n=>{e(t)},r.onerror=e=>{n({status:400,ok:!1,message:"Cannot update AI flag",data:e,body:t})}})).catch((t=>{n({status:400,ok:!1,message:"Cannot update AI flag because you cannot open the database",data:t})}))}))}))}();let s=(new Date).getTime()-i;console.log("The time taken is ",s)}catch(t){t instanceof Error?console.log("Ai Error Message: ",t.message):console.log("Ai Error Message: ",t),R(t,o.GetAllAiData())}}))}()}return!0}catch(t){let e={message:"cannot initlize the AI system",ok:!1,status:400,data:t};return console.log(e),!0}}))}const _r={number:/^\d+(\.\d+)?$/,text:/^[\s\S]*$/,textOnly:/^[A-Za-z\s]+$/,email:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,document:/\.(pdf|docx?|pptx?|xlsx?)$/i,sound:/\.(mp3|wav|ogg|flac)$/i,image:/\.(jpg|jpeg|png|gif|bmp|svg|webp)$/i,video:/\.(mp4|avi|mov|mkv|flv|webm)$/i,url:/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,date:/^\d{4}-\d{2}-\d{2}$/,time:/^(?:[01]\d|2[0-3]):[0-5]\d$/,password:/^.{6,}$/,ipaddress:/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4})$/,uuid:/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/};var Br=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Pr{constructor(){Pr.cacheInitialized||Pr.initializeAnomalyParameters()}static initializeAnomalyParameters(){return Br(this,void 0,void 0,(function*(){try{yield Pr.getAnomalyParameters(),Pr.refreshCache(),Pr.cacheInitialized=!0}catch(t){console.error("Error during anomaly parameter initialization:",t)}}))}static getAnomalyParameters(){return Br(this,void 0,void 0,(function*(){const t=Date.now();if(Pr.anomalyParamsCache&&t-Pr.lastFetchedTime<Pr.cacheExpiryThreshold)return console.log("Returning cached anomaly parameters"),Pr.anomalyParamsCache;try{return yield Pr.fetchAnomalyParameters()}catch(t){throw console.error("Error fetching anomaly parameters:",t),t}}))}static fetchAnomalyParameters(){return Br(this,void 0,void 0,(function*(){try{const t=yield fetch("https://devai.freeschema.com/v1/get-frontend-anomaly-parameters",{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch anomaly parameters");const e=yield t.json();return Pr.anomalyParamsCache=e.data,Pr.lastFetchedTime=Date.now(),e.data}catch(t){throw console.error("API Fetch Error:",t),t}}))}static refreshCache(){return Br(this,void 0,void 0,(function*(){try{Date.now()-Pr.lastFetchedTime>Pr.cacheExpiryThreshold&&(yield Pr.getAnomalyParameters())}catch(t){console.error("Error refreshing anomaly parameters cache:",t)}}))}detectDataType(t){for(const[e,n]of Object.entries(_r))if(n.test(t))return e;return null}checkConceptAnomaly(t,e){return Br(this,void 0,void 0,(function*(){const n=[];try{if(!e)return n.push("Null value"),{valid:!1,warnings:n};const o=Pr.anomalyParamsCache;t.startsWith("the_")||(t=`the_${t}`);const i=o[t];if(console.log("Concept Details : ",i),!i)return console.warn(`No concept details found for type: ${t}`),n.push(`No concept details found for type: ${t}`),{valid:!1,warnings:n};const r=e.length,{min_length:c,max_length:a,data_types:s}=i,l=r>=c&&r<=a,d=this.detectDataType(e),h=s.includes(d);return l||n.push(`Length of '${e}' is outside the allowed range (min: ${c}, max: ${a}). Current length: ${r}.`),h||n.push(`Type mismatch for '${e}'. Expected types: ${s.join(", ")}, detected type: ${d}.`),l&&h&&n.push(`Concept ${t} is valid. Length: ${r}, Type: ${d}`),{valid:l&&h,warnings:n}}catch(o){return console.error(`Error checking anomaly for ${t} with value ${e}:`,o),{valid:!1,warnings:n}}}))}static checkAnomalyInBulk(t){return Br(this,void 0,void 0,(function*(){Pr.cacheInitialized||(yield Pr.initializeAnomalyParameters());try{const e={};for(const[n,o]of Object.entries(t)){const t=o.value,{valid:i,warnings:r}=yield(new Pr).checkConceptAnomaly(n,t);e[n]={valid:i,warnings:r}}return e}catch(t){throw console.error("Bulk Anomaly Check Error:",t),t}}))}}Pr.anomalyParamsCache=null,Pr.cacheInitialized=!1,Pr.lastFetchedTime=0,Pr.cacheExpiryThreshold=6e5;var Ur=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Fr{checkUniqueness(t,e){return Ur(this,void 0,void 0,(function*(){t.startsWith("the_")||(t="the_"+t);let n=(yield _n(t,999,999,999)).id,o=yield Ie(e,n);return!o||!o.id}))}validateField(t,e,n,o,i,r,c,a,s,l,d){return Ur(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a,s,l,d,h=!1){var u;const f=[];if(!d||null!==n&&""!==n||f.push(`${t} is required`),e&&n){const o=_r[e];o&&""!==n&&!o.test(n)&&f.push(`Invalid format for ${e} in ${t}`)}if(n&&null!==i&&n.length>i&&f.push(`${t} exceeds the maximum length of ${i}`),n&&null!==r&&n.length<r&&f.push(`${t} must be at least ${r} characters long`),null!==c&&n&&!isNaN(Number(n))&&Number(n)<c&&f.push(`${t} must be greater than or equal to ${c}`),null!==a&&n&&!isNaN(Number(n))&&Number(n)>a&&f.push(`${t} must be less than or equal to ${a}`),"file"===e&&l&&s){const e=s.split(",").map((t=>t.trim().toLowerCase())),n=null===(u=l.name.split(".").pop())||void 0===u?void 0:u.toLowerCase();n&&!e.includes(n)&&f.push(`${t} must be a valid file type: ${e.join(", ")}`)}return o&&h&&n&&((yield this.checkUniqueness(o,n))||f.push(`${t} is not unique`)),f}))}validateForm(t){return Ur(this,void 0,void 0,(function*(){const e={};for(const n in t){const{value:o,dataType:i,conceptType:r,maxLength:c=null,minLength:a=null,minValue:s=null,maxValue:l=null,accept:d=null,file:h=null,required:u,isUnique:f}=t[n],y=yield this.validateField(n,i,o,r,c,a,s,l,d,h,u,f);y.length>0&&(e[n]=y)}return e}))}}const Dr=t=>{const e=document.getElementsByName(t)[0];if(!e)return console.warn(`Element with NAME "${t}" not found.`),{value:null,dataType:null,conceptType:null,maxLength:null,minLength:null,minValue:null,maxValue:null,accept:null,required:!1,isUnique:!0};const n=e.hasAttribute("required")||"true"===e.getAttribute("data-required"),o=e.hasAttribute("isUnique")&&"true"===e.getAttribute("isUnique");return{value:e.value,dataType:e.getAttribute("data-type"),conceptType:e.getAttribute("concept-type"),maxLength:e.getAttribute("data-maxlength")?parseInt(e.getAttribute("data-maxlength")):null,minLength:e.getAttribute("data-minlength")?parseInt(e.getAttribute("data-minlength")):null,minValue:e.getAttribute("data-min")?parseInt(e.getAttribute("data-min")):null,maxValue:e.getAttribute("data-max")?parseInt(e.getAttribute("data-max")):null,accept:e.getAttribute("accept")||null,required:n,isUnique:o}};class Er{constructor(){this.subscribers=[]}notify(){this.subscribers.map((t=>{t(this.data)}))}dataChange(t){return this.subscribers.push(t),t(this.data)}}class Or extends Er{constructor(){super(...arguments),this.elementIdentifier=0,this.widgetMounted=!1}getComponent(){return document.getElementById(this.elementIdentifier.toString())}getElementById(t){let e=this.getComponent(),n=document.body;if(e){let o=e.querySelector("#"+t);if(o)return n=o,n}return null}createWidgetWrapperIdentifier(){return this.elementIdentifier=1e4*Math.random(),this.elementIdentifier.toString()}}class Vr extends Or{constructor(){super(...arguments),this.childWidgets=[],this.parentElement="",this.element=null}setTitle(t){document.title=t}getHtml(){return""}UpdateChildData(t,e){let n=e;n.data=t,n.render(),n.updateWidget()}updateWidget(){}setState(t){this.data=t,this.notify(),this.render()}loadChildWidgets(){this.childWidgets.map((t=>{let e=this.getElementById(t.parentElement);e&&(e.innerHTML=""),t.mount(e)}))}render(){this.element&&(this.element.innerHTML=this.getHtml()),this.addEvents(),this.widgetMounted&&this.loadChildWidgets()}mountChildWidgets(){}mount(t){return e=this,n=void 0,i=function*(){t&&(this.element=document.createElement("div"),this.element.id=this.createWidgetWrapperIdentifier(),this.element.innerHTML=yield this.getHtml(),t.appendChild(this.element),this.parentElement=t.id,0==this.widgetMounted?(this.widgetDidMount(),this.mountChildWidgets(),this.widgetMounted=!0):this.render())},new((o=void 0)||(o=Promise))((function(t,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}));var e,n,o,i}widgetDidMount(){this.render()}addEvents(){}}var jr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Mr(t,e){return jr(this,void 0,void 0,(function*(){let n=yield On(t);for(let t=0;t<n.length;t++)Z.AddConnection(n[t]);let o=yield Z.GetConnectionsOfConcept(t),i=yield Kt(e),r=[];for(let t=0;t<o.length;t++)o[t].typeId==i.id&&r.push(o[t]);for(let t=0;t<r.length;t++)sn(r[t].id)}))}class Hr{constructor(){this.type="",this.inpage=10,this.page=1,this.concepts=[],this.conceptIds=[],this.selectors=[],this.freeschemaQueries=[],this.filters=[],this.filterLogic="",this.typeConnection="",this.outputFormat=li,this.name="",this.reverse=!1}}var Wr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function $r(t){return Wr(this,arguments,void 0,(function*(t,e=""){var n=_("application/json",e);const i=o.FreeschemaQueryUrl(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(L(t),console.log("This is the freeschema query error",t.status),[])}catch(t){console.log("This is the freeschema query error others",t),R(t,i)}}))}var qr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Jr extends or{constructor(t,e){super(),this.mainCompositionIds=[],this.query=new Hr,this.query=t,this.format=t.outputFormat}bind(){return qr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){this.isDataLoaded=!0,this.query.outputFormat=yi;let t=yield $r(this.query,"");this.conceptIds=t.conceptIds,this.internalConnections=t.internalConnections,this.linkers=t.linkers,this.reverse=t.reverse,this.mainCompositionIds=t.mainCompositionIds}return yield this.build()}))}build(){return qr(this,void 0,void 0,(function*(){return this.format==di?this.data=yield function(t,e,n,o){return gi(this,void 0,void 0,(function*(){let e=yield co(t),i=[];i=yield function(t,e){return vi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let h=0;h<t.length;h++){let u=!1,f=yield dn(t[h].ofTheConceptId),y=yield dn(t[h].toTheConceptId);if(n.includes(t[h].id)&&(u=!0),1==u){if(0!=f.id&&0!=y.id){let n,a=yield dn(t[h].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[h].toTheConceptId in e?n=e[t[h].toTheConceptId]:(n={},n[s]={},e[t[h].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(a.characterValue+"_reverse").includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=yield dn(t[h].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[h].ofTheConceptId in e?n=e[t[h].ofTheConceptId]:(n={},n[i]={},e[t[h].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n)}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o),console.log("this is the format data builders BEFORE",i),i=yield function(t,e){return vi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let h=0;h<t.length;h++){let u=!1,f=yield dn(t[h].ofTheConceptId),y=yield dn(t[h].toTheConceptId);if(n.includes(t[h].id)&&(u=!0),1==u){if(0!=f.id&&0!=y.id){let n,a=yield dn(t[h].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[h].toTheConceptId in e?(n=e[t[h].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},e[t[h].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o={id:f.id,data:{[t]:e}},i=a.characterValue+"_reverse";i.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][i]=o)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=yield dn(t[h].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[h].ofTheConceptId in e?(n=e[t[h].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},e[t[h].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",e=y.characterValue,r={id:y.id,data:{[t]:e}};o.characterValue.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][o.characterValue]=r)}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o),console.log("this is the format data builders",i);let r=yield function(t,e,n,o){return vi(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c,a,s;(new Date).getTime();let l=[],d=[];for(let e=0;e<t.length;e++)d.push(t[e].toTheConceptId),d.push(t[e].ofTheConceptId),d.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1,l=yield dn(t[n].ofTheConceptId),d=yield dn(t[n].toTheConceptId);if(i.includes(t[n].id)&&(o=!0),1==o){if(0!=l.id&&0!=d.id&&d.id in e){let o,i=yield dn(t[n].typeId),a=null!==(c=null===(r=d.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",s=!1;t[n].toTheConceptId in e&&(s=!0),t[n].toTheConceptId in e?o=e[t[n].toTheConceptId]:(o={},o[a]={},e[t[n].toTheConceptId]=o);try{if(e[t[n].ofTheConceptId]){let r={id:l.id,data:e[t[n].ofTheConceptId]},c=i.characterValue+"_reverse";Array.isArray(o[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(t){console.log("this is error",t)}}}else if(0!=l.id&&0!=d.id&&l.id in e){let o,i=yield dn(t[n].typeId),r=null!==(s=null===(a=l.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self",c=!1;t[n].toTheConceptId in e&&(c=!0),t[n].ofTheConceptId in e?o=e[t[n].ofTheConceptId]:(o={},o[r]={},e[t[n].ofTheConceptId]=o);try{if(e[t[n].toTheConceptId]){let c={id:d.id,data:e[t[n].toTheConceptId]};Array.isArray(o[r][i.characterValue])?o[r][i.characterValue].push(c):i.characterValue.includes("_s_")?(o[r][i.characterValue]=[],o[r][i.characterValue].push(c)):o[r][i.characterValue]=c}}catch(t){console.log("this is error",t)}}}console.log("these are the main datas",e);for(let t=0;t<o.length;t++){let n={};n.id=o[t],n.data=e[o[t]],l.push(n)}return l}))}(e,i,[],n,o);return r}))}(this.linkers,this.conceptIds,this.mainCompositionIds,this.reverse):this.data=yield function(t,e,n,o){return gi(this,void 0,void 0,(function*(){let e=yield co(t),i=[];i=yield function(t,e,n){return vi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let h=0;h<t.length;h++){let u=!1;n.includes(t[h].id)&&(u=!0);let f=yield dn(t[h].ofTheConceptId),y=yield dn(t[h].toTheConceptId);if(1==u){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[h].toTheConceptId in e?n=e[t[h].toTheConceptId]:(n={},n[a]={},e[t[h].toTheConceptId]=n);let s=yield dn(t[h].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;s.characterValue,s.characterValue.includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[h].ofTheConceptId in e?n=e[t[h].ofTheConceptId]:(n={},n[o]={},e[t[h].ofTheConceptId]=n);let i=yield dn(t[h].typeId);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n)}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o),console.log("this is the format normal builders BEFORE",i),i=yield function(t,e,n){return vi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let h=0;h<t.length;h++){let u=!1;n.includes(t[h].id)&&(u=!0);let f=yield dn(t[h].ofTheConceptId),y=yield dn(t[h].toTheConceptId);if(1==u){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[h].toTheConceptId in e?(n=e[t[h].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},e[t[h].toTheConceptId]=n);let s=yield dn(t[h].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o={[t]:e},i=s.characterValue+"_reverse";s.characterValue.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][i]=o)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[h].ofTheConceptId in e?(n=e[t[h].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},e[t[h].ofTheConceptId]=n);let i=yield dn(t[h].typeId);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",e=y.characterValue,r={[t]:e};i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][i.characterValue]=r)}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o),console.log("this is the format normal builders",i);let r=yield function(t,e,n,o){return vi(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c,a,s;let l=[],d=[];for(let e=0;e<t.length;e++)d.push(t[e].toTheConceptId),d.push(t[e].ofTheConceptId),d.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1;i.includes(t[n].id)&&(o=!0);let l=yield dn(t[n].ofTheConceptId),d=yield dn(t[n].toTheConceptId);if(1==o){if(0!=l.id&&0!=d.id&&d.id in e){let o,i=null!==(c=null===(r=d.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";t[n].toTheConceptId in e?o=e[t[n].toTheConceptId]:(o={},o[i]={},e[t[n].toTheConceptId]=o);let a=yield dn(t[n].typeId);try{let r=a.characterValue+"_reverse",c=e[t[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):a.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(t){console.log("this is error",t)}}}else if(0!=l.id&&0!=d.id&&l.id in e){let o,i=null!==(s=null===(a=l.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[n].ofTheConceptId in e?o=e[t[n].ofTheConceptId]:(o={},o[i]={},e[t[n].ofTheConceptId]=o);let r=yield dn(t[n].typeId);try{let c=e[t[n].toTheConceptId];c&&(Array.isArray(o[i][r.characterValue])?o[i][r.characterValue].push(c):r.characterValue.includes("_s_")?(o[i][r.characterValue]=[],o[i][r.characterValue].push(c)):o[i][r.characterValue]=c)}catch(t){console.log("this is error",t)}}}for(let t=0;t<n.length;t++){let o=e[n[t]];o.id=n[t],l.push(o)}return l}))}(e,i,n,[],o);return r}))}(this.linkers,this.conceptIds,this.mainCompositionIds,this.reverse),this.data}))}}function zr(t,e){return new Jr(t,e)}var Qr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Zr(t=""){b.BearerAccessToken=t}function Kr(){return Qr(this,arguments,void 0,(function*(t="",e="",n="",i="",r=!0,c="",a=!1){try{o.BASE_URL=t,o.AI_URL=e,o.NODE_URL=i,o.BASE_APPLICATION=c,b.BearerAccessToken=n;let s=Math.floor(1e8*Math.random());if(o.BASE_RANDOMIZER=s,a)return u.isDataLoaded=!0,u.isCharacterLoaded=!0,u.isTypeLoaded=!0,u.isLocalDataLoaded=!0,u.isLocalTypeLoaded=!0,u.isLocalCharacterLoaded=!0,u.isConnectionLoaded=!0,u.isConnectionTypeLoaded=!0,u.isLocalConnectionLoaded=!0,!0;console.log("This ist he base url",o.BASE_URL,s),yield Gr(r);const l=(new Date).getTime();return yield x().then((()=>{let t=(new Date).getTime()-l;console.log("The time taken to prepare concept data is ",t)})).catch((t=>{throw t})),yield Fe().then((()=>{let t=(new Date).getTime()-l;console.log("The time taken to prepare local concept ",t)})).catch((t=>{throw t})),yield function(){return Sr(this,void 0,void 0,(function*(){try{let t=yield lt("localconnection");if(Array.isArray(t))for(let e=0;e<t.length;e++)xt.AddConnectionToMemory(t[e])}catch(t){throw{message:"Cannot create Local Connection Binary Tree Concept",ok:!1,status:400,data:t}}}))}().then((()=>{u.isLocalConnectionLoaded=!0})).catch((t=>{throw t})),De().then((()=>{})).catch((t=>{throw console.log("This is the error in populating binary tree"),t})),yield function(){return Sr(this,void 0,void 0,(function*(){try{let t=yield d("connection");if(Array.isArray(t))for(let e=0;e<t.length;e++)Z.AddConnectionToMemory(t[e])}catch(t){throw{message:"Cannot create Connection Binary Tree Concept",ok:!1,status:400,data:t}}}))}().then((()=>{u.isConnectionLoaded=!0,u.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-l;console.log("The time taken to prepare connections ",t)})).catch((t=>{throw t})),!0}catch(t){console.log("cannot initialize the system",t)}}))}var Xr=exports;for(var Yr in e)Xr[Yr]=e[Yr];e.__esModule&&Object.defineProperty(Xr,"__esModule",{value:!0})})();
1
+ (()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ADMIN:()=>Xi,ALLID:()=>pi,AddGhostConcept:()=>li,Anomaly:()=>Ur,BaseUrl:()=>o,BinaryTree:()=>g,Composition:()=>Fo,CompositionBinaryTree:()=>_o,CompositionNode:()=>bo,Concept:()=>m,ConceptsData:()=>k,Connection:()=>O,ConnectionData:()=>Z,CreateComposition:()=>Pe,CreateConnectionBetweenTwoConcepts:()=>un,CreateConnectionBetweenTwoConceptsGeneral:()=>yn,CreateConnectionBetweenTwoConceptsLocal:()=>$i,CreateDefaultConcept:()=>C,CreateDefaultLConcept:()=>Nt,CreateSession:()=>Xo,CreateSessionVisit:()=>ti,CreateTheCompositionLocal:()=>Ke,CreateTheCompositionWithCache:()=>Eo,CreateTheConnection:()=>Ce,CreateTheConnectionGeneral:()=>en,CreateTheConnectionLocal:()=>Me,DATAID:()=>hi,DATAIDDATE:()=>fi,DelayFunctionExecution:()=>Ki,DeleteConceptById:()=>qn,DeleteConceptLocal:()=>Ji,DeleteConnectionById:()=>sn,DeleteConnectionByType:()=>Hr,DependencyObserver:()=>ir,FilterSearch:()=>xr,FormatFromConnections:()=>Ai,FormatFromConnectionsAltered:()=>wi,FreeschemaQuery:()=>Wr,FreeschemaQueryApi:()=>qr,GetAllConnectionsOfComposition:()=>_t,GetAllConnectionsOfCompositionBulk:()=>it,GetComposition:()=>Ft,GetCompositionBulk:()=>eo,GetCompositionBulkWithDataId:()=>no,GetCompositionFromConnectionsWithDataId:()=>oo,GetCompositionFromConnectionsWithDataIdInObject:()=>ao,GetCompositionFromConnectionsWithDataIdIndex:()=>io,GetCompositionFromConnectionsWithIndex:()=>ro,GetCompositionList:()=>ne,GetCompositionListAll:()=>oe,GetCompositionListAllWithId:()=>ie,GetCompositionListListener:()=>ur,GetCompositionListLocal:()=>fe,GetCompositionListLocalWithId:()=>ye,GetCompositionListWithId:()=>re,GetCompositionListWithIdUpdated:()=>ce,GetCompositionListener:()=>lr,GetCompositionLocal:()=>le,GetCompositionLocalWithId:()=>de,GetCompositionWithAllIds:()=>Dt,GetCompositionWithCache:()=>qo,GetCompositionWithDataIdBulk:()=>Qo,GetCompositionWithDataIdWithCache:()=>zo,GetCompositionWithId:()=>Ht,GetCompositionWithIdAndDateFromMemory:()=>Mt,GetConceptBulk:()=>X,GetConceptByCharacter:()=>Kt,GetConceptByCharacterAndCategoryLocal:()=>te,GetConceptByCharacterAndType:()=>Ie,GetConnectionBetweenTwoConceptsLinker:()=>Zi,GetConnectionBulk:()=>Yn,GetConnectionById:()=>cn,GetConnectionDataPrefetch:()=>co,GetConnectionOfTheConcept:()=>Ye,GetLink:()=>Nn,GetLinkListListener:()=>Tr,GetLinkListener:()=>pr,GetLinkRaw:()=>Tn,GetLinkerConnectionFromConcepts:()=>Mn,GetLinkerConnectionToConcepts:()=>Hn,GetRelation:()=>ni,GetRelationLocal:()=>Ui,GetRelationRaw:()=>oi,GetTheConcept:()=>dn,GetTheConceptLocal:()=>bi,GetUserGhostId:()=>si,JUSTDATA:()=>ui,LConcept:()=>Ir,LConnection:()=>wr,LISTNORMAL:()=>vi,LocalConceptsData:()=>Lt,LocalSyncData:()=>kt,LoginToBackend:()=>go,MakeTheInstanceConcept:()=>_e,MakeTheInstanceConceptLocal:()=>Qe,MakeTheTimestamp:()=>Zn,MakeTheTypeConcept:()=>_n,MakeTheTypeConceptApi:()=>Dn,MakeTheTypeConceptLocal:()=>Je,NORMAL:()=>di,PRIVATE:()=>Yi,PUBLIC:()=>tr,PatcherStructure:()=>kr,RAW:()=>yi,RecursiveSearchApi:()=>uo,RecursiveSearchApiNewRawFullLinker:()=>po,RecursiveSearchApiRaw:()=>fo,RecursiveSearchApiRawFullLinker:()=>yo,RecursiveSearchListener:()=>mr,SchemaQueryListener:()=>Qr,SearchAllConcepts:()=>Mo,SearchLinkInternal:()=>Mi,SearchLinkInternalAll:()=>Hi,SearchLinkMultipleAll:()=>Ii,SearchLinkMultipleAllObservable:()=>rr,SearchLinkMultipleApi:()=>U,SearchQuery:()=>Kn,SearchStructure:()=>Sr,SearchWithLinker:()=>Wo,SearchWithTypeAndLinker:()=>Ci,SearchWithTypeAndLinkerApi:()=>nr,SessionData:()=>Ar,Signin:()=>Io,Signup:()=>Co,SignupEntity:()=>No,SplitStrings:()=>F,StatefulWidget:()=>jr,SyncData:()=>me,TrashTheConcept:()=>zn,UpdateComposition:()=>Vo,UpdateCompositionLocal:()=>_i,UserBinaryTree:()=>ci,Validator:()=>Dr,ViewInternalData:()=>Oi,ViewInternalDataApi:()=>Di,convertFromConceptToLConcept:()=>xi,convertFromLConceptToConcept:()=>Si,createFormFieldData:()=>Er,getFromDatabaseWithType:()=>gn,getObjectsFromIndexDb:()=>mn,init:()=>Xr,recursiveFetch:()=>qt,recursiveFetchNew:()=>Po,searchLinkMultipleListener:()=>cr,storeToDatabase:()=>vn,updateAccessToken:()=>Kr});class n{constructor(t){this.id=1,this.isOnlineSync=!1,this.isOnlineSync=t}}class o{static GetConceptUrl(){return this.BASE_URL+"/api/getConcept"}static GetConnectionUrl(){return this.BASE_URL+"/api/get-connection-by-id"}static GetConceptBulkUrl(){return this.BASE_URL+"/api/get_concept_bulk"}static GetConnectionBulkUrl(){return this.BASE_URL+"/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 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 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 SearchAllTypeWithLinker(t=!0){return t?this.BASE_URL+"/api/search-all-with-linker-ccs":this.BASE_URL+"/api-search-compositions-internal-clean-ccs"}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 SearchInternalWithCcsUrl(){return this.BASE_URL+"/api-search-compositions-internal-clean-ccs"}static CreateGhostConceptApiUrl(){return o.NODE_URL+"/api/v1/local-concepts"}static CreateGhostConnectionApiUrl(){return o.NODE_URL+"/api/v1/local-connections"}static GetRealConceptById(){return o.NODE_URL+"/api/v1/local-concepts-translate"}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 DeleteTheConnectionUrl(){return this.BASE_URL+"/api/delete_connection"}static FreeschemaQueryUrl(){return this.BASE_URL+"/api/freeschema-query"}}o.BASE_URL="https://localhost:7053/",o.AI_URL="https://ai.freeschema.com",o.MQTT_URL="192.168.1.249",o.NODE_URL="http://localhost:5001",o.BASE_APPLICATION="",o.BASE_RANDOMIZER=999;var i=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},r=9;class c{}function a(t){return new Promise((function(e,n){c.db&&e(c.db);let i=o.BASE_URL+"_FreeSchema"+o.BASE_APPLICATION;const s=indexedDB.open(i,r);s.onerror=e=>{console.error("Why didn't you allow my web app to use IndexedDB?!",e),indexedDB.deleteDatabase(i),a(t),n(e)},s.onsuccess=function(t){let n=t.target;c.db=n.result,e(c.db)},s.onupgradeneeded=t=>{let n=t.target.result,o="concept",i="connection",c="settings";console.log("this is the version update for index",r),n.objectStoreNames.contains(o)&&n.deleteObjectStore(o),n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.objectStoreNames.contains(c)&&n.deleteObjectStore(c),n.objectStoreNames.contains(o)||(n.createObjectStore(o,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(i)||(n.createObjectStore(i,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(c)||(n.createObjectStore(c,{keyPath:"id"}).transaction.oncomplete=t=>{}),e(n)}}))}function s(t,e){return new Promise((function(n,o){console.log("this is storing to the database",e),a(t).then((i=>{if(0!=e.id){const r=i.transaction(t,"readwrite").objectStore(t).add(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot store to the database"+t,data:n,body:e})}}})).catch((t=>{o({status:400,ok:!1,message:"Cannot store to the database because you cannot open the database",data:t})}))}))}function l(t,e){return new Promise((function(n,o){console.log("this is wriring to the database",e),a(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).put(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot Update to the database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot update to database because you cannot open the database",data:t})}))}))}function d(t){return i(this,void 0,void 0,(function*(){return new Promise((function(e,n){a(t).then((n=>{let o=[],i=n.transaction(t,"readwrite").objectStore(t).getAll();i.onsuccess=()=>{const t=i.result;for(let e=0;e<t.length;e++)o.push(t[e]);e(o)}})).catch((t=>{n({status:400,ok:!1,message:"Cannot get objects from the database because you cannot open the database",data:t})}))}))}))}function h(t,e){return new Promise((function(n,o){a(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).delete(Number(e));r.onsuccess=function(t){n(e)},r.onerror=e=>{o({status:400,ok:!1,message:"Cannot remove from the database"+t,data:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot remove from the database because you cannot open the database",data:t,body:e})}))}))}class u{}u.isTypeLoaded=!1,u.isCharacterLoaded=!1,u.isDataLoaded=!1,u.isLocalDataLoaded=!1,u.isLocalCharacterLoaded=!1,u.isLocalTypeLoaded=!1,u.isConnectionLoaded=!1,u.isConnectionTypeLoaded=!1,u.isLocalConnectionLoaded=!1;class f{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;let n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}checkIfIdsInNode(t,e,n,o){if(t){if(e.includes(t.key)){n.push(t.value);let o=e.indexOf(t.key);e.splice(o,1)}t.leftNode&&this.checkIfIdsInNode(t.leftNode,e,n,o),t.rightNode&&this.checkIfIdsInNode(t.rightNode,e,n,o)}}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key){return this.rightRotate(e)}if(t.key>e.leftNode.key){return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key){return this.leftRotate(e)}if(t.key<e.rightNode.key){return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return console.log("adding the type node to the tree",t),t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return console.log("adding the type node to the tree down",t),e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),console.log("adding the type node to the tree last",e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key){return this.rightRotate(e)}if(t.key>e.leftNode.key){return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key){return this.leftRotate(e)}if(t.key<e.rightNode.key){return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getCharacterFromNodeUpdated(t,e){var n;return e?t==e.key||51==(null===(n=e.value)||void 0===n?void 0:n.typeId)?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNode(t.rightNode,e.key),t}}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){let e=t.variants[0];if(e)return t.value=e.value,t.key=e.key,t.currentNode=e.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,e.key,n),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var y=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class p{static waitForDataToLoad(){return y(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isCharacterLoaded)return t("done");setTimeout(p.checkFlag,1e3,t)}static addNodeToTree(t){return y(this,void 0,void 0,(function*(){return null==this.characterRoot?(this.characterRoot=t,this.characterRoot):(this.characterRoot=this.characterRoot.addCharacterNode(t,this.characterRoot,this.characterRoot.height),this.characterRoot)}))}static removeNodeByCharacter(t,e){return y(this,void 0,void 0,(function*(){this.characterRoot&&this.characterRoot.removeNodeWithVariants(this.characterRoot,t,e)}))}static countNumberOfNodes(){return this.characterRoot?this.characterRoot.countNodeBelow(this.characterRoot):0}static addConceptToTree(t){if(""!=t.characterValue){var e=new f(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getNodeFromTreeUpdated(t){return this.characterRoot?this.characterRoot.getCharacterFromNode(t,this.characterRoot):this.characterRoot}static getCharacterAndTypeFromTree(t,e){return y(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndType(t,e,this.characterRoot):this.characterRoot}))}static getCharacterAndCategoryFromTree(t,e){return y(this,void 0,void 0,(function*(){return this.characterRoot?this.characterRoot.getFromNodeWithCharacterAndCategory(t,e,this.characterRoot):this.characterRoot}))}static removeConceptCharacter(t){this.characterRoot&&(this.characterRoot=this.characterRoot.removeNode(this.characterRoot,t))}}p.characterRoot=null;var v=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class g{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return v(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isDataLoaded)return t("done");setTimeout(g.checkFlag,1e3,t)}static addConceptToTree(t){let e=new f(t.id,t,null,null),n=new f(t.characterValue,t,null,null);p.addNodeToTree(n),this.addNodeToTree(e)}static getNodeFromTree(t){return v(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return v(this,void 0,void 0,(function*(){if(this.root){let e=new Event(`${t}`);console.log("this is the fired event after delete",e),dispatchEvent(e),this.root=this.root.removeNode(this.root,t)}}))}static getConceptListFromIds(t,e,n){return v(this,void 0,void 0,(function*(){this.root&&this.root.checkIfIdsInNode(this.root,t,e,n)}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}g.root=null;class m{constructor(t,e,n,i,r,c,a,s=!1,l,d,h){this.count=0,this.typeCharacter="",this.isComposition=!1,this.isTemp=!1,this.isSynced=!1,this.applicationId=o.BASE_RANDOMIZER,this.x=0,this.y=0,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=i,this.referentId=r,this.characterValue=`${c}`,this.accessId=a,this.typeCharacter=h,this.type=null,this.isNew=s,this.entryTimeStamp=l,this.updatedTimeStamp=d}getType(){console.log(this.typeId)}}function C(){let t=new Date,e=new Date;return new m(0,0,0,0,0,"0",0,!1,t,e,"0")}class N{constructor(t,e){this.value=[],this.height=1,this.key=t,this.value.push(e),this.leftNode=null,this.rightNode=null,this.currentNode=null}addType(t,e,n){var o,i,r,c;if(null==t)return new N(e,n);if(e<t.key)t.leftNode=this.addType(t.leftNode,e,n);else{if(!(e>t.key))return t.value.push(n),t;t.rightNode=this.addType(t.rightNode,e,n)}t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1;const a=this.getBalanceFactor(t);return a>1&&e<(null===(o=t.leftNode)||void 0===o?void 0:o.key)?this.rightRotate(t):a<-1&&e>(null===(i=t.rightNode)||void 0===i?void 0:i.key)?this.leftRotate(t):a>1&&e>(null===(r=t.leftNode)||void 0===r?void 0:r.key)?(t.leftNode=this.leftRotate(t.leftNode),this.rightRotate(t)):a<-1&&e<(null===(c=t.rightNode)||void 0===c?void 0:c.key)?(t.rightNode=this.rightRotate(t.rightNode),this.leftRotate(t)):t}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.value.length>0)for(let e=0;e<t.value.length;e++)if(n==t.value[e])return t.value.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.currentNode=e.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,e.key,n),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var T=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class I{static addType(t){return T(this,void 0,void 0,(function*(){if(null==this.root)return this.root=t,this.root;{let e=new CustomEvent(`${t.key}`,{detail:t.value[0]});dispatchEvent(e),this.root=this.root.addType(this.root,t.key,t.value[0])}return this.root}))}static addConceptToTree(t){if(0!=t.typeId){let e=new N(t.typeId,t.id);this.addType(e)}}static removeTypeConcept(t,e){this.root&&(this.root=this.root.removeNodeWithVariants(this.root,t,e))}static getNodeFromTreeNew(t){return this.root?this.root.getFromNode(t,this.root):this.root}static getTypeVariantsFromTreeNew(t){return T(this,void 0,void 0,(function*(){let e=this.getNodeFromTreeNew(t),n=[],o=[];if(e){n=e.value;for(let t=0;t<n.length;t++){let e=!1;for(let i=0;i<o.length;i++)o[i].id==n[t]&&(e=!0);e||o.push(yield dn(n[t]))}}return o}))}static waitForDataToLoad(){return T(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isTypeLoaded)return t("done");setTimeout(I.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserIdNew(t,e){return T(this,void 0,void 0,(function*(){let n=[],o=yield this.getTypeVariantsFromTreeNew(t);console.log("these are all the concepts",o);for(let t=0;t<o.length;t++)o[t].userId==e&&n.push(o[t]);return n}))}static getTypeVariantsWithCharacterValueNew(t,e){return T(this,void 0,void 0,(function*(){let n=yield this.getTypeVariantsFromTreeNew(e);console.log("this is all the concepts for character",n);let o=C();for(let e=0;e<n.length;e++)n[e].characterValue==t&&(o=n[e]);return o}))}static countNumberOfNodes(){return this.typeRoot?this.typeRoot.countNodeBelow(this.typeRoot):0}}I.typeRoot=null,I.root=null;var w=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class k{constructor(){this.name="conceptsArray"}static CheckContains(t){for(var e=!1,n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].id==t.id&&(e=!0);return e}static AddNpc(t){this.NPC.includes(t)||(this.NPC.length>10&&(this.NPC=[]),this.NPC.push(t))}static GetNpc(t){return!!this.NPC.includes(t)}static AddConceptToStorage(t){t.id>0&&l("concept",t)}static GetConceptBulkData(t,e,n){return w(this,void 0,void 0,(function*(){yield g.getConceptListFromIds(t,e,n)}))}static AddConcept(t){t.id>0&&(g.addConceptToTree(t),I.addConceptToTree(t))}static AddConceptToMemory(t){t.id>0&&(g.addConceptToTree(t),I.addConceptToTree(t))}static AddConceptTemporary(t){var e=this.CheckContains(t);this.conceptDictionary[t.id]=t,e&&this.RemoveConcept(t),this.conceptsArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsArray.length;e++)this.conceptsArray[e].id==t.id&&this.conceptsArray.splice(e,1);h("concept",t.id)}static GetConcept(t){return w(this,void 0,void 0,(function*(){var e=C(),n=yield g.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return w(this,void 0,void 0,(function*(){var e=C(),n=p.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterUpdated(t){return w(this,void 0,void 0,(function*(){var e=C(),n=p.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return w(this,void 0,void 0,(function*(){return C(),yield I.getTypeVariantsWithCharacterValueNew(t,e)}))}static GetConceptByCharacterAndCategoryLocal(t,e){return w(this,void 0,void 0,(function*(){var n=C(),o=yield p.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.conceptsArray.length;n++)this.conceptsArray[n].typeId==t&&e.push(this.conceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return w(this,void 0,void 0,(function*(){let n=[];return n=yield I.getTypeVariantsFromTreeWithUserIdNew(t,e),n}))}static GetBinaryCharacterTree(){return p.characterRoot}getName(){return this.name}}k.conceptsArray=[],k.NPC=[],k.conceptDictionary=[];var A=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function x(){return A(this,void 0,void 0,(function*(){try{let t=yield d("concept");if(Array.isArray(t))for(let e=0;e<t.length;e++){let n=t[e];k.AddConceptToMemory(n)}u.isDataLoaded=!0,u.isCharacterLoaded=!0,u.isTypeLoaded=!0}catch(t){throw yield Ki(2e3,x()),{message:"Cannot create Binary Tree Concept",ok:!1,status:400,data:t}}}))}class S{constructor(t,e,n,i){this.url=o.BASE_URL,this.message=t,this.ok=e,this.status=n,this.data=i}getMessage(){return this.message}setMessage(t){return this.message=t,this}getStatus(){return this.status}setStatus(t){return this.status=t,this}getData(){return this.data}setData(t){return this.data=t,this}getOk(){return this.ok}setOk(t){return this.ok=t,this}getUrl(){return this.url}setUrl(t){return this.url=t,this}}function L(t){if(401==t.status||406==t.status){let e=new S(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}if(500==t.status){let e=new S(t.statusText,!1,t.status,"");throw e.setUrl(t.url),e}}function R(t,e=""){if(t.status){let n=new S(t.message,!1,t.status,t.stack);throw n.setUrl(e),n}{let n=new S(t.message,!1,500,t.stack);throw n.setUrl(e),n}}class b{}function G(t="application/json",e="application/json"){return{"Content-Type":t,Authorization:"Bearer "+b.BearerAccessToken,Accept:e}}function _(t="application/json",e="",n="application/json"){return""==e&&(e=b.BearerAccessToken),{"Content-Type":t,Authorization:"Bearer "+e,Accept:n}}function B(){let t=b.BearerAccessToken;const e=new Headers;return e.append("Authorization","Bearer "+t),e}b.BearerAccessToken="";var P=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function U(t){return P(this,arguments,void 0,(function*(t,e=""){var n=_("application/json",e);const i=o.SearchLinkMultipleAllApiUrl(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(L(t),console.log("This is the searching multiple error",t.status),[])}catch(t){console.log("This is the searching multiple error",t),R(t,i)}}))}function F(t){const e=t.lastIndexOf("_");let n=[];return n=e>0?[t.substring(0,e),t.substring(e+1,t.length)]:[t],n}var D=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function E(t,e){return D(this,void 0,void 0,(function*(){try{var n=new URLSearchParams;n.append("type",t),n.append("user_id",e.toString());var i=G("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllConceptsByTypeUrl(),{method:"POST",headers:i,body:n});if(c.ok){const t=yield c.json();for(var r=0;r<t.length;r++)k.AddConcept(t[r])}else console.log("GetAllConceptsByType error",c.status),L(c)}catch(t){t instanceof Error?console.log("GetAllConceptsByType error message: ",t.message):console.log("GetAllConceptsByType unexpected error: ",t),R(t,o.GetAllConceptsByTypeUrl())}}))}class O{constructor(t=0,e,n,i,r,c,a){this.count=0,this.isTemp=!1,this.toUpdate=!1,this.applicationId=o.BASE_RANDOMIZER,this.type=C(),this.ofConcept=C(),this.toConcept=C(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.userId=i,this.typeId=r,this.ghostId=t,this.orderId=c,this.accessId=a,this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date,this.typeCharacter=""}}class V{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;let n=!1;t.value.id==e.value.id&&(n=!0);for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key){return this.rightRotate(e)}if(t.key>e.leftNode.key){return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key){return this.leftRotate(e)}if(t.key<e.rightNode.key){return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?(e.value.count?e.value.count++:e.value.count=1,e):t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}checkIfIdsInNode(t,e,n,o){if(t){if(e.includes(t.key)){n.push(t.value);let o=e.indexOf(t.key);e.splice(o,1)}t.leftNode&&this.checkIfIdsInNode(t.leftNode,e,n,o),t.rightNode&&this.checkIfIdsInNode(t.rightNode,e,n,o)}}traverse(t){let e=0;return t&&(e+=1,(null==t?void 0:t.leftNode)&&(e+=this.traverse(t.leftNode)),t.rightNode&&(e+=this.traverse(t.rightNode))),e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;let n=new Event(`${t.value.ofTheConceptId}`);if(dispatchEvent(n),null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNode(t.rightNode,e.key),t}}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){let e=t.variants[0];if(e)return t.value=e.value,t.key=e.key,t.currentNode=e.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,e.key,n),t}}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var j=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class M{static addNodeToTree(t){if(null==this.connectionroot)return this.connectionroot=t,this.connectionroot;this.connectionroot=this.connectionroot.addNode(t,this.connectionroot,this.connectionroot.height)}static addConnectionToTree(t){let e=new V(t.id,t,null,null);this.addNodeToTree(e)}static traverse(){var t;return null===(t=this.connectionroot)||void 0===t?void 0:t.traverse(this.connectionroot)}static waitForDataToLoad(){return j(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isConnectionLoaded)return t("done");setTimeout(M.checkFlag,1e3,t)}static removeNodeFromTree(t){return j(this,void 0,void 0,(function*(){this.connectionroot&&(this.connectionroot=this.connectionroot.removeNode(this.connectionroot,t))}))}static getNodeFromTree(t){return j(this,void 0,void 0,(function*(){return this.connectionroot?this.connectionroot.getFromNode(t,this.connectionroot):this.connectionroot}))}static getConnectionListFromIds(t,e,n){return j(this,void 0,void 0,(function*(){this.connectionroot&&this.connectionroot.checkIfIdsInNode(this.connectionroot,t,e,n)}))}}M.connectionroot=null;class H{constructor(t,e,n,o){this.key="",this.value=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}{let e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.variants=e.variants,t.currentNode=e.currentNode,t.rightNode=this.removeNode(t.rightNode,e.key),t}}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}class W extends H{constructor(t,e,n,o){super(t,e,n,o),this.key="",this.value=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}addNode(t,e,n){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}}var $=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class q{static CreateCompositionKey(t,e){return t}static GetConnectionByOfTheConceptAndTypeId(t,e){let n=this.CreateCompositionKey(t,e);if(this.node){let t=this.node.getFromNode(n,this.node);if(t)return t.value}return null}static addConnection(t){if(t.id>0){let e=this.CreateCompositionKey(t.ofTheConceptId,t.typeId);if(this.node){let n=this.node.getFromNode(e,this.node);if(n){let e=null==n?void 0:n.value;0==e.length&&(n.value=[]),e.includes(t.id)||e.push(t.id)}else{let n=[];n.push(t.id);let o=new W(e,n,null,null);this.addNodeToTree(o)}}else{let n=[];n.push(t.id);let o=new W(e,n,null,null);this.addNodeToTree(o)}let n=new Event(`${e}`);dispatchEvent(n)}else console.log("cannot insert key id with n 0 to the connection tree",t)}static addNodeToTree(t){return $(this,void 0,void 0,(function*(){return null==this.node?(this.node=t,this.node):(this.node=this.node.addNode(t,this.node,this.node.height),this.node)}))}static removeNodeFromTree(t){return $(this,void 0,void 0,(function*(){this.node&&(this.node=this.node.removeNode(this.node,t))}))}}q.node=null;class J extends H{constructor(t,e,n,o){super(t,e,n,o),this.key="",this.value=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}addNode(t,e,n){if(null==e)return t;let o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}}class z{static CreateCompositionKey(t){return t}static addNodeToTree(t){return e=this,n=void 0,i=function*(){return null==this.connectionTypeRoot?(this.connectionTypeRoot=t,this.connectionTypeRoot):(this.connectionTypeRoot=this.connectionTypeRoot.addNode(t,this.connectionTypeRoot,this.connectionTypeRoot.height),this.connectionTypeRoot)},new((o=void 0)||(o=Promise))((function(t,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}));var e,n,o,i}static addConnectionToTree(t){if(t.id>0){let e=this.CreateCompositionKey(t.typeId);if(this.connectionTypeRoot){let n=this.connectionTypeRoot.getFromNode(e,this.connectionTypeRoot);if(n){let e=null==n?void 0:n.value;0==e.length&&(n.value=[]),e.includes(t.id)||e.push(t.id)}else{let n=[];n.push(t.id);let o=new J(e,n,null,null);this.addNodeToTree(o)}}else{let n=[];n.push(t.id);let o=new J(e,n,null,null);this.addNodeToTree(o)}}else console.log("cannot insert key id with n 0 to the connection tree",t)}static GetConnectionByOfTheConceptAndTypeId(t,e){let n=this.CreateCompositionKey(e);if(this.connectionTypeRoot){let t=this.connectionTypeRoot.getFromNode(n,this.connectionTypeRoot);if(t)return t.value}return null}}z.connectionTypeRoot=null;var Q=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Z{constructor(){this.name="Connection Array"}static CheckContains(t){let e=!1;for(let n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnectionToStorage(t){l("connection",t)}static AddConnection(t){M.addConnectionToTree(t),z.addConnectionToTree(t),q.addConnection(t)}static AddConnectionToMemory(t){t.isTemp||(M.addConnectionToTree(t),z.addConnectionToTree(t),q.addConnection(t))}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){0!=t.id&&(h("connection",t.id),M.removeNodeFromTree(t.id),q.removeNodeFromTree(t.id))}static GetConnectionTypeOfTree(){q.node}static GetConnectionByOfTheConceptAndType(t,e){return q.GetConnectionByOfTheConceptAndTypeId(t,e)||[]}static GetConnectionByOfType(t,e){return z.GetConnectionByOfTheConceptAndTypeId(t,e)||[]}static GetConnectionTree(){return M.connectionroot}static GetConnectionTypeTree(){return z.connectionTypeRoot}static GetConnectionBulkData(t,e,n){return Q(this,void 0,void 0,(function*(){yield M.getConnectionListFromIds(t,e,n)}))}static GetConnection(t){return Q(this,void 0,void 0,(function*(){let e=new O(0,0,0,0,0,0,0),n=yield M.getNodeFromTree(t);if(null==n?void 0:n.value){let t=n.value;t&&(e=t)}return e}))}static GetConnectionsOfCompositionLocal(t){return Q(this,void 0,void 0,(function*(){let e=[],n=[];n=Z.GetConnectionByOfType(t,t);for(let t=0;t<n.length;t++){let o=yield M.getNodeFromTree(n[t]);o&&e.push(o.value)}return e}))}static GetConnectionsOfConcept(t){return Q(this,void 0,void 0,(function*(){let e=[],n=[];e=Z.GetConnectionByOfTheConceptAndType(t,t);for(let t=0;t<e.length;t++){let o=yield M.getNodeFromTree(e[t]);o&&n.push(o.value)}return n}))}getName(){return this.name}}Z.connectionArray=[],Z.connectionDictionary=[];var K=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function X(t){return K(this,void 0,void 0,(function*(){let e=[],n=((new Date).getTime(),Array.from(new Set(t)));try{if(n.length>0){let t=[];for(let e=0;e<n.length;e++)0==(yield k.GetConcept(n[e])).id&&t.push(n[e]);if(0==t.length)return e;{let n=G();const i=yield fetch(o.GetConceptBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){if(e=yield i.json(),console.log("got all the concepts",e),e.length>0)for(let t=0;t<e.length;t++){let n=e[t];k.AddConcept(n)}console.log("added the concepts")}else console.log("Get Concept Bulk error",i.status),L(i)}}}catch(t){t instanceof Error?console.log("Get Concept Bulk error message: ",t.message):console.log("Get Concept Bulk unexpected error: ",t),R(t,o.GetConceptBulkUrl())}return e}))}var Y=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function tt(){return Y(this,arguments,void 0,(function*(t=[]){let e=[];if(t.length>0){for(let n=0;n<t.length;n++)e.includes(t[n].ofTheConceptId)||e.push(t[n].ofTheConceptId),e.includes(t[n].toTheConceptId)||e.push(t[n].toTheConceptId);yield X(e)}}))}var et=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function nt(){return et(this,arguments,void 0,(function*(t=[]){let e=[];for(let n=0;n<t.length;n++){let o=yield Z.GetConnectionsOfConcept(t[n]);e.push(...o)}return e}))}var ot=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function it(){return ot(this,arguments,void 0,(function*(t=[]){var e=[];if(t.length<=0)return e;yield nt(t);var n=yield function(){return ot(this,arguments,void 0,(function*(t=[]){var e=[];try{var n=G();const r=yield fetch(o.GetAllConnectionsOfCompositionBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(r.ok){const t=yield r.json();for(var i=0;i<t.length;i++)Z.AddConnection(t[i]),e.push(t[i])}else console.log("Get all connections of composition bulk error message: ","Cannot get response"),L(r);return e}catch(t){t instanceof Error?console.log("Get all connections of composition bulk error message: ",t.message):console.log("Get all connections of composition bulk unexpected error: ",t),R(t,o.GetAllConnectionsOfCompositionBulkUrl())}}))}(t);return e=n,yield tt(e),e}))}var rt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},ct=9;class at{}function st(t){return new Promise((function(e,n){at.db&&e(at.db);let i=o.BASE_URL+"_FreeSchemaLocal"+o.BASE_APPLICATION;const r=indexedDB.open(i,ct);r.onerror=e=>{console.error("Why didn't you allow my web app to use IndexedDB?!",e),indexedDB.deleteDatabase(i),st(t),n(e)},r.onsuccess=function(t){var n=t.target;at.db=n.result,e(at.db)},r.onupgradeneeded=t=>{var n=t.target.result,i="localconcept",r="localconnection",c="localid";console.log("this is the version upgrade",ct),n.objectStoreNames.contains(i)&&n.deleteObjectStore(i),n.objectStoreNames.contains(r)&&n.deleteObjectStore(r),n.objectStoreNames.contains(c)&&n.deleteObjectStore(c),n.objectStoreNames.contains(i)||(n.createObjectStore(i,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(r)||(n.createObjectStore(r,{keyPath:"id"}).transaction.oncomplete=t=>{}),n.objectStoreNames.contains(c)||(n.createObjectStore(c,{keyPath:"id"}).transaction.oncomplete=t=>{dt(c,{id:0,value:-100}),dt(c,{id:1,value:-200}),dt(c,{id:3,value:o.BASE_RANDOMIZER})}),e(n)}}))}function lt(t){return rt(this,void 0,void 0,(function*(){return new Promise((function(e,n){st(t).then((n=>{var o=[],i=n.transaction(t,"readwrite").objectStore(t).getAll();i.onsuccess=()=>{const t=i.result;for(var n=0;n<t.length;n++)o.push(t[n]);e(o)}})).catch((t=>{n({status:400,ok:!1,message:"Cannot get objects from database because you cannot open the Local database",data:t})}))}))}))}function dt(t,e){return new Promise((function(n,o){st(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).add(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot store to the Local database "+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot store to database because you cannot open the Local database",data:t})}))}))}function ht(t,e){return new Promise((function(n,o){console.log("this is wriring to the database local",e),st(t).then((i=>{const r=i.transaction(t,"readwrite").objectStore(t).put(e);r.onsuccess=t=>{n(e)},r.onerror=n=>{o({status:400,ok:!1,message:"Cannot Update to the Local database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot update to database because you cannot open the Local database",data:t})}))}))}function ut(t,e){return new Promise((function(n,o){st(t).then((i=>{let r=i.transaction(t,"readwrite").objectStore(t).delete(e);r.onsuccess=function(t){n(e)},r.onerror=function(n){o({status:400,ok:!1,message:"Cannot Update to the Local database"+t,data:n,body:e})}})).catch((t=>{o({status:400,ok:!1,message:"Cannot remove object from database because you cannot open the Local database",data:t})}))}))}class ft{constructor(t,e,n,o){this.variants=[],this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o,this.currentNode=null}addCurrentNode(t,e){return null==e?e=t:(t.value.typeId!=e.value.typeId&&(e.currentNode=this.addCurrentNode(t,e.currentNode)),e)}addCurrentNodeType(t,e){if(null==e)return t;var n=!1;for(let o=0;o<e.variants.length;o++)e.variants[o].value.id==t.value.id&&(n=!0);return n||e.variants.push(t),e}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}addCharacterNode(t,e,n){if(""!=t.value.characterValue){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addCharacterNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&""!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addCharacterNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}addTypeNode(t,e,n){if(0!=t.value.typeId){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addTypeNode(t,o,n);else{if(!(e.key<t.key))return e.key==t.key&&0!=e.key&&e.value.id!=t.value.id&&e.addCurrentNodeType(t,e),e;e.rightNode=this.addTypeNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}updateNodeSyncStatus(t,e,n){if(n){if(t==n.key){let t=n.value;return t.isSynced=e,n.value=t,n}return t<n.key?this.updateNodeSyncStatus(t,e,n.leftNode):t>n.key?this.updateNodeSyncStatus(t,e,n.rightNode):n}return n}getCharacterFromNode(t,e){return e?t==e.key?e:t<e.key?this.getCharacterFromNode(t,e.leftNode):t>e.key?this.getCharacterFromNode(t,e.rightNode):e:e}getFromNodeWithCharacterAndType(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.typeId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.typeId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndType(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndType(t,e,n.rightNode)}return null}return n}getFromNodeWithCharacterAndCategory(t,e,n){if(t=`${t}`,n){if(t==n.key){if(t==n.value.characterValue&&e==n.value.categoryId)return n;for(let t=0;t<n.variants.length;t++)if(n.variants[t].value.categoryId==e)return n.variants[t]}else{if(t<n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.leftNode);if(t>n.key)return this.getFromNodeWithCharacterAndCategory(t,e,n.rightNode)}return null}return n}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.variants=n.variants,t.currentNode=n.currentNode,t.rightNode=this.removeNode(t.rightNode,n.key),t}removeNodeWithVariants(t,e,n){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNodeWithVariants(t.leftNode,e,n),t;if(t.key<e)return t.rightNode=this.removeNodeWithVariants(t.rightNode,e,n),t;if(t.variants.length>0)if(t.value.id==n){var o=t.variants[0];if(o)return t.value=o.value,t.key=o.key,t.currentNode=o.currentNode,t.variants.splice(0,1),t}else for(let e=0;e<t.variants.length;e++)if(n==t.variants[e].value.id)return t.variants.splice(e,1),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var i=this.inOrderSuccessor(t.rightNode);return t.value=i.value,t.key=i.key,t.variants=i.variants,t.currentNode=i.currentNode,t.rightNode=this.removeNodeWithVariants(t.rightNode,i.key,n),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var yt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class pt{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new ft(t.id,t,null,null);new ft(t.characterValue,t,null,null),this.addNodeToTree(e)}static waitForDataToLoad(){return yt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalDataLoaded)return t("done");setTimeout(pt.checkFlag,1e3,t)}static getNodeFromTree(t){return yt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static getCharacterAndTypeFromTree(t,e){return this.root?this.root.getFromNodeWithCharacterAndType(t,e,this.root):this.root}static updateSyncStatus(t){return this.root?this.root.updateNodeSyncStatus(t,!0,this.root):this.root}static removeNodeFromTree(t){return yt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}pt.root=null;var vt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class gt{static waitForDataToLoad(){return vt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalCharacterLoaded)return t("done");setTimeout(gt.checkFlag,1e3,t)}static addNodeToTree(t){return vt(this,void 0,void 0,(function*(){return null==this.LocalCharacterRoot?(this.LocalCharacterRoot=t,this.LocalCharacterRoot):(this.LocalCharacterRoot=this.LocalCharacterRoot.addCharacterNode(t,this.LocalCharacterRoot,this.LocalCharacterRoot.height),this.LocalCharacterRoot)}))}static addConceptToTree(t){if(""!=t.characterValue){var e=new ft(t.characterValue,t,null,null);this.addNodeToTree(e)}}static getNodeFromTree(t){return this.LocalCharacterRoot?this.LocalCharacterRoot.getCharacterFromNode(t,this.LocalCharacterRoot):this.LocalCharacterRoot}static getCharacterAndTypeFromTree(t,e){return vt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndType(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static getCharacterAndCategoryFromTree(t,e){return vt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.LocalCharacterRoot?this.LocalCharacterRoot.getFromNodeWithCharacterAndCategory(t,e,this.LocalCharacterRoot):this.LocalCharacterRoot}))}static removeConceptType(t,e){this.LocalCharacterRoot&&(this.LocalCharacterRoot=this.LocalCharacterRoot.removeNodeWithVariants(this.LocalCharacterRoot,t,e))}}gt.LocalCharacterRoot=null;var mt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ct{static addNodeToTree(t){return mt(this,void 0,void 0,(function*(){return null==this.LocalTypeRoot?(this.LocalTypeRoot=t,this.LocalTypeRoot):(this.LocalTypeRoot=this.LocalTypeRoot.addTypeNode(t,this.LocalTypeRoot,this.LocalTypeRoot.height),this.LocalTypeRoot)}))}static addConceptToTree(t){if(0!=t.typeId){var e=new ft(t.typeId,t,null,null);this.addNodeToTree(e)}}static removeConceptType(t,e){this.LocalTypeRoot&&(this.LocalTypeRoot=this.LocalTypeRoot.removeNodeWithVariants(this.LocalTypeRoot,t,e))}static getNodeFromTree(t){return this.LocalTypeRoot?this.LocalTypeRoot.getFromNode(t,this.LocalTypeRoot):this.LocalTypeRoot}static getTypeVariantsFromTree(t){var e=this.getNodeFromTree(t),n=[];if(e){n.push(null==e?void 0:e.value);for(let t=0;t<e.variants.length;t++)n.push(e.variants[t].value);return n}}static waitForDataToLoad(){return mt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalTypeLoaded)return t("done");setTimeout(Ct.checkFlag,1e3,t)}static getTypeVariantsFromTreeWithUserId(t,e){return mt(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad()}catch(t){return n}var o=this.getNodeFromTree(t);if(o){console.log("this is the node to type",o),o.value.userId!=e&&999!=o.value.userId||n.push(null==o?void 0:o.value);for(let t=0;t<o.variants.length;t++)o.variants[t].value.userId!=e&&999!=o.value.userId||n.push(o.variants[t].value)}return n}))}}function Nt(){let t=new Date,e=new Date;return new m(0,0,0,0,0,"0",0,!1,t,e,"0")}Ct.LocalTypeRoot=null;var Tt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class It{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addConceptToTree(t){var e=new ft(t.ghostId,t,null,null);this.addNodeToTree(e)}static waitForDataToLoad(){return Tt(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalDataLoaded)return t("done");setTimeout(It.checkFlag,1e3,t)}static getNodeFromTree(t){return Tt(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return Tt(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}}It.root=null;var wt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class kt{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){try{let e=!1;0!=kt.CheckIfTheConceptIdExists(t.id,this.conceptsSyncArray).id&&(e=!0),e||this.conceptsSyncArray.push(t)}catch(t){throw t}}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static SyncDataOnline(){return wt(this,void 0,void 0,(function*(){try{let t=this.conceptsSyncArray.slice(),e=this.connectionSyncArray.slice();this.connectionSyncArray=[],this.conceptsSyncArray=[];let n=[];for(let e=0;e<t.length;e++)n.push(t[e]),yield Lt.UpdateConceptSyncStatus(t[e].id);yield this.UpdateConceptListToIncludeRelatedConcepts(e,n);let i=yield function(t,e){return n=this,i=void 0,c=function*(){let n={concepts:[],connections:[]};try{const i=new Headers;let r={concepts:t,connections:e};i.set("Content-Type","application/json"),i.set("Authorization","Bearer "+b.BearerAccessToken),i.set("Accept","application/json"),i.set("Randomizer",o.BASE_RANDOMIZER.toString());const c=yield fetch(o.CreateGhostConceptApiUrl(),{method:"POST",headers:i,body:JSON.stringify(r)});if(!c.ok)throw L(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();return n.concepts=a.concepts,n.connections=a.connections,n}catch(t){throw t instanceof Error?console.log("Create the concept api error message: ",t.message):console.log("Create the concept api unexpected error: ",t),t}},new((r=void 0)||(r=Promise))((function(t,e){function o(t){try{s(c.next(t))}catch(t){e(t)}}function a(t){try{s(c.throw(t))}catch(t){e(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(o,a)}s((c=c.apply(n,i||[])).next())}));var n,i,r,c}(n,e),r=i.concepts,c=i.connections;for(let t=0;t<r.length;t++)Lt.AddPermanentConcept(r[t]);for(let t=0;t<c.length;t++)xt.AddPermanentConnection(c[t]);return t}catch(t){throw t}}))}static ConvertGhostIdsInConnections(t){var e,n,o;for(let i=0;i<t.length;i++){let r=t[i].ofTheConceptId,c=t[i].toTheConceptId,a=t[i].typeId,s=null!==(e=kt.ghostIdMap.get(r))&&void 0!==e?e:r,l=null!==(n=kt.ghostIdMap.get(c))&&void 0!==n?n:c,d=null!==(o=kt.ghostIdMap.get(a))&&void 0!==o?o:a;t[i].ofTheConceptId=s,t[i].toTheConceptId=l,t[i].typeId=d}}static UpdateConceptListToIncludeRelatedConcepts(t,e){return wt(this,void 0,void 0,(function*(){for(let n=0;n<t.length;n++){let o=t[n].ofTheConceptId,i=t[n].toTheConceptId,r=t[n].typeId;if(o<0){let i=this.CheckIfTheConceptIdExists(o,e);0==i.id&&(i=yield Lt.GetConceptByGhostId(o),0!=i.id?i.id!=i.ghostId&&(t[n].ofTheConceptId=i.id):(i=yield Lt.GetConcept(o),this.AddConceptIfDoesNotExist(i,e)))}if(i<0){let o=this.CheckIfTheConceptIdExists(i,e);0==o.id&&(o=yield Lt.GetConceptByGhostId(i),0!=o.id?o.id!=o.ghostId&&(t[n].toTheConceptId=o.id):(o=yield Lt.GetConcept(i),this.AddConceptIfDoesNotExist(o,e)))}if(r<0){let o=this.CheckIfTheConceptIdExists(r,e);0==o.id&&(o=yield Lt.GetConceptByGhostId(r),0!=o.id?o.id!=o.ghostId&&(t[n].typeId=o.id):(o=yield Lt.GetConcept(r),this.AddConceptIfDoesNotExist(o,e)))}}}))}static AddConceptIfDoesNotExist(t,e=[]){let n=!1;for(let o=0;o<e.length;o++)t.ghostId==e[o].ghostId&&(n=!0);n||e.push(t)}static CheckIfTheConceptIdExists(t,e=[]){let n=Nt();for(let o=0;o<e.length;o++)t!=e[o].ghostId&&t!=e[o].id||(n=e[o]);return n}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static RemoveConnectionById(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t&&this.connectionSyncArray.splice(e,1)}static syncDataLocalDb(){return wt(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)ht("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)ht("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}kt.conceptsSyncArray=[],kt.connectionSyncArray=[],kt.ghostIdMap=new Map;var At=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class xt{constructor(){this.name="Connection Array"}static CheckContains(t){for(var e=!1,n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t.id&&(e=!0);return e}static AddConnection(t){this.CheckContains(t)&&this.RemoveConnection(t),0!=t.id&&ht("localconnection",t),this.connectionArray.push(t)}static AddConnectionToMemory(t){this.CheckContains(t)&&this.RemoveConnection(t),this.connectionArray.push(t)}static AddToDictionary(t){this.connectionDictionary[t.id]=t}static RemoveConnection(t){for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t.id&&this.connectionArray.splice(e,1);t.id}static RemoveConnectionById(t){for(var e=0;e<this.connectionArray.length;e++)this.connectionArray[e].id==t&&this.connectionArray.splice(e,1);kt.RemoveConnectionById(t)}static AddPermanentConnection(t){t.id>0&&(ut("localconnection",t.ghostId),Z.AddConnection(function(t){let e=new O(0,0,0,0,0,0,0);return e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.typeId=t.typeId,e.orderId=t.orderId,e.id=t.id,e}(t)))}static GetConnection(t){var e;e=null;for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].id==t&&(e=this.connectionArray[n]);return e}static waitForDataToLoad(){return At(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isLocalConnectionLoaded)return t("done");setTimeout(xt.checkFlag,1e3,t)}static GetConnectionsOfCompositionLocal(t){return At(this,void 0,void 0,(function*(){var e=[];try{yield this.waitForDataToLoad();for(var n=0;n<this.connectionArray.length;n++)this.connectionArray[n].typeId==t&&e.push(this.connectionArray[n]);return e}catch(t){return e}}))}static GetConnectionOfCompositionAndTypeLocal(t,e){return At(this,void 0,void 0,(function*(){var n=[];try{yield this.waitForDataToLoad(),console.log("this is the connections",this.connectionArray,t,e);for(var o=0;o<this.connectionArray.length;o++)this.connectionArray[o].typeId==t&&this.connectionArray[o].ofTheConceptId==e&&n.push(this.connectionArray[o]);return n}catch(t){return n}}))}getName(){return this.name}}xt.connectionArray=[],xt.connectionDictionary=[];var St=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Lt{constructor(){this.name="conceptsArray"}static AddConcept(t){0!=t.id&&(ht("localconcept",t),pt.addConceptToTree(t),gt.addConceptToTree(t),Ct.addConceptToTree(t),this.localconceptsArray.push(t))}static AddPermanentConcept(t){0!=t.id&&(pt.removeNodeFromTree(t.ghostId),gt.removeConceptType(t.characterValue,t.ghostId),Ct.removeConceptType(t.typeId,t.ghostId),It.addConceptToTree(t),ut("localconcept",t.ghostId),k.AddConcept(t))}static RemoveConcept(t){return St(this,void 0,void 0,(function*(){try{0!=t.id&&(pt.removeNodeFromTree(t.ghostId),gt.removeConceptType(t.characterValue,t.ghostId),Ct.removeConceptType(t.typeId,t.ghostId),yield ut("localconcept",t.ghostId))}catch(t){throw t}}))}static RemoveConceptById(t){return St(this,void 0,void 0,(function*(){try{let e=yield Lt.GetConcept(t);0!=e.id&&(pt.removeNodeFromTree(t),gt.removeConceptType(e.characterValue,e.ghostId),Ct.removeConceptType(e.typeId,e.ghostId),kt.RemoveConcept(e))}catch(t){throw t}}))}static AddConceptToMemory(t){0!=t.id&&(pt.addConceptToTree(t),gt.addConceptToTree(t),Ct.addConceptToTree(t))}static GetConcept(t){return St(this,void 0,void 0,(function*(){var e=Nt(),n=yield pt.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static UpdateConceptSyncStatus(t){return St(this,void 0,void 0,(function*(){pt.updateSyncStatus(t)}))}static GetConceptByGhostId(t){return St(this,void 0,void 0,(function*(){var e=Nt(),n=yield It.getNodeFromTree(t);if(null==n?void 0:n.value){var o=n.value;o&&(e=o)}return e}))}static GetConceptByCharacter(t){return St(this,void 0,void 0,(function*(){var e=Nt(),n=gt.getNodeFromTree(t);return n&&(e=n.value),e}))}static GetConceptByCharacterAndTypeLocal(t,e){return St(this,void 0,void 0,(function*(){var n=Nt(),o=yield gt.getCharacterAndTypeFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptByCharacterAndCategoryLocal(t,e){return St(this,void 0,void 0,(function*(){var n=Nt(),o=yield gt.getCharacterAndCategoryFromTree(t,e);return o&&(n=o.value),n}))}static GetConceptsByTypeId(t){let e=[];for(var n=0;n<this.localconceptsArray.length;n++)this.localconceptsArray[n].typeId==t&&e.push(this.localconceptsArray[n]);return e}static GetConceptsByTypeIdAndUser(t,e){return St(this,void 0,void 0,(function*(){let n=[];return n=yield Ct.getTypeVariantsFromTreeWithUserId(t,e),n}))}static ClearData(){return St(this,void 0,void 0,(function*(){this.localconceptsArray=[],xt.connectionArray=[]}))}getName(){return this.name}}Lt.localconceptsArray=[];var Rt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bt(t){return Rt(this,void 0,void 0,(function*(){try{let n=C();var e=yield k.GetConcept(t);let i=k.GetNpc(t);if(0!=e.id||i)return e;{G(),console.log("this is the url",o.GetConceptUrl());const e=new FormData;e.append("id",t.toString());const i=yield fetch(o.GetConceptUrl(),{method:"POST",body:e});return i.ok?(n=yield i.json(),n.id>0?k.AddConcept(n):k.AddNpc(t)):(console.log("Get the concept error",i.status),L(i)),n}}catch(t){t instanceof Error?console.log("Get the concept error message: ",t.message):console.log("Get the concept unexpected error: ",t),R(t,o.GetConceptUrl())}}))}var Gt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _t(t){return Gt(this,void 0,void 0,(function*(){var e=[];0==(e=yield Z.GetConnectionsOfConcept(t)).length?e=yield Bt(t):e=yield Bt(t);return e}))}function Bt(t){return Gt(this,void 0,void 0,(function*(){var e=[];try{G("application/json");const i=new Headers,r=new FormData;r.append("composition_id",t.toString());const c=yield fetch(o.GetAllConnectionsOfCompositionUrl(),{method:"POST",headers:i,body:r});if(console.log("this is getting connection from online",o.GetAllConnectionsOfCompositionUrl(),t),!c.ok)throw L(c),new Error(`Error! status: ${c.status}`);const a=yield c.json();for(var n=0;n<a.length;n++)Z.AddConnection(a[n]),e.push(a[n]);return e}catch(t){t instanceof Error?console.log("Get all connection of composition error : ",t.message):console.log("Get all connection of composition error : ",t),R(t,o.GetAllConnectionsOfCompositionUrl())}}))}var Pt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ut(t,e,n){return Pt(this,void 0,void 0,(function*(){var o,i;let r={},c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,e,n);return r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a,r}))}function Ft(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield _t(t),console.log("this is the connection list online",o);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,o,r);return i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a,i}))}function Dt(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield _t(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield Jt(t,o,r);return i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a,i}))}function Et(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield Z.GetConnectionsOfCompositionLocal(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield Wt(c,o,r);return i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a,i}))}function Ot(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield Z.GetConnectionsOfCompositionLocal(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield $t(c,o,r);return i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a,i}))}function Vt(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield Z.GetConnectionsOfCompositionLocal(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield Wt(c,o,r);i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a;let s={};return s.created_at=c.entryTimeStamp,s.data=i,s.id=t,s}))}function jt(t){return Pt(this,void 0,void 0,(function*(){var e;let n=[],o={};n=yield Z.GetConnectionsOfCompositionLocal(t);let i=[];for(let t=0;t<n.length;t++)i.includes(n[t].ofTheConceptId)||i.push(n[t].ofTheConceptId);let r=yield k.GetConcept(t);0==r.id&&null!=t&&null!=t&&(console.log("this concept you cannot find ",t),r=yield bt(t));let c=(new Date).getTime(),a=yield function(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c,a,s,l,d,h;let u={},f=t.id,y=((new Date).getTime(),null!==(r=null===(i=null==t?void 0:t.type)||void 0===i?void 0:i.characterValue)&&void 0!==r?r:"");if(!n.includes(f)){let e=y;return{[e]:null==t?void 0:t.characterValue}}if(o.includes(f))return"";o.push(f);for(let t=0;t<e.length;t++){let n=yield dn(e[t].ofTheConceptId),o=yield dn(e[t].toTheConceptId);e[t].ofConcept=n,e[t].toConcept=o;let i=n.id,r="the_",s=(null!==(a=null===(c=null==o?void 0:o.type)||void 0===c?void 0:c.characterValue)&&void 0!==a?a:"").replace(r,"");null!=u[i]&&null!=u[i]||(u[i]={}),u[i][s]=o.characterValue}let p={};for(let t=0;t<e.length;t++){let n=e[t].ofConcept,o=e[t].toConcept,i=null!==(l=null===(s=null==n?void 0:n.type)||void 0===s?void 0:s.characterValue)&&void 0!==l?l:"",r="the_",c=(null!==(h=null===(d=null==o?void 0:o.type)||void 0===d?void 0:d.characterValue)&&void 0!==h?h:"").replace(r,"");null!=p[n.id]&&null!=p[n.id]||(p[n.id]={});let a=p[n.id];null!=a[i]&&null!=a[i]||(a[i]={}),null!=u[e[t].ofTheConceptId]&&null!=u[e[t].toTheConceptId]?a[i][c]=u[o.id]:a[i][c]=o.characterValue}return p[t.id]}))}(r,n,i);console.log("this is the time for the data to be made",(new Date).getTime()-c),null===(e=null==r?void 0:r.type)||void 0===e||e.characterValue,o=a;let s={};return s.created_at=r.entryTimeStamp,s.data=o,s.id=t,s}))}function Mt(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield Z.GetConnectionsOfCompositionLocal(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,o,r);i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a;let s={};return s.data=i,s.id=t,s.created_at=c.entryTimeStamp,s}))}function Ht(t){return Pt(this,void 0,void 0,(function*(){var e,n;let o=[],i={};o=yield _t(t);let r=[];for(let t=0;t<o.length;t++)r.includes(o[t].ofTheConceptId)||r.push(o[t].ofTheConceptId);let c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,o,r);i[null!==(n=null===(e=null==c?void 0:c.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=a;let s={};return s.data=i,s.id=t,s}))}function Wt(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;let a={},s=[],l=t.id;if(null===(i=null==t?void 0:t.type)||void 0===i?void 0:i.characterValue,!n.includes(l))return null==t?void 0:t.characterValue;if(o.includes(l))return"";o.push(l);for(let t=0;t<e.length;t++)if(e[t].ofTheConceptId==l)if(l!=e[t].toTheConceptId){let i=e[t].toTheConceptId,l=yield k.GetConcept(i);if(null!=l&&0!=l.id||null==i||null==i||(l=yield bt(i)),0!=l.id&&null==(null==l?void 0:l.type)){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}let d="the_",h=(null!==(c=null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(d,"");if(isNaN(Number(h))){if(h){const t=yield Wt(l,e,n,o);a[h]=t}}else{const t=yield Wt(l,e,n,o);s[h]=t,a=s}}else console.log("this is the faulty connection ",e[t]);return a}))}function $t(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;(new Date).getTime();let a={},s=[],l=t.id;if(a.id=l,null===(i=null==t?void 0:t.type)||void 0===i?void 0:i.characterValue,!n.includes(l))return null==t?void 0:t.characterValue;if(o.includes(l))return"";o.push(l);for(let t=0;t<e.length;t++)if(e[t].ofTheConceptId==l)if(l!=e[t].toTheConceptId){let i=e[t].toTheConceptId,l=yield k.GetConcept(i);if(null!=l&&0!=l.id||null==i||null==i||(l=yield bt(i)),0!=l.id&&null==(null==l?void 0:l.type)){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}let d="the_",h=(null!==(c=null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(d,"");if(isNaN(Number(h))){if(h){const t=yield Wt(l,e,n,o);a[h]=t}}else{const t=yield Wt(l,e,n,o);s[h]=t,a=s}}else console.log("this is the faulty connection ",e[t]);return a}))}function qt(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;let a={},s=[];if(0==t)return null;let l=yield k.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield bt(t)),0!=l.id&&null==l.type){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(let i=0;i<e.length;i++)if((new Date).getTime(),e[i].ofTheConceptId==t)if(t!=e[i].toTheConceptId){let t=e[i].toTheConceptId,l=yield k.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield bt(t)),0!=l.id&&null==(null==l?void 0:l.type)){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}let d="the_",h=(null!==(c=null===(r=null==l?void 0:l.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(d,"");if(isNaN(Number(h))){if(h){const i=yield qt(t,e,n,o);a[h]=i}}else{const i=yield qt(t,e,n,o);s[h]=i,a=s}}else console.log("this is the faulty connection ",e[i]);return a}))}function Jt(t,e,n){return Pt(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;let a={},s=[];if(0==t)return null;let l=yield k.GetConcept(t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield bt(t)),0!=l.id&&null==l.type){let t=l.typeId,e=yield k.GetConcept(t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),l.type=e)}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t),a.id=t;for(let o=0;o<e.length;o++)if(e[o].ofTheConceptId==t){let t=e[o].toTheConceptId,i=yield k.GetConcept(t);if(null!=i&&0!=i.id||null==t||null==t||(i=yield bt(t)),i&&null==(null==i?void 0:i.type)){let t=i.typeId,e=yield k.GetConcept(t);i.type=e,null==e&&null!=t&&null!=t&&(e=yield bt(t),i.type=e)}let l="the_",d=(null!==(c=null===(r=null==i?void 0:i.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(d))){if(d){const o=yield Jt(t,e,n);a[d]=o}}else{const o=yield Jt(t,e,n);s[d]=o,a=s}}return a}))}var zt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Qt(t){return zt(this,void 0,void 0,(function*(){let e=C();try{const n=new FormData;n.append("character_value",t);const i=yield fetch(o.GetConceptByCharacterValueUrl(),{method:"POST",body:n});i.ok?(e=yield i.json(),e.id>0&&k.AddConcept(e)):(L(i),console.log("Error in Getting concept by character value Error",i.status))}catch(t){t instanceof Error?console.log("Error in Getting concept by character value error message: ",t):console.log("Error in Getting concept by character value unexpected error: ",t),R(t,o.GetConceptByCharacterValueUrl())}return e}))}var Zt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Kt(t){return Zt(this,void 0,void 0,(function*(){let e=yield k.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Qt(t),e=yield k.GetConceptByCharacterAndTypeLocal(t,51),0==e.id&&(e=yield k.GetConceptByCharacter(t))),e}))}var Xt=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yt(t){return Xt(this,void 0,void 0,(function*(){return yield Lt.GetConceptByCharacterAndTypeLocal(t,51)}))}function te(t){return Xt(this,void 0,void 0,(function*(){let e=Nt();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=F(t);if(n.length>1){let o=1,i=yield te(n[0]);0!=i.id&&(o=i.id),e=yield function(t,e){return Xt(this,void 0,void 0,(function*(){return Lt.GetConceptByCharacterAndCategoryLocal(t,e)}))}(t,o)}else n[0]==t&&(e=yield Yt(t));return e}))}var ee=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ne(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=yield Kt(t),r=[];if(i){yield E(t,e);let c=yield k.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[];for(let t=a;t<a+n;t++)c[t]&&s.push(c[t].id);yield it(s);for(let t=a;t<a+n;t++)if(c[t]){let e=yield Et(c[t].id);r.push(e)}}return r}))}function oe(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=fe(t,e),r=ne(t,e),c=[];return Promise.race([i,r]).then((t=>{console.log("Promise result",t),c.push(...t)})).catch((t=>{console.log("error in handling",t)})),r.then((t=>{console.log("This is the second promise result",t),c.push(...t)})),c}))}function ie(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=yield Yt(t),r=yield Kt(t),c=[],a=[],s=[],l=[];0!=i.id&&(a=yield Lt.GetConceptsByTypeIdAndUser(i.id,e)),0!=r.id&&(yield E(t,e),l=yield k.GetConceptsByTypeIdAndUser(r.id,e),c=l);for(let t=0;t<a.length;t++){let e=!1;for(let n=0;n<l.length;n++)a[t].ghostId==l[n].ghostId&&(e=!0);e||s.push(a[t])}console.log("This is the all list",s);let d=[];return d=yield function(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=[],r=n*(o-1),c=[],a=e.length;for(let e=r;e<r+n-a;e++)t[e]&&c.push(t[e].id);for(let t=0;t<e.length;t++){let n=yield de(e[t].id);i.push(n)}yield it(c);for(let e=r;e<r+n-a;e++)if(t[e]){let n=yield Vt(t[e].id);i.push(n)}return i}))}(c,s,n,o),d}))}function re(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=yield Kt(t),r=[];if(i){yield E(t,e);let c=yield k.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[];for(let t=a;t<a+n;t++)c[t]&&s.push(c[t].id);yield it(s);for(let t=a;t<a+n;t++)if(c[t]){let e=yield Vt(c[t].id);r.push(e)}}return r}))}function ce(t,e){return ee(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=yield function(t){return Zt(this,void 0,void 0,(function*(){let e=yield k.GetConceptByCharacter(t),n=`${t}`;return null!=e&&0!=(null==e?void 0:e.id)||!n||(yield Qt(t),e=yield k.GetConceptByCharacter(t)),e}))}(t),r=[];if(i){yield E(t,e);let c=yield k.GetConceptsByTypeIdAndUser(i.id,e),a=n*(o-1),s=[];for(let t=a;t<a+n;t++)c[t]&&s.push(c[t].id);yield it(s);for(let t=a;t<a+n;t++)if(c[t]){let e=yield Vt(c[t].id);r.push(e)}}return r}))}var ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},se=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function le(t){return se(this,void 0,void 0,(function*(){var e,n;try{let i=[],r={};i=yield xt.GetConnectionsOfCompositionLocal(t);let c=[];for(let t=0;t<i.length;t++)c.includes(i[t].ofTheConceptId)||c.push(i[t].ofTheConceptId);let a=yield Lt.GetConcept(t);if(0==a.id){let e=yield function(t){return ae(this,void 0,void 0,(function*(){let e=C();try{var n=_("application/x-www-form-urlencoded");const i=yield fetch(o.GetRealConceptById(),{method:"POST",headers:n,body:`id=${t}`});if(i.ok)return e=yield i.json(),e.id>0&&k.AddConcept(e),e;console.log("Error in Getting Translating concept Error",i.status),L(i)}catch(t){t instanceof Error?console.log("Error in Getting Translating concept error message: ",t):console.log("Error in Getting Translating concept unexpected error: ",t),R(t,o.GetRealConceptById())}return e}))}(t);if(e.id>0)return yield Ft(e.id)}let s=yield he(t,i,c);return r[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=s,r}catch(t){throw t}}))}function de(t){return se(this,void 0,void 0,(function*(){var e,n;try{let o=[],i={},r={};o=yield xt.GetConnectionsOfCompositionLocal(t);let c=[];for(let t=0;t<o.length;t++)c.includes(o[t].ofTheConceptId)||c.push(o[t].ofTheConceptId);let a=yield Lt.GetConcept(t);if(0!=a.id){let r=yield he(t,o,c);i[null!==(n=null===(e=null==a?void 0:a.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"top"]=r}return r.data=i,r.id=t,r}catch(t){throw t}}))}function he(t,e,n){return se(this,arguments,void 0,(function*(t,e,n,o=[]){var i,r,c;let a={},s=[],l=yield Lt.GetConcept(t);if(0!=l.id&&null==l.type){let t=l.typeId,e=yield Lt.GetConcept(t);l.type=e}if(null===(i=null==l?void 0:l.type)||void 0===i?void 0:i.characterValue,!n.includes(t))return null==l?void 0:l.characterValue;if(o.includes(t))return"";o.push(t);for(let o=0;o<e.length;o++)if(e[o].ofTheConceptId==t){let t=e[o].toTheConceptId,i=yield Lt.GetConcept(t);if(0!=i.id&&null==(null==i?void 0:i.type)){let t=i.typeId,e=yield Lt.GetConcept(t);i.type=e}let l="the_",d=(null!==(c=null===(r=null==i?void 0:i.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"top").replace(l,"");if(isNaN(Number(d))){if(d){const o=yield he(t,e,n);a[d]=o}}else{const o=yield he(t,e,n);s[d]=o,a=s}}return a}))}var ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function fe(t,e){return ue(this,void 0,void 0,(function*(){try{let n=yield Yt(t),o=[];if(0!=n.id){let t=yield Lt.GetConceptsByTypeIdAndUser(n.id,e);for(let e=0;e<t.length;e++){let n=yield le(t[e].id);o.push(n)}}return o}catch(t){throw t}}))}function ye(t,e){return ue(this,void 0,void 0,(function*(){try{let n=yield Yt(t),o=[];if(0!=n.id){let t=yield Lt.GetConceptsByTypeIdAndUser(n.id,e);for(let e=0;e<t.length;e++){let n=yield de(t[e].id);o.push(n)}}return o}catch(t){throw t}}))}var pe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ve(t){return pe(this,void 0,void 0,(function*(){let e=C();try{var n=G();const i=yield fetch(o.CreateTheConceptUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(!i.ok)throw L(i),new Error(`Error! status: ${i.status}`);return e=yield i.json(),e}catch(t){t instanceof Error?console.log("Create the concept api error message: ",t.message):console.log("Create the concept api unexpected error: ",t),R(t,o.CreateTheConceptUrl())}}))}var ge=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class me{static CheckContains(t){for(var e=!1,n=0;n<this.conceptsSyncArray.length;n++)this.conceptsSyncArray[n].id==t.id&&(e=!0);return e}static SyncDataDelete(t){for(var e=0;e<this.conceptsSyncArray.length;e++)t==this.conceptsSyncArray[e].id&&this.conceptsSyncArray.splice(e,1);for(e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].ofTheConceptId!=t&&this.connectionSyncArray[e].toTheConceptId!=t&&this.connectionSyncArray[e].typeId!=t||this.connectionSyncArray.splice(e,1)}static CheckContainsConnection(t){for(var e=!1,n=0;n<this.connectionSyncArray.length;n++)this.connectionSyncArray[n].id==t.id&&(e=!0);return e}static AddConcept(t){this.conceptsSyncArray.push(t)}static RemoveConcept(t){for(var e=0;e<this.conceptsSyncArray.length;e++)this.conceptsSyncArray[e].id==t.id&&this.conceptsSyncArray.splice(e,1)}static AddConnection(t){this.connectionSyncArray.push(t)}static RemoveConnection(t){for(var e=0;e<this.connectionSyncArray.length;e++)this.connectionSyncArray[e].id==t.id&&this.connectionSyncArray.splice(e,1)}static SyncDataOnline(){return ge(this,void 0,void 0,(function*(){for(let t=0;t<this.conceptsSyncArray.length;t++)k.AddConcept(this.conceptsSyncArray[t]);for(let t=0;t<this.connectionSyncArray.length;t++)Z.AddConnection(this.connectionSyncArray[t]);if(this.conceptsSyncArray.length>0){let t=this.conceptsSyncArray.slice();this.conceptsSyncArray=[],ve(t)}if(this.connectionSyncArray.length>0){let t=this.connectionSyncArray.slice();this.connectionSyncArray=[],yield function(t){return e=this,n=void 0,r=function*(){let e=new O(0,0,0,0,0,0,0);try{var n=G(),i=JSON.stringify(t);const r=yield fetch(o.CreateTheConnectionUrl(),{method:"POST",headers:n,body:i});return r.ok?yield r.json():(console.log("Create the connection error message: ",r.status),L(r)),e}catch(t){throw t instanceof Error?console.log("Create the connection error message: ",t.message):console.log(" Create the connection unexpected error: ",t),t}},new((i=void 0)||(i=Promise))((function(t,o){function c(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r.throw(t))}catch(t){o(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(c,a)}s((r=r.apply(e,n||[])).next())}));var e,n,i,r}(t)}return"done"}))}static syncDataLocalDb(){return ge(this,void 0,void 0,(function*(){if(this.conceptsSyncArray.length>0){for(let t=0;t<this.conceptsSyncArray.length;t++)s("localconcept",this.conceptsSyncArray[t]);this.conceptsSyncArray=[]}if(this.connectionSyncArray.length>0){for(let t=0;t<this.connectionSyncArray.length;t++)s("localconnection",this.connectionSyncArray[t]);this.connectionSyncArray=[]}return"done"}))}}function Ce(t,e,n,o){var i=new O(0,t,n,e,o,1,4);if(t==n)return i.ofTheConceptId=0,i.toTheConceptId=1,i;try{i.isTemp=!0,i.id=Math.floor(1e8*Math.random()),me.AddConnection(i)}catch(t){R(t)}return i}me.conceptsSyncArray=[],me.connectionSyncArray=[];var Ne=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Te=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ie(t,e){return Te(this,void 0,void 0,(function*(){let n=yield k.GetConceptByCharacterAndTypeLocal(t,e);try{if(null==n||0==n.id){var i={character_value:`${t}`,type_id:e},r=JSON.stringify(i),c=G();const a=yield fetch(o.GetConceptByCharacterAndTypeUrl(),{method:"POST",headers:c,body:r});a.ok?(n=yield a.json(),k.AddConcept(n)):(L(a),console.log("This is the concept by type and character error",a.status))}return n}catch(t){t instanceof Error?console.log(" This is the concept by type and character error message: ",t.message):console.log(" This is the concept by type and character unexpected error: ",t),R(t,o.GetConceptByCharacterAndTypeUrl())}}))}var we=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ke{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.userId=t,this.data=e,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.entryTimestamp=s,this.isNew=l}}var Ae=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class xe{static getId(){return Ae(this,void 0,void 0,(function*(){this.ids.length<5&&(yield function(){return t=this,e=void 0,i=function*(){try{let t=G("application/x-www-form-urlencoded");const e=yield fetch(o.GetReservedIdUrl(),{method:"GET",headers:t});if(!e.ok)throw L(e),new Error(`Error! status: ${e.status}`);const n=yield e.json();for(let t=0;t<n.length;t++)xe.AddId(n[t])}catch(t){t instanceof Error?console.log("get reserved ids error message: ",t.message):console.log("get reserved ids unexpected error: ",t),R(t,o.GetReservedIdUrl())}},new((n=void 0)||(n=Promise))((function(o,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((i=i.apply(t,e||[])).next())}));var t,e,n,i}());var t=this.ids[0];return this.ids.shift(),t}))}static AddId(t){this.ids.includes(t)||this.ids.push(t)}}xe.ids=[];class Se{static getId(){return Ae(this,void 0,void 0,(function*(){this.connectionIds.length<5&&(yield function(){return t=this,e=void 0,i=function*(){try{let t=G("application/x-www-form-urlencoded");const e=yield fetch(o.GetReservedConnectionIdUrl(),{method:"GET",headers:t});if(!e.ok)throw L(e),new Error(`Error! status: ${e.status}`);const n=yield e.json();for(let t=0;t<n.length;t++)Se.AddId(n[t])}catch(t){t instanceof Error?console.log("get reserved connection ids error message: ",t.message):console.log("get reserved connection ids unexpected error: ",t),R(t,o.GetReservedConnectionIdUrl())}},new((n=void 0)||(n=Promise))((function(o,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((i=i.apply(t,e||[])).next())}));var t,e,n,i}());var t=this.connectionIds[0];return this.connectionIds.shift(),t}))}static AddId(t){this.connectionIds.includes(t)||this.connectionIds.push(t)}}Se.connectionIds=[];var Le=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Re(t,e,n,o,i,r,c){return Le(this,void 0,void 0,(function*(){let a=yield xe.getId(),s=new Date,l=new Date,d=new m(a,e,o,n,i,t,r,!0,s,l,c);return d.isTemp=!1,me.AddConcept(d),d}))}function be(t,e,n,o,i,r,c){return Le(this,void 0,void 0,(function*(){let a=yield xe.getId(),s=new Date,l=new Date,d=new m(a,e,o,n,i,t,r,!1,s,l,c);return k.AddConcept(d),ve([d]),d}))}var Ge=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _e(t,e){return Ge(this,arguments,void 0,(function*(t,e,n=!1,i,r=4,c=999,a=0){let s,l=c,d=i,h=i,u=r,f=i,y="",p=e.length,v=C();if(y=t.startsWith("the_")?t:"the_"+t,n)v=yield Dn(t),s=yield Re(e,i,4,v.id,a,u,t);else if(p>255)v=yield Dn(y),s=yield Re(e,i,4,v.id,a,u,y),function(t){Ne(this,void 0,void 0,(function*(){try{var e=G();const n=yield fetch(o.CreateTheTextDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!n.ok)throw L(n),new Error(`Error! status: ${n.status}`);return yield n.json()}catch(t){throw t instanceof Error?console.log("Create the text error message: ",t.message):console.log("Create the text unexpected error: ",t),t}}))}(new ke(i,e,999,d,u,f,l,h,Date.now().toString(),!0));else{v=yield Dn(y);let t=yield Ie(e,v.id);s=t,0==t.id&&0==t.userId&&(s=yield be(e,i,4,v.id,12,u,y),function(t,e,n,i){we(this,void 0,void 0,(function*(){try{let r={newConceptId:t,referent:e,typeId:n,typeUserId:i},c=G(),a=JSON.stringify(r);const s=yield fetch(o.MakeTheNameInBackendUrl(),{method:"POST",headers:c,body:a});s.ok||L(s)}catch(t){t instanceof Error?console.log("make the name in backend error message: ",t.message):console.log("make the name in backend unexpected error: ",t),R(t,o.MakeTheNameInBackendUrl())}}))}(s.id,`${e}`,v.id,i))}return s.type=v,s}))}var Be=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Pe(t){return Be(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null){let a=null!=i?i:999,s=null!=r?r:4,l=null!=c?c:999,d=null!=o?o:0,h=C();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){let e=d,n=yield _e(o,"",!0,a,s,l);h=n,e=n.id,d=n.id,yield Pe(t[o],n.id,n.userId,e,i,r,c)}else{let u=null!=e?e:999,f=null!=n?n:999,y=d,p=yield _e(o,"",!0,a,s,l);h=p,yield Ce(u,f,p.id,y),yield Pe(t[o],p.id,p.userId,y,i,r,c)}else{let i=null!=e?e:999,r=null!=n?n:10267,c=d,h=yield _e(o,t[o].toString(),!1,a,s,l);yield Ce(i,r,h.id,c)}return h}))}var Ue=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Fe(){return Ue(this,void 0,void 0,(function*(){console.log("this is trying to create local binary tree");try{let t=yield lt("localconcept");if(Array.isArray(t))for(let e=0;e<t.length;e++){let n=t[e];Lt.AddConceptToMemory(n)}u.isLocalDataLoaded=!0,u.isLocalTypeLoaded=!0,u.isLocalCharacterLoaded=!0}catch(t){throw yield Ki(2e3,Fe()),{message:"Cannot create local binary tree from index db",data:t,ok:!1,status:400}}}))}function De(){return Ue(this,void 0,void 0,(function*(){try{yield navigator.locks.request("dblock",(t=>Ue(this,void 0,void 0,(function*(){let t=yield lt("localid");if(Array.isArray(t)){if(t[0]){let e=t[0].value;if(e)Ve.AddConceptId(t[0]);else{e=-Math.floor(1e8*Math.random());let t={id:0,value:e},n={id:0,value:e-10};Ve.AddConceptId(t),yield ht("localid",n)}}t[2]&&(o.BASE_RANDOMIZER=t[2].value)}}))))}catch(t){throw{message:"Cannot populate Local Ids from the Index Db",data:t,ok:!1,status:400}}}))}function Ee(){return Ue(this,void 0,void 0,(function*(){try{yield navigator.locks.request("dblock",(t=>Ue(this,void 0,void 0,(function*(){let t=yield lt("localid");if(Array.isArray(t)){if(t[1]){let e=t[1].value;if(e)Ve.AddConnectionId(t[1]),yield ht("localid",{id:1,value:e-10});else{e=-Math.floor(1e8*Math.random());let t={id:0,value:e},n={id:0,value:e-10};Ve.AddConnectionId(t),yield ht("localid",n)}}t[2]&&(o.BASE_RANDOMIZER=t[2].value)}}))))}catch(t){throw{message:"Cannot populate Local Ids from the Index Db",data:t,ok:!1,status:400}}}))}var Oe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ve{static AddConceptId(t){this.localId=t.value,ht("localid",t)}static getConceptId(){return Oe(this,void 0,void 0,(function*(){try{if(this.localId){if(this.ReservedLocalId.length<5){yield De().then((()=>{let t=this.localId;for(let e=1;e<10;e++){let n=this.localId-e;this.ReservedLocalId.push(n),t=n}this.AddConceptId({id:0,value:t})})).catch((t=>(console.log(" getid: cannot get the id from indexdb"),-Math.floor(1e8*Math.random()))));let t=this.ReservedLocalId[0];return this.ReservedLocalId.shift(),t}{let t=this.ReservedLocalId[0];return this.ReservedLocalId.shift(),t}}return yield De().then((()=>{let t=this.localId;for(let e=1;e<10;e++){let n=this.localId-e;this.ReservedLocalId.push(n),t=n}this.AddConceptId({id:0,value:t})})),this.getConceptId()}catch(t){return console.log(" getid: this is the eror in concept",t),-Math.floor(1e8*Math.random())}}))}static AddConnectionId(t){this.localConnectionId=t.value}static getConnectionId(){return Oe(this,void 0,void 0,(function*(){try{if(this.localConnectionId){if(this.ReservedConnectionId.length<5){yield Ee().then((()=>{let t=this.localConnectionId;for(let e=1;e<10;e++){let n=this.localConnectionId-e;this.ReservedConnectionId.push(n),t=n}})).catch((t=>(console.log("this is the new event",t),-Math.floor(1e8*Math.random()))));let t=this.ReservedConnectionId[0];return this.ReservedConnectionId.shift(),t}{let t=this.ReservedConnectionId[0];return this.ReservedConnectionId.shift(),t}}return yield Ee().then((()=>{let t=this.localConnectionId;for(let e=1;e<10;e++){let n=this.localConnectionId-e;this.ReservedConnectionId.push(n),t=n}this.AddConnectionId({id:1,value:t})})),this.getConnectionId()}catch(t){return-Math.floor(1e8*Math.random())}}))}}Ve.ReservedLocalId=[],Ve.ReservedConnectionId=[];var je=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Me(t,e,n){return je(this,arguments,void 0,(function*(t,e,n,o=1,i="",r=999){try{let c=4,a=yield Ve.getConnectionId(),s=0,l=0,d=0;s=t,l=e,d=n;let h=new O(0,0,0,0,0,0,0);return t!=e&&(h=new O(a,s,l,r,n,o,c),h.isTemp=!0,h.typeCharacter=i,yield kt.AddConnection(h),xt.AddConnection(h)),h}catch(t){throw t}}))}var He=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function We(t,e,n,o,i,r){return He(this,arguments,void 0,(function*(t,e,n,o,i,r,c=!1,a=0){try{let s=yield Ve.getConceptId();console.log("this is the getting id type connection",s);let l=!0,d=new Date,h=new Date;if("the"==t)return new m(1,999,5,5,a,t,r,l,d,h,e);let u=new m(s,n,i,o,a,t,r,l,d,h,e);return u.isTemp=!0,u.isComposition=c,Lt.AddConcept(u),u}catch(t){throw t}}))}var $e=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},qe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Je(t,e,n,o){return qe(this,void 0,void 0,(function*(){let i=yield te(t);if(i&&(0==i.id||0==i.userId)){let r=F(t);if(r[0]==t){let e=yield function(t,e,n,o){return $e(this,void 0,void 0,(function*(){let e=yield Lt.GetConceptByCharacterAndTypeLocal(t,51),i=e;return o=1,0==i.id&&(e=yield We(t,"the",n,o,51,4),i=e),i}))}(t,0,o,1);i=e}else{let c=yield Je(r[0],e,n,o),a=yield Je(r[1],e,n,o);i=yield We(t,r[1],o,c.id,a.id,4)}}return i}))}var ze=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Qe(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!1,o,i,r=999,c=0){try{let i,r,a=999,s=4,l=o,d=4,h="",u=e.length;if(h=t.startsWith("the_")?t:"the_"+t,n)i=yield Je(t,a,o,o),r=yield We(e,t,o,s,i.id,d,!0,c);else if(u>255)i=yield Je(h,a,l,o),r=yield We(e,h,o,s,i.id,d);else{i=yield Je(h,a,l,o);let t=yield Lt.GetConceptByCharacterAndTypeLocal(e,i.id);r=t,0==t.id&&0==t.userId&&(r=yield We(e,h,o,s,i.id,d))}return r.type=i,kt.AddConcept(r),r}catch(t){throw t}}))}var Ze=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ke(t){return Ze(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=!1){let s=null!=i?i:999,l=null!=r?r:999,d=null!=c?c:999,h=null!=o?o:0,u=Nt();for(const o in t)if("string"!=typeof t[o]&&"number"!=typeof t[o])if(null==e&&null==n){let e=h,n=yield Qe(o,"",!0,s,l,d);u=n,e=n.id,h=n.id,yield Ke(t[o],n.id,n.userId,e,i,r,c)}else{let n=null!=e?e:999,a=h,u=yield Qe(o,"",!0,s,l,d);yield Me(n,u.id,a),yield Ke(t[o],u.id,u.userId,a,i,r,c)}else{let n=null!=e?e:999,i=h,r=yield Qe(o,t[o].toString(),!1,s,l,d);yield Me(n,r.id,i)}return u}))}var Xe=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ye(t,e,n){return Xe(this,arguments,void 0,(function*(t,e,n,i=10,r=1){let c=[];try{let a=new URLSearchParams;a.append("typeId",`${t}`),a.append("ofTheConceptId",`${e}`),a.append("userId",`${n}`),a.append("inpage",`${i}`),a.append("page",`${r}`);let s=G("application/x-www-form-urlencoded");const l=yield fetch(o.GetAllConnectionsOfConceptUrl(),{method:"POST",headers:s,body:a});return l.ok?c=yield l.json():(L(l),console.log("Get connection of concept error",l.status)),c}catch(t){t instanceof Error?console.log("Get connection of concept error message: ",t.message):console.log("Get connection of concept unexpected error: ",t),R(t,o.GetAllConnectionsOfConceptUrl())}}))}var tn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function en(t,e,n,o){return tn(this,arguments,void 0,(function*(t,e,n,o,i=1,r=4){if(t>0&&n>0){var c=e,a=yield Se.getId(),s=new O(a,t,n,c,o,i,r);return t==n?(s.ofTheConceptId=0,s.toTheConceptId=1,s):(s.toUpdate=!0,s.isTemp=!1,me.AddConnection(s),s)}throw new S("cannot create connection because id are negative ",!1,400,"")}))}var nn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},on=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},rn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function cn(t){return rn(this,void 0,void 0,(function*(){let e=yield Z.GetConnection(t);if((null==e||0==e.id)&&null!=t&&null!=t){let n=yield function(t){return on(this,void 0,void 0,(function*(){let e=yield Z.GetConnection(t);try{if(0!=e.id)return e;{let n=G("application/x-www-form-urlencoded");const i=new FormData;i.append("id",t.toString());const r=yield fetch(o.GetConnectionUrl(),{method:"POST",headers:n,body:i});return r.ok?(e=yield r.json(),Z.AddConnection(e)):(L(r),console.log("Get Connection Error",r.status)),e}}catch(t){t instanceof Error?console.log("Get Connection error message: ",t.message):console.log("Get Connection unexpected error: ",t),R(t,o.GetConnectionUrl())}}))}(t);e=n}return e}))}var an=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function sn(t){return an(this,void 0,void 0,(function*(){t>0?(yield cn(t),yield function(t){return nn(this,void 0,void 0,(function*(){try{const e=new FormData;e.append("id",t.toString());let n=B();const i=yield fetch(o.DeleteTheConnectionUrl(),{method:"POST",headers:n,body:e,redirect:"follow"});i.ok||(console.log("Delete connection error status: ",i.status),L(i))}catch(t){t instanceof Error?console.log("Delete connection error message: ",t.message):console.log("Delete connection unexpected error: ",t),R(t,o.DeleteTheConnectionUrl())}}))}(t),M.removeNodeFromTree(t)):xt.RemoveConnectionById(t)}))}var ln=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function dn(t){return ln(this,arguments,void 0,(function*(t,e=999){try{let n=C();if(t<0)return n=Si(yield si(e,t)),n;if(n=yield k.GetConcept(t),null!=n&&0!=n.id||null==t||null==t||(n=yield bt(t)),0!=n.id&&null==n.type&&null==(yield k.GetConcept(n.typeId))&&null!=n.typeId&&null!=n.typeId){let t=yield bt(n.typeId);n.type=t}return n}catch(t){throw console.error("this is the error in the getting concept",t),t}}))}var hn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function un(t,e,n){return hn(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c;let a=t.userId;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield fn(o,e,a));let s=yield _e("connection",c,!1,999,999,999),l=new O(0,e.id,t.id,a,s.id,1e3,4);me.AddConnection(l)}let s=n+"_s",l=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+s;i&&(yield fn(s,t,a));let d=yield _e("connection",l,!1,999,999,999),h=new O(0,t.id,e.id,a,d.id,1e3,4);return me.AddConnection(h),h}))}function fn(t,e){return hn(this,arguments,void 0,(function*(t,e,n=null){var o;let i=e,r=null!=n?n:e.userId,c=t+"_count",a=(null===(o=e.type)||void 0===o?void 0:o.characterValue)+"_s_"+c,s=yield _e("connection",a,!1,r,4,999),l=yield Ye(s.id,e.id,r,10,1),d=[],h=C();for(let t=0;t<l.length;t++){let e=yield dn(l[t].toTheConceptId);d.push(e)}if(d.length<1)h=yield _e("count","1",!1,r,4,999);else{let t=d[0],e=0;try{e=Number(t.characterValue)}catch(t){e=0}e+=1,h=yield _e("count",e.toString(),!1,r,4,999);for(let t=0;t<l.length;t++)sn(l[t].id)}let u=new O(0,i.id,h.id,i.userId,s.id,1e3,4);yield me.AddConnection(u)}))}function yn(t,e,n){return hn(this,arguments,void 0,(function*(t,e,n,o=!1,i=!1){var r,c;let a=t.userId;if(o){let o=n+"_by",c=(null===(r=e.type)||void 0===r?void 0:r.characterValue)+"_s_"+o;i&&(yield fn(o,e,a));let s=yield _e("connection",c,!1,999,999,999),l=new O(0,e.id,t.id,a,s.id,1e3,4);me.AddConnection(l)}let s=n+"_s",l=(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+s;i&&(yield fn(s,t,a));let d=yield _e("connection",l,!1,999,999,999);return yield en(t.id,t.userId,e.id,d.id,1e3,4)}))}var pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function vn(t,e){}function gn(t,e,n){return pn(this,void 0,void 0,(function*(){}))}function mn(t){return pn(this,void 0,void 0,(function*(){}))}var Cn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Nn(t,e){return Cn(this,arguments,void 0,(function*(t,e,n=10,o=1){var i;let r=[],c=yield dn(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield Ie(a,16);if(s.id>0){let t=yield Ye(s.id,c.id,c.userId,n,o),e=[];for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield it(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield dn(n),i=yield Mt(o.id);r.push(i)}}return r}))}function Tn(t,e){return Cn(this,arguments,void 0,(function*(t,e,n=10,o=1){var i;let r=[],c=yield dn(t),a=(null===(i=c.type)||void 0===i?void 0:i.characterValue)+"_s_"+e,s=yield Ie(a,16);if(s.id>0){let t=yield Ye(s.id,c.id,c.userId,n,o),e=[];for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield dn(n);r.push(o)}}return r}))}class In{constructor(t,e,n,o,i,r,c,a,s,l){this.id=0,this.isNew=!1,this.userId=t,this.data=`${e}`,this.securityId=n,this.securityUserId=o,this.accessId=i,this.accessUserId=r,this.sessionId=c,this.sessionUserId=a,this.isNew=l}}class wn{constructor(){this.name="character Repository"}static AddCharacter(t){this.characterData[t.id]=t}static GetCharacter(t){for(var e=new In(0,"0",0,0,0,0,0,0,"0",!1),n=0;n<this.characterData.length;n++)this.characterData[n].data==t&&(e=this.characterData[n]);return e}}wn.characterData=[];class kn{constructor(t,e,n,o){this.id=t,this.userId=e,this.referentId=n,this.isNew=o}}var An=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},xn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Sn(t,e,n,i,r){return xn(this,void 0,void 0,(function*(){return new In(e,t,n,e,i,e,r,e,"",!1),yield function(){return An(this,void 0,void 0,(function*(){var t;try{if(0==(t=wn.GetCharacter(t.data)).id){var e=G();const i=yield fetch(o.CreateTheCharacterDataUrl(),{method:"POST",headers:e,body:JSON.stringify(t)});if(!i.ok)throw L(i),new Error(`Error! status: ${i.status}`);const r=yield i.json();var n=new In(r.userId,t.data,0,0,4,4,999,999,"",!1);return n.id=r.id,wn.AddCharacter(n),r}return new kn(t.id,t.userId,0,!1)}catch(t){throw t instanceof Error?console.log("create the character error message: ",t.message):console.log("create the character unexpected error: ",t),t}}))}()}))}var Ln=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Rn(t,e,n,o,i,r,c){return Ln(this,void 0,void 0,(function*(){let a=yield Ie(t,o),s=a;return 0==s.id&&(a=yield Re(t,e,n,o,i,r,c),s=a),s}))}var bn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Gn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _n(t,e,n,o){return Gn(this,void 0,void 0,(function*(){let i=yield Kt(t);if(i&&(0==i.id||0==i.userId)){let r=F(t);if(r.length>0)if(r[0]==t){let n=yield function(t,e,n,o,i,r){return bn(this,void 0,void 0,(function*(){let n;if(1==t.length){let i=t.charCodeAt(0),c=49;yield Sn(t,e,999,o,r),n=Rn(t,e,4,c,i,o,"the_character")}else{let i=yield Sn(t,e,999,o,r);i.isNew,n=yield Rn(t,e,4,51,i.id,o,"the_characters")}return n}))}(t,o,0,999,0,e);i=n}else{let c=yield _n(r[0],e,n,o),a=yield _n(r[1],e,n,o);a&&(i=yield be(t,o,c.id,a.id,999,999,r[1]))}}return i}))}var Bn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Pn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Un(t){return Pn(this,void 0,void 0,(function*(){let e=C();if("the"==t)return e.id=1,e.typeId=5,e.characterValue="the",e;let n=F(t);if(n.length>1){let i=1,r=yield Un(n[0]);0!=r.id&&(i=r.id),e=yield function(t,e){return Pn(this,void 0,void 0,(function*(){let n=yield k.GetConceptByCharacterAndCategoryLocal(t,e);return 0==n.id&&(n=yield function(t,e){return Bn(this,void 0,void 0,(function*(){let n=C();try{var i=G("application/x-www-form-urlencoded");const r=yield fetch(o.GetConceptByCharacterAndCategoryDirectUrl(),{method:"POST",headers:i,body:`character_value=${t}&category_id=${e}`});r.ok?(n=yield r.json(),k.AddConcept(n)):(console.log("This is the concept by category and character error",r.status),L(r))}catch(t){t instanceof Error?console.log(" This is the concept by category and character error message: ",t.message):console.log(" This is the concept by category and character unexpected error: ",t),R(t,o.GetConceptByCharacterAndCategoryDirectUrl())}return n}))}(t,e)),n}))}(t,i)}else n[0]==t&&(e=yield function(t){return Pn(this,void 0,void 0,(function*(){let e=yield k.GetConceptByCharacterAndTypeLocal(t,51);return 0==e.id&&(e=yield Qt(t)),e}))}(t));return e}))}var Fn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Dn(t,e){return Fn(this,void 0,void 0,(function*(){let e=C();try{if(e=yield Un(t),0==e.id||4==e.typeId){let n=G("application/x-www-form-urlencoded");const i=yield fetch(o.MakeTheTypeConceptUrl(),{method:"POST",headers:n,body:`type=${t}`});if(!i.ok)throw L(i),new Error(`Error! status: ${i.status}`);e=yield i.json()}}catch(t){t instanceof Error?console.log("Make The Type Concept Api error : ",t.message):console.log("Make The Type Concept Api error : ",t),R(t,o.MakeTheTypeConceptUrl())}return e}))}var En=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function On(t){return En(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=G("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllLinkerConnectionOfConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection from the concepts error","cannot get respone"),L(c)}catch(t){t instanceof Error?console.log("Get all linker connection from the concepts error: ",t.message):console.log("Get all linker connection from the concepts error(Unexpected): ",t),R(t,o.GetAllLinkerConnectionOfConceptUrl())}return e}))}var Vn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},jn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Mn(t){return jn(this,void 0,void 0,(function*(){let e=yield On(t);for(let t=0;t<e.length;t++){let n=e[t],o=n.typeId,i=yield dn(o);n.type=i}return e}))}function Hn(t){return jn(this,void 0,void 0,(function*(){let e=yield function(t){return Vn(this,void 0,void 0,(function*(){var e=[];try{(new Date).getTime();var n=G("application/x-www-form-urlencoded");const c=yield fetch(o.GetAllLinkerConnectionToConceptUrl()+`?conceptId=${t}`,{method:"GET",headers:n});if(c.ok){const t=yield c.json();for(var i=0;i<t.length;i++){var r=t[i];e.push(r)}}else console.log("Get all linker connection To the concepts error","cannot get respone"),L(c)}catch(t){t instanceof Error?console.log("Get all linker connection To the concepts error: ",t.message):console.log("Get all linker connection To the concepts error(Unexpected): ",t),R(t,o.GetAllLinkerConnectionToConceptUrl())}return e}))}(t);for(let t=0;t<e.length;t++){let n=e[t],o=n.typeId,i=yield dn(o);n.type=i}return e}))}var Wn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},$n=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qn(t){return $n(this,void 0,void 0,(function*(){if(t>0){var e=yield dn(t),n=e.typeId,i=e.characterValue;yield I.removeTypeConcept(n,t),yield p.removeNodeByCharacter(i,t),yield function(t){return Wn(this,void 0,void 0,(function*(){try{const e=new FormData;e.append("id",t.toString());let n=B();const i=yield fetch(o.DeleteConceptUrl(),{method:"POST",headers:n,body:e});i.ok||(console.log("Delete concept error",i.status),L(i))}catch(t){t instanceof Error?console.log("Delete concept error message: ",t.message):console.log("Delete concept unexpected error: ",t),R(t,o.DeleteConceptUrl())}}))}(t),yield g.removeNodeFromTree(t),yield q.removeNodeFromTree(t)}else Lt.RemoveConceptById(t)}))}var Jn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function zn(t,e){return Jn(this,void 0,void 0,(function*(){try{const n=new Headers;n.append("Authorization","Bearer "+e);const i=new FormData;i.append("id",t.toString());const r=yield fetch(o.DeleteConceptUrl(),{method:"POST",body:i,headers:n});if(!r.ok)throw L(r),new Error(`Delete composition Error! status: ${r.status}`)}catch(t){t instanceof Error?console.log("Delete composition error message: ",t.message):console.log("Delete composition unexpected error: ",t),R(t,o.DeleteConceptUrl())}}))}var Qn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Zn(t,e,n){return Qn(this,arguments,void 0,(function*(t,e,n,o=4,i=999){let r,c="",a=t.startsWith("the_"),s=C();return c=a?t:"the_"+t,s=yield Dn(c),r=yield Rn(e,n,4,s.id,0,o,c),r}))}class Kn{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=[],this.ofCompositions=[]}}var Xn=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Yn(){return Xn(this,arguments,void 0,(function*(t=[]){let e=[];try{if(t.length>0){let n=[];for(let o=0;o<t.length;o++){let i=yield Z.GetConnection(t[o]);0==i.id?n.push(t[o]):e.push(i)}if(0==n.length)return e;{let t=G();const i=yield fetch(o.GetConnectionBulkUrl(),{method:"POST",headers:t,body:JSON.stringify(n)});if(i.ok){const t=yield i.json();if(t.length>0)for(let n=0;n<t.length;n++){let o=t[n];e.push(o),Z.AddConnection(o)}}else L(i),console.log("Get Connection Bulk error",i.status)}}}catch(t){t instanceof Error?console.log("Get Connection Bulk error message: ",t):console.log("Get Connection Bulk unexpected error: ",t),R(t,o.GetConnectionBulkUrl())}return yield tt(e),e}))}var to=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function eo(){return to(this,arguments,void 0,(function*(t=[]){yield it(t);let e=[];for(let n=0;n<t.length;n++){let o=yield Et(t[n]);e.push(o)}return e}))}function no(){return to(this,arguments,void 0,(function*(t=[]){yield it(t);let e=[];for(let n=0;n<t.length;n++){let o=yield Vt(t[n]);e.push(o)}return e}))}function oo(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e),yield nt(t);let n=[];for(let e=0;e<t.length;e++){let o=yield Vt(t[e]);n.push(o)}return n}))}function io(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e),yield nt(t);let n={};for(let e=0;e<t.length;e++){let o=yield Vt(t[e]);n[t[e]]=o}return n}))}function ro(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e),yield nt(t);let n={};for(let e=0;e<t.length;e++){let o=yield Et(t[e]);n[t[e]]=o}return n}))}function co(t){return to(this,void 0,void 0,(function*(){let e=[],n=[],o={};for(let o=0;o<t.length;o++){let i=yield Z.GetConnection(t[o]);0==i.id?e.push(t[o]):n.push(i)}for(let e=0;e<t.length;e++)o[t[e]]=!1;let i=[],r=yield Yn(e);n=[...n,...r];for(let t=0;t<n.length;t++)i.push(n[t].ofTheConceptId),i.push(n[t].toTheConceptId);return yield X(i),n}))}function ao(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e);let n={};for(let e=0;e<t.length;e++){let o=yield Vt(t[e]);n[t[e]]=o}return n}))}function so(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e);let n={};for(let e=0;e<t.length;e++){let o=yield Et(t[e]);n[t[e]]=o}return n}))}function lo(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e);let n={};for(let e=0;e<t.length;e++){let o=yield Ot(t[e]);n[t[e]]=o}return n}))}var ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function uo(){return ho(this,arguments,void 0,(function*(t=0,e=[],n=""){let i=[];try{let r=new Kn;r.composition=t,r.listLinkers=e,r.textSearch=n;let c=JSON.stringify(r),a=G();const s=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:a,body:c});if(s.ok){const t=yield s.json();let e=t.compositionIds,n=t.internalConnections;t.externalConnections,i=yield oo(e,n)}else console.log("recursive search error ",s.status),L(s)}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),R(t,o.RecursiveSearchUrl())}return i}))}function fo(){return ho(this,arguments,void 0,(function*(t=0,e=[],n=""){try{let i=new Kn;i.composition=t,i.listLinkers=e,i.textSearch=n;let r=JSON.stringify(i),c=G();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),L(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),R(t,o.RecursiveSearchUrl())}}))}function yo(){return ho(this,arguments,void 0,(function*(t=0,e=[],n=""){try{let i=new Kn;i.composition=t,i.fullLinkers=e,i.textSearch=n;let r=JSON.stringify(i),c=G();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),L(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),R(t,o.RecursiveSearchUrl())}}))}function po(){return ho(this,arguments,void 0,(function*(t=0,e=[],n=""){try{let i=new Kn;i.composition=t,i.fullLinkers=e,i.textSearch=n;let r=JSON.stringify(i),c=G();const a=yield fetch(o.RecursiveSearchUrl(),{method:"POST",headers:c,body:r});if(a.ok){const t=yield a.json();return t.compositionIds,t.internalConnections,t.externalConnections,t}return console.log("recursive search error ",a.status),L(a),[]}catch(t){t instanceof Error?console.log("recursive search error message: ",t.message):console.log("recursive search unexpected error: ",t),R(t,o.RecursiveSearchUrl())}}))}var vo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function go(t,e){return vo(this,void 0,void 0,(function*(){try{let n={email:t,password:e},i=new Headers;i.append("Content-Type","application/json");let r=JSON.stringify(n);const c=yield fetch(o.LoginUrl(),{method:"POST",headers:i,body:r});if(c.ok){const t=yield c.json();return console.log(t.data),b.BearerAccessToken=t.data.token,console.log("this is the token",b.BearerAccessToken),t}console.log("Login tsccs error message: ",c.status),L(c)}catch(t){t instanceof Error?console.log("Login tsccs error message: ",t.message):console.log(" Login tsccs unexpected error: ",t),R(t,o.LoginUrl())}}))}var mo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Co(t){return mo(this,void 0,void 0,(function*(){const e=yield function(){return mo(this,arguments,void 0,(function*(t="",e={}){let n={message:"success",status:!1,statusCode:200,data:""};try{const o=yield fetch(t,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},redirect:"follow",referrerPolicy:"no-referrer",body:JSON.stringify(e)}),i=yield o.json();return o.ok?n={message:"success",status:!0,statusCode:200,data:i}:L(o),n}catch(e){console.log("Signup Error: ",e),R(e,t)}}))}(o.SignupUrl(),t);return e}))}function No(t){return mo(this,void 0,void 0,(function*(){const e=o.NODE_URL,n=yield fetch(`${e}/api/v1/entity/signup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(n.ok)return n.json();if(404===n.status)throw new Error("404, Not found");if(500===n.status)throw new Error("500, internal server error");throw new Error(n.status)}))}var To=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Io(t){return To(this,void 0,void 0,(function*(){const e=JSON.stringify({email:t.email,password:t.password});let n={message:"success",status:!1,statusCode:200,data:""};const i=new Headers;i.append("Content-Type","application/json");const r=o.LoginUrl();try{const t=yield fetch(r,{method:"POST",headers:i,body:e,redirect:"follow"}),o=yield t.json();return t.ok?n={message:"success",status:!0,statusCode:200,data:null==o?void 0:o.data}:L(t),n}catch(t){console.log("Sign in api error",t),R(t,r)}}))}function wo(t,e){return-1===t.indexOf(e)&&t.push(e),t}function ko(t=[],e){var n,o;let i=[],r=null===(n=e.type)||void 0===n?void 0:n.characterValue;if((null==r?void 0:r.startsWith("the_"))||(r="the_"+r),Array.isArray(t))for(let n=0;n<t.length;n++){let c=null===(o=t[n].type)||void 0===o?void 0:o.characterValue;(null==c?void 0:c.startsWith("the_"))||(c="the_"+c),e.typeId!=t[n].typeId&&r!=c||i.push(t[n])}return i}function Ao(t=[],e){let n=[],o=e.typeCharacter;if((null==o?void 0:o.startsWith("the_"))||(o="the_"+o),Array.isArray(t))for(let i=0;i<t.length;i++){let r=t[i].typeCharacter;(null==r?void 0:r.startsWith("the_"))||(r="the_"+r),e.typeId!=t[i].typeId&&o!=r||n.push(t[i])}return n}function xo(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function So(t=[],e){let n=[];if(Array.isArray(t)){const o=t.find((t=>t.toTheConceptId==e));o&&n.push(o);const i=t.find((t=>t.ofTheConceptId==e));i&&n.push(i)}return n}function Lo(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}function Ro(t=[],e){Array.isArray(t)&&t.splice(t.findIndex((function(t){return t.id===e.id})),1)}class bo{constructor(t,e,n,o){this.expiryTime=new Date(Date.now()+6e5),this.height=1,this.key=t,this.value=e,this.leftNode=n,this.rightNode=o}isValid(){const t=new Date(Date.now());return!(this.expiryTime<t&&(_o.removeNodeFromTree(this.key),1))}saveToCache(t){this.value.cached=t}addNode(t,e,n){if(null==e)return t;const o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return this.isValid(),t;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));const r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return this.isValid(),e}rightRotate(t){if(t){const e=t.leftNode;if(e){const n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){const e=t.rightNode;if(e){const n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key&&e.isValid()?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){const e=t.rightNode;return t=null,e}if(null==t.rightNode){const e=t.leftNode;return t=null,e}{const e=this.inOrderSuccessor(t.rightNode);return t.value=e.value,t.key=e.key,t.rightNode=this.removeNode(t.rightNode,e.key),t}}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var Go=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class _o{static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static addCompositionToTree(t){const e=new bo(t.id,t,null,null);this.addNodeToTree(e)}static getNodeFromTree(t){return Go(this,void 0,void 0,(function*(){return this.root?this.root.getFromNode(t,this.root):null}))}static removeNodeFromTree(t){return Go(this,void 0,void 0,(function*(){this.root&&(this.root=this.root.removeNode(this.root,t))}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}_o.root=null;var Bo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Po(t,e,n,o){return Bo(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c;let a={};const s=[];if(0==t)return"";let l=Uo(n,t);if(null!=l&&0!=l.id||null==t||null==t||(l=yield dn(t)),0!=l.id&&null==l.type){const t=l.typeId;let e=Uo(n,t);l.type=e,null==e&&null!=t&&null!=t&&(e=yield dn(t),l.type=e)}if(!o.includes(t))return null==l?void 0:l.characterValue;if(i.includes(t))return"";i.push(t);for(let l=0;l<e.length;l++)if(e[l].ofTheConceptId==t){const d=e[l].toTheConceptId;if(o.includes(t)){let t=Uo(n,d);if(null!=t&&0!=t.id||null==d||null==d||(t=yield dn(d)),0!=t.id&&null==(null==t?void 0:t.type)){const e=t.typeId;let n=yield k.GetConcept(e);t.type=n,null==n&&null!=e&&null!=e&&(n=yield dn(e),t.type=n)}const l="the_",h=(null!==(c=null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"").replace(l,"");if(isNaN(Number(h))){if(h){const t=yield Po(d,e,n,o,i);a[h]=t}}else{const t=yield Po(d,e,n,o,i);s[h]=t,a=s}}}return a}))}function Uo(t,e){let n=C();for(let o=0;o<t.length;o++)if(e==t[o].id)return n=t[o],n;return n}class Fo{constructor(){this.id=0,this.mainConcept=C(),this.connections=[],this.concepts=[],this.subcompositions=[],this.cached={}}updateCache(){return t=this,e=void 0,o=function*(){if(0==this.mainConcept.id)for(let t=0;t<this.concepts.length;t++)this.concepts[t].id==this.id&&(this.mainConcept=this.concepts[t]);this.cached=yield Po(this.id,this.connections,this.concepts,this.subcompositions,[])},new((n=void 0)||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}));var t,e,n,o}UpdateAcrossDistributedSystem(){var t,e;try{0!=this.id&&(e=null===(t=this.id)||void 0===t?void 0:t.toString(),o.MQTT_CONNECTION&&o.MQTT_CONNECTION.publish("compositionUpdate",e))}catch(t){console.log("Error while publishing message",t)}}isUpdating(){this.UpdateAcrossDistributedSystem()}GetDataCache(){var t,e,n;const o={};o[null!==(n=null===(e=null===(t=this.mainConcept)||void 0===t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:""]=this.cached;const i={};return i.data=o,i.id=this.id,i}}var Do=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Eo(t){return Do(this,arguments,void 0,(function*(t,e=null,n=null,o=null,i=null,r=null,c=null,a=null){const s=null!=i?i:999,l=null!=r?r:4,d=null!=c?c:999;let h=null!=o?o:0,u=C();null==a&&(a=new Fo);for(const o in t)if("object"==typeof t[o]||Array.isArray(t[o])){const f=yield _e(o,"",!0,s,l,d);if(null==e&&null==n){let e=h;u=f,e=f.id,h=f.id,a.concepts.push(f),a.id=f.id,yield Eo(t[o],f.id,f.userId,e,i,r,c,a)}else{const s=null!=e?e:999,l=null!=n?n:999,d=h;u=f,a.concepts.push(f);const y=yield Ce(s,l,f.id,d);a.connections.push(y),yield Eo(t[o],f.id,f.userId,d,i,r,c,a)}null!=t[o]&&null!=t[o]&&a.subcompositions.push(f.id)}else{const i=null!=e?e:999,r=null!=n?n:999,c=h,u=yield _e(o,t[o],!1,s,l,d);a.concepts.push(u);const f=yield Ce(i,r,u.id,c);a.connections.push(f)}return u}))}var Oo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Vo(t){return Oo(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=C(),a=C();const s=[];let l=t.compositionId;const d=t.ofTheCompositionId;let h=[];if(l<0){let t=yield dn(l,e);if(!(t.id>0))return null;l=t.id}i=yield _t(l);const u=[],f=new Fo,y=[];f.id=l,f.isUpdating();let p=[];for(let t=0;t<i.length;t++)wo(y,i[t].ofTheConceptId),wo(u,i[t].ofTheConceptId),wo(u,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);f.subcompositions=y,f.connections=i;for(let t=0;t<u.length;t++){const e=yield dn(u[t]);l==u[t]&&(c=e),d==u[t]&&(a=e),r.push(e)}const v=t.patchObject;for(const t in v){let i=C();const l=v[t];let d=c;if(a.id>0&&(d=a),Array.isArray(l)||"object"==typeof l){i=yield _e(t,"",!0,c.userId,4,999),f.subcompositions.push(i.id);const e=ko(r,i);for(let t=0;t<e.length;t++)if(e[t].id>0){const n=xo(f.connections,e[t].id);h=h.concat(n),s.push(e[t])}yield Eo(v[t],i.id,i.userId,c.id,c.userId,4,999,f)}else{i=yield _e(t,l,!1,e,o,n);const c=ko(r,i);for(let t=0;t<c.length;t++)if(c[t].id>0){const e=xo(f.connections,c[t].id);h=h.concat(e),s.push(c[t])}}const u=Ce(d.id,d.userId,i.id,c.id);r.push(i),f.connections.push(u)}for(let t=0;t<h.length;t++)Ro(f.connections,h[t]),sn(h[t].id);for(let t=0;t<s.length;t++)Lo(r,s[t]);return f.concepts=f.concepts.concat(r),f.mainConcept=c,f.id=c.id,yield f.updateCache(),_o.addCompositionToTree(f),me.SyncDataOnline(),f.GetDataCache()}))}var jo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Mo(t,e,n,i){return jo(this,arguments,void 0,(function*(t,e,n,i,r=10,c=1){var a=_("application/x-www-form-urlencoded",i),s=new URLSearchParams;s.append("type",t),s.append("search",e),s.append("composition",n),s.append("inpage",r.toString()),s.append("page",c.toString());const l=o.SearchCompositionsUrl()+"?"+s.toString();try{const t=yield fetch(l,{method:"GET",headers:a});return t.ok?yield t.json():(L(t),[])}catch(t){console.log("This is the searching error",t),R(t,l)}}))}var Ho=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Wo(t){return Ho(this,arguments,void 0,(function*(t,e=""){var n=_("application/json",e);const i=o.SearchLinkMultipleAll(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(console.log("This is the searching error",t.status),L(t),[])}catch(t){console.log("This is the searching error",t),R(t,i)}}))}var $o=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qo(t){return $o(this,arguments,void 0,(function*(t,e=[]){var n,o;let i=[];const r=[];let c={},a={};const s=yield _o.getNodeFromTree(t),l=[];let d=yield k.GetConcept(t);if(0==d.id&&null!=t&&null!=t&&(d=yield bt(t)),null==s){let s=[];s=e.length>0?Jo(t,e):yield _t(t),i=s;for(let t=0;t<i.length;t++)l.includes(i[t].ofTheConceptId)||(l.push(i[t].ofTheConceptId),r.push(i[t].ofTheConceptId)),r.includes(i[t].toTheConceptId)||r.push(i[t].toTheConceptId);Zo(d,i,r,l);let h=[];a=yield qt(t,i,l,h),c[null!==(o=null===(n=null==d?void 0:d.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a}else a=s.value.GetDataCache(),c=a;return 0==d.id?"":c}))}function Jo(t,e){const n=[];for(let o=0;o<e.length;o++)e[o].typeId==t&&n.push(e[o]);return n}function zo(t){return $o(this,arguments,void 0,(function*(t,e=[]){var n,o;let i={},r=[];const c=[];let a;const s={},l=yield _o.getNodeFromTree(t),d=[];let h=yield k.GetConcept(t);if(0==h.id&&null!=t&&null!=t&&(h=yield bt(t)),null==l){let l=[];l=e.length>0?Jo(t,e):yield _t(t),r=l;for(let t=0;t<r.length;t++)d.includes(r[t].ofTheConceptId)||(d.push(r[t].ofTheConceptId),c.push(r[t].ofTheConceptId)),c.includes(r[t].toTheConceptId)||c.push(r[t].toTheConceptId);Zo(h,r,c,d),a=yield qt(t,r,d),s[null!==(o=null===(n=null==h?void 0:h.type)||void 0===n?void 0:n.characterValue)&&void 0!==o?o:""]=a,i.created_at=h.entryTimeStamp,i.data=s,i.id=t}else a=l.value.GetDataCache(),i=a;return 0==h.id?"":i}))}function Qo(t,e){return $o(this,void 0,void 0,(function*(){let n=[];const o=[];n=yield Yn(e);for(let e=0;e<t.length;e++){const i=yield zo(t[e],n);i&&o.push(i)}return o}))}function Zo(t,e,n,i){return $o(this,void 0,void 0,(function*(){const r=new Fo,c=yield function(t){return $o(this,void 0,void 0,(function*(){let e=[];const n=[];for(let o=0;o<(null==t?void 0:t.length);o++){const i=yield k.GetConcept(t[o]);0==i.id?n.push(t[o]):e.push(i)}return 0==(null==n?void 0:n.length)||(e=yield function(t){return K(this,void 0,void 0,(function*(){const e=[];if(t.length>0){const n={"Content-Type":"application/json"};try{const i=yield fetch(o.GetConceptBulkUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){const t=yield i.json();if(t.length>0)for(let n=0;n<t.length;n++){const o=t[n];e.push(o),k.AddConcept(o)}}else console.log("bulk concept getter api error: ",i.status),L(i)}catch(t){t instanceof Error?console.log("bulk concept getter api error: ",t.message):console.log("bulk concept getter api error: ",t),R(t,o.GetConceptBulkUrl())}}return e}))}(n)),e}))}(n);r.connections=e,r.concepts=c,r.id=t.id,r.subcompositions=i,r.mainConcept=t;const a=yield Po(t.id,e,c,i,[]);r.cached=a,_o.addCompositionToTree(r)}))}var Ko=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Xo(t){return Ko(this,void 0,void 0,(function*(){try{var e=G();const n=JSON.stringify(t),i=yield fetch(o.CreateSessionId(),{method:"POST",headers:e,body:n});return i.ok?i.json():(console.log("Creating session failed",yield i.json()),L(i),null)}catch(t){console.log("Creating session failed",t),R(t,o.CreateSessionId())}}))}var Yo=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ti(t,e){return Yo(this,void 0,void 0,(function*(){try{var n=G("application/x-www-form-urlencoded");const i=new URLSearchParams;i.append("sessionId",t.toString()),i.append("url",e);const r=yield fetch(o.CreateSessionVisitUrl(),{method:"POST",headers:n,body:i});return r.ok?r.json():(console.log("Creating session url failed",yield r.json()),L(r),null)}catch(t){console.log("Creating session url failed",t),R(t,o.CreateSessionVisitUrl())}}))}var ei=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function ni(t,e){return ei(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=[],r=yield dn(t),c=yield Un(e);if(c.id>0){let t=yield Ye(c.id,r.id,r.userId,n,o),e=[];for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);yield it(e);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield dn(n),r=yield Mt(o.id);i.push(r)}}return i}))}function oi(t,e){return ei(this,arguments,void 0,(function*(t,e,n=10,o=1){let i=[],r=yield dn(t),c=yield Un(e);if(c.id>0){let t=yield Ye(c.id,r.id,r.userId,n,o),e=[];for(let n=0;n<t.length;n++)e.push(t[n].toTheConceptId);for(let e=0;e<t.length;e++){let n=t[e].toTheConceptId,o=yield dn(n);i.push(o)}}return i}))}class ii{constructor(t,e,n,o){this.value=[],this.height=1,this.key=t,this.value.push(e),this.leftNode=n,this.rightNode=o}addNode(t,e,n){if(null==e)return t;var o=e.leftNode,i=e.rightNode;if(e.key>t.key)e.leftNode=this.addNode(t,o,n);else{if(!(e.key<t.key))return e.value.push(...t.value),e;e.rightNode=this.addNode(t,i,n)}e.height=1+Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode));let r=this.getBalanceFactor(e);if(r>1&&e.leftNode){if(t.key<e.leftNode.key)return this.rightRotate(e);if(t.key>e.leftNode.key)return e.leftNode=this.leftRotate(e.leftNode),this.rightRotate(e)}if(r<-1&&e.rightNode){if(t.key>e.rightNode.key)return this.leftRotate(e);if(t.key<e.rightNode.key)return e.rightNode=this.rightRotate(e.rightNode),this.leftRotate(e)}return e}rightRotate(t){if(t){let e=t.leftNode;if(e){let n=e.rightNode;return t.leftNode=n,e.rightNode=t,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode))+1,e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(e.rightNode))+1,e}}return t}leftRotate(t){if(t){let e=t.rightNode;if(e){let n=e.leftNode;return e.leftNode=t,t.rightNode=n,t.height=Math.max(this.getHeight(t.leftNode),this.getHeight(t.rightNode)+1),e.height=Math.max(this.getHeight(e.leftNode),this.getHeight(t.rightNode)+1),e}}return t}getHeight(t){return t?t.height:0}getBalanceFactor(t){return null==t?0:this.getHeight(t.leftNode)-this.getHeight(t.rightNode)}getFromNode(t,e){return e?t==e.key?e:t<e.key?this.getFromNode(t,e.leftNode):t>e.key?this.getFromNode(t,e.rightNode):e:e}removeNode(t,e){if(null==t)return t;if(t.key>e)return t.leftNode=this.removeNode(t.leftNode,e),t;if(t.key<e)return t.rightNode=this.removeNode(t.rightNode,e),t;if(null==t.leftNode){let e=t.rightNode;return t=null,e}if(null==t.rightNode){let e=t.leftNode;return t=null,e}var n=this.inOrderSuccessor(t.rightNode);return t.value=n.value,t.key=n.key,t.rightNode=this.removeNode(t.rightNode,n.key),t}countNodeBelow(t){return null==t?0:1+this.countNodeBelow(t.leftNode)+this.countNodeBelow(t.rightNode)}inOrderSuccessor(t){for(;null!=t.leftNode;)t=t.leftNode;return t}}var ri=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ci{static compositeKey(t,e){return("0000"+t.toString(16).toUpperCase()).slice(-4)+("0000"+e.toString(16).toUpperCase()).slice(-4)}static addNodeToTree(t){if(null==this.root)return this.root=t,this.root;this.root=this.root.addNode(t,this.root,this.root.height)}static waitForDataToLoad(){return ri(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{this.checkFlag(t),setTimeout((()=>{e("not")}),25e3)}))}))}static checkFlag(t){if(u.isDataLoaded)return t("done");setTimeout(ci.checkFlag,1e3,t)}static addConceptToTree(t,e,n=999){let o=this.compositeKey(e,n);var i=new ii(o,t,null,null);this.addNodeToTree(i)}static getNodeFromTree(t,e){return ri(this,void 0,void 0,(function*(){try{yield this.waitForDataToLoad()}catch(t){return null}let n=this.compositeKey(t,e);return this.root?this.root.getFromNode(n,this.root):null}))}static removeNodeFromTree(t){return ri(this,arguments,void 0,(function*(t,e=999){if(this.root){let n=this.compositeKey(t,e);this.root=this.root.removeNode(this.root,n)}}))}static countNumberOfNodes(){return this.root?this.root.countNodeBelow(this.root):0}}ci.root=null;var ai=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function si(t,e){return ai(this,arguments,void 0,(function*(t,e,n=999){let o=yield ci.getNodeFromTree(t,n);console.log("this is the ghost id",t,n);let i=Nt();if(o)for(let t=0;t<o.value.length;t++){let n=o.value[t];n.ghostId==e&&(i=n)}return i}))}function li(t,e){return ai(this,arguments,void 0,(function*(t,e,n=999){ci.addConceptToTree(t,e,n)}))}const di=1,hi=2,ui=3,fi=4,yi=5,pi=6,vi=7;var gi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},mi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ci(t,e){return mi(this,arguments,void 0,(function*(t,e,n=""){let o=yield nr(t,e,n),i=o.compositionIds,r=o.internalConnections,c=o.linkers,a=o.reverse,s=o.mainCompositionIds,l=yield co(c),d=yield so(i,r);return yield ki(l,d,s,a)}))}function Ni(t,e,n,o,i){return mi(this,void 0,void 0,(function*(){let r=yield co(t),c=yield lo(e,n);return yield ki(r,c,o,i)}))}var Ti=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ii(t){return Ti(this,arguments,void 0,(function*(t,e="",n=null,o=hi){var i,r,c,a,s,l,d,h;let u=[],f=[],y=[],p=[],v=t[0].composition,g={},m={};try{(null==n?void 0:n.isDataLoaded)?(g.compositionIds=null===(i=n.conceptIds)||void 0===i?void 0:i.slice(),g.internalConnections=null===(r=n.internalConnections)||void 0===r?void 0:r.slice(),g.linkers=null===(c=n.linkers)||void 0===c?void 0:c.slice(),g.reverse=null===(a=n.reverse)||void 0===a?void 0:a.slice(),m=g,u=m.compositionIds,y=m.internalConnections,f=m.linkers,p=m.reverse):(g=yield U(t,e),n&&(n.conceptIds=null===(s=g.compositionIds)||void 0===s?void 0:s.slice(),n.internalConnections=null===(l=g.internalConnections)||void 0===l?void 0:l.slice(),n.linkers=null===(d=g.linkers)||void 0===d?void 0:d.slice(),n.reverse=null===(h=g.reverse)||void 0===h?void 0:h.slice(),n.isDataLoaded=!0),m=g,u=m.compositionIds,y=m.internalConnections,f=m.linkers,p=m.reverse);let C=yield function(t,e,n,o,i,r){return Ti(this,arguments,void 0,(function*(t,e,n,o,i,r,c=hi){(new Date).getTime();let a,s,l=yield co(t);return c==ui?(a=yield so(e,n),s=yield Ai(t,a,i,o)):c==di?(a=yield lo(e,n),s=yield Ai(t,a,i,o)):100==c?(a=yield function(){return to(this,arguments,void 0,(function*(t=[],e=[]){yield Yn(e);let n={};for(let e=0;e<t.length;e++){let o=yield jt(t[e]);n[t[e]]=o}return n}))}(e,n),s=yield wi(l,a,i,o)):c==vi?s=yield Ni(t,e,n,r.ofCompositions,o):(a=yield ao(e,n),s=yield wi(l,a,i,o)),s}))}(f,u,y,p,v,t[0],o);return C}catch(t){throw console.log("this is the error in the search link multiple",t),t}}))}function wi(t,e,n){return Ti(this,arguments,void 0,(function*(t,e,n,o=[]){(new Date).getTime();let i={},r=[];for(let e=0;e<t.length;e++)r.push(t[e].toTheConceptId),r.push(t[e].ofTheConceptId),r.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let i=!1;if(o.includes(t[n].id)&&(i=!0),1==i){if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].toTheConceptId],i=yield dn(t[n].typeId),r=null==o?void 0:o.data,c=Object.keys(r)[0];try{let o=i.characterValue+"_reverse";"string"==typeof r&&(r={}),Array.isArray(r[c][o])||("string"==typeof r[c]&&(r[c]={}),r[c][o]=[]),r[c][o].push(e[t[n].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].ofTheConceptId],i=yield dn(t[n].typeId),r=null==o?void 0:o.data,c=Object.keys(r)[0];try{"string"==typeof r&&(r={}),Array.isArray(r[c][i.characterValue])||("string"==typeof r[c]&&(r[c]={}),r[c][i.characterValue]=[]),r[c][i.characterValue].push(e[t[n].toTheConceptId])}catch(t){console.log("this is error",t)}}}return i=e[n],i}))}function ki(t,e,n){return Ti(this,arguments,void 0,(function*(t,e,n,o=[]){let i=[],r=[];for(let e=0;e<t.length;e++)r.push(t[e].toTheConceptId),r.push(t[e].ofTheConceptId),r.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let i=!1;if(o.includes(t[n].id)&&(i=!0),1==i){if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].toTheConceptId],i=yield dn(t[n].typeId),r=Object.keys(o)[0];try{let c=i.characterValue+"_reverse";"string"==typeof o&&(o={}),Array.isArray(o[r][c])||("string"==typeof o[r]&&(o[r]={}),o[r][c]=[]),o[r][c].push(e[t[n].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].ofTheConceptId],i=yield dn(t[n].typeId),r=Object.keys(o)[0];try{"string"==typeof o&&(o={}),Array.isArray(o[r][i.characterValue])||("string"==typeof o[r]&&(o[r]={}),o[r][i.characterValue]=[]),o[r][i.characterValue].push(e[t[n].toTheConceptId])}catch(t){console.log("this is error",t)}}}for(let t=0;t<n.length;t++){let o=e[n[t]];i.push(o)}return i}))}function Ai(t,e,n){return Ti(this,arguments,void 0,(function*(t,e,n,o=[]){let i={},r=yield Yn(t),c=[];for(let t=0;t<r.length;t++)c.push(r[t].toTheConceptId),c.push(r[t].ofTheConceptId),c.push(r[t].typeId);yield X(c),r.sort((function(t,e){return e.id-t.id}));for(let t=0;t<r.length;t++){let n=!1;if(o.includes(r[t].id)&&(n=!0),1==n){if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].toTheConceptId],o=yield dn(r[t].typeId),i=n,c=Object.keys(i)[0];try{let n=o.characterValue+"_reverse";"string"==typeof i&&(i={}),Array.isArray(i[c][n])||("string"==typeof i[c]&&(i[c]={}),i[c][n]=[]),i[c][n].push(e[r[t].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[r[t].ofTheConceptId]&&e[r[t].toTheConceptId]){let n=e[r[t].ofTheConceptId],o=yield dn(r[t].typeId),i=n,c=Object.keys(i)[0];try{"string"==typeof i&&(i={}),Array.isArray(i[c][o.characterValue])||("string"==typeof i[c]&&(i[c]={}),i[c][o.characterValue]=[]),i[c][o.characterValue].push(e[r[t].toTheConceptId])}catch(t){console.log("this is error",t)}}}return i=e[n],i}))}function xi(t){var e,n;const o=Nt();return o.id=t.id,o.ghostId=t.ghostId,o.userId=t.userId,o.accessId=t.accessId,o.categoryId=t.categoryId,o.characterValue=t.characterValue,o.entryTimeStamp=t.entryTimeStamp,o.typeId=t.typeId,o.type=t.type,o.isTemp=!1,o.typeCharacter=null!==(n=null===(e=null==t?void 0:t.type)||void 0===e?void 0:e.characterValue)&&void 0!==n?n:"",o}function Si(t){const e=C();return e.id=t.id,e.ghostId=t.ghostId,e.userId=t.userId,e.accessId=t.accessId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.categoryId=t.categoryId,e}function Li(t){const e=new O(0,0,0,0,0,0,0);return e.id=t.id,e.ghostId=t.ghostId,e.accessId=t.accessId,e.ofTheConceptId=t.ofTheConceptId,e.toTheConceptId=t.toTheConceptId,e.entryTimeStamp=t.entryTimeStamp,e.typeId=t.typeId,e.isTemp=!1,e}var Ri=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function bi(t){return Ri(this,void 0,void 0,(function*(){try{let e=Nt();if(t<0){if(e=yield Lt.GetConcept(t),0==e.id){let n=yield It.getNodeFromTree(t);if(null==n?void 0:n.value){let t=n.value;t&&(e=t)}}}else e=xi(yield dn(t));return e}catch(t){throw t}}))}var Gi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _i(t){return Gi(this,void 0,void 0,(function*(){const e=t.userId,n=t.sessionId,o=t.accessId;let i=[];const r=[];let c=Nt(),a=Nt();const s=[],l=t.compositionId,d=t.ofTheCompositionId;let h=[],u=yield _t(l);for(let t=0;t<u.length;t++)i.push(Li(u[t]));const f=[],y=[];let p=[];for(let t=0;t<i.length;t++)wo(y,i[t].ofTheConceptId),wo(f,i[t].ofTheConceptId),wo(f,i[t].toTheConceptId),p.push(i[t].ofTheConceptId);for(let t=0;t<f.length;t++){const e=yield dn(f[t]);l==f[t]&&(c=xi(e)),d==f[t]&&(a=xi(e)),r.push(xi(e))}const v=t.patchObject;for(const t in v){let l=Nt();const d=v[t];let u=c;a.id>0&&(u=a),Array.isArray(d)||"object"==typeof d?(l=yield Qe(t,"",!0,c.userId,4,999),yield Ke(v[t],l.id,l.userId,c.id,c.userId,4,999)):l=yield Qe(t,d,!1,e,o,n);const f=Ao(r,l);for(let t=0;t<f.length;t++)if(f[t].id>0){const e=So(i,f[t].id);h=h.concat(e),s.push(f[t])}yield Me(u.id,l.id,c.id,2),r.push(l)}for(let t=0;t<h.length;t++)yield sn(h[t].id);yield kt.SyncDataOnline()}))}var Bi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Pi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ui(t,e,n){return Pi(this,void 0,void 0,(function*(){try{let n=yield te(e),o=[];0!=n.id&&(o=yield function(t,e){return Bi(this,void 0,void 0,(function*(){try{return yield xt.GetConnectionOfCompositionAndTypeLocal(e,t)}catch(t){throw t}}))}(t,n.id));let i=[];for(let t=0;t<o.length;t++){let e=yield le(o[t].toTheConceptId);i.push(e)}return i}catch(t){throw t}}))}var Fi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Di(t){return Fi(this,void 0,void 0,(function*(){let e=[];try{var n=G();const i=yield fetch(o.ViewInternalDataUrl(),{method:"POST",headers:n,body:JSON.stringify(t)});if(i.ok){let t=yield i.json(),n={};for(let o=0;o<t.length;o++){let i=t[o].concepts;e=t[o].connections;let r=t[o].id;X(i),n[r]=e}return n}return console.log("View Internal Data error",i.status),L(i),e}catch(t){throw t instanceof Error?console.log(" This is the view internal data error message: ",t.message):console.log(" This is the view internal data unexpected error: ",t),t}}))}var Ei=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Oi(t){return Ei(this,void 0,void 0,(function*(){var e;try{let n=yield Di(t),o=[];for(let i=0;i<t.length;i++){let r=t[i],c=n[r];if(r&&c){let t=[],e={};for(let e=0;e<c.length;e++)t.includes(c[e].ofTheConceptId)||t.push(c[e].ofTheConceptId);let n=yield qt(r,c,t);e.data=n,e.id=r,o.push(e)}else{let t={};t.id=r;let n=yield dn(r),i={};n.type&&(i[null===(e=null==n?void 0:n.type)||void 0===e?void 0:e.characterValue]=n.characterValue,t.data=i,o.push(t))}}return o}catch(t){throw t}}))}var Vi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},ji=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Mi(t){return ji(this,arguments,void 0,(function*(t,e=""){try{let n=yield function(t){return Vi(this,arguments,void 0,(function*(t,e=""){var n=_("application/json",e);let i=o.SearchInternalWithAuthenticatedCcsUrl();i=i+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(i,{method:"GET",headers:n});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),L(t),[])}catch(t){console.log("This is the searching internal error",t),R(t,i)}}))}(t,e);return yield Oi(n)}catch(t){throw t}}))}function Hi(t){return ji(this,arguments,void 0,(function*(t,e=""){try{return yield function(t){return Vi(this,void 0,void 0,(function*(){var e=_("application/json","");let n=o.SearchInternalWithCcsUrl();n=n+"?composition="+t.composition+"&search="+t.search+"&internalComposition="+t.internalComposition+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;try{const t=yield fetch(n,{method:"GET",headers:e});return t.ok?yield t.json():(console.log("This is the searching internal error",t.status),L(t),[])}catch(t){console.log("This is the searching internal error",t),R(t,n)}}))}(t)}catch(t){throw t}}))}var Wi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function $i(t,e,n){return Wi(this,arguments,void 0,(function*(t,e,n,o=!1){var i,r;try{if(t.userId,o){let o=(null===(i=e.type)||void 0===i?void 0:i.characterValue)+"_s_"+n+"_by";var c=yield Qe("connection",o,!1,999,999,999);yield Me(e.id,t.id,c.id,1e3)}let s=(null===(r=t.type)||void 0===r?void 0:r.characterValue)+"_s_"+n+"_s";var a=yield Qe("connection",s,!1,999,999,999);return yield Me(t.id,e.id,a.id,1e3)}catch(t){throw t}}))}var qi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Ji(t){return qi(this,void 0,void 0,(function*(){let e=yield bi(t);Lt.RemoveConcept(e)}))}var zi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Qi=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Zi(t,e,n,i){return Qi(this,arguments,void 0,(function*(t,e,n,i,r=!0){var c,a;let s=C();if(""!=n){let o="";o=r?(null===(c=t.type)||void 0===c?void 0:c.characterValue)+"_s_"+n+"_s":(null===(a=e.type)||void 0===a?void 0:a.characterValue)+"_s_"+n+"_by",s=yield _e("connection",o,!1,999)}""!=i&&(s=yield Dn(i));let l=yield function(t,e,n){return zi(this,void 0,void 0,(function*(){var i=[];try{var r=new FormData;r.append("ofConceptId",t.toString()),r.append("mainKey",n.toString()),r.append("toConceptId",e.toString());const a=yield fetch(o.GetCompositionConnectionBetweenTwoConceptsUrl(),{method:"POST",body:r,redirect:"follow"});if(a.ok){const t=yield a.json();for(var c=0;c<t.length;c++)Z.AddConnection(t[c]),i.push(t[c])}else console.log("Get composition connection between two concepts",a.status),L(a)}catch(t){t instanceof Error?console.log("Get composition connection between two concepts error message: ",t.message):console.log("Get composition connection between two concepts unexpected error: ",t),R(t,o.GetCompositionConnectionBetweenTwoConceptsUrl())}return i}))}(t.id,e.id,s.id);return l}))}function Ki(t,e){return new Promise(((n,o)=>{setTimeout((()=>{n(e)}),t)}))}const Xi=3,Yi=4,tr=5;var er=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function nr(t,e){return er(this,arguments,void 0,(function*(t,e,n=""){let i=o.SearchAllTypeWithLinker(t.auth);var r=_("application/json",n);i=i+"?search="+t.search+"&type="+t.type+"&inpage="+t.inpage+"&page="+t.page;const c=JSON.stringify(e);try{const t=yield fetch(i,{method:"POST",headers:r,body:c});return t.ok?yield t.json():(L(t),console.log("This is the searching multiple error",t.status),[])}catch(t){console.log("This is the searching SearchWithTypeAndLinker error",t),R(t,i)}}))}var or=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class ir{constructor(){this.subscribers=[],this.mainConcept=0,this.compositionIds=[],this.conceptIds=[],this.internalConnections=[],this.reverse=[],this.linkers=[],this.dependency=[],this.isDataLoaded=!1,this.isUpdating=!1,this.fetched=!1,this.format=di}listenToEventType(t){window.addEventListener(`${t}`,(t=>{if(this.isUpdating)console.log("rejected this");else{this.isUpdating=!0;let e=this;setTimeout((function(){return or(this,void 0,void 0,(function*(){let n=t;e.compositionIds.includes(null==n?void 0:n.detail)||(e.compositionIds.unshift(null==n?void 0:n.detail),e.listenToEvent(null==n?void 0:n.detail)),e.isUpdating=!1,yield e.bind(),e.notify()}))}),200)}}))}listenToEvent(t){window.addEventListener(`${t}`,(e=>{if(this.isUpdating)console.log("rejected this");else{this.isUpdating=!0;let e=this;setTimeout((function(){return or(this,void 0,void 0,(function*(){let n=yield Z.GetConnectionByOfTheConceptAndType(t,t);for(let t=0;t<n.length;t++)yield Z.GetConnection(n[t]).then((t=>{t.typeId==e.mainConcept?e.internalConnections.includes(t.id)||e.internalConnections.push(t.id):e.linkers.includes(t.id)||e.linkers.push(t.id),e.conceptIds.includes(t.toTheConceptId)||e.conceptIds.push(t.toTheConceptId),e.compositionIds.includes(t.ofTheConceptId)||e.compositionIds.push(t.ofTheConceptId)}));e.isUpdating=!1,yield e.bind(),e.notify()}))}),200)}}))}listenToEventConnectionType(t,e){window.addEventListener(`${t}`,(n=>{if(this.isUpdating)console.log("rejected this");else{this.isUpdating=!0;let n=this;setTimeout((function(){return or(this,void 0,void 0,(function*(){let o=yield Z.GetConnectionByOfTheConceptAndType(t,t);for(let t=0;t<o.length;t++)o.typeId==e&&(yield Z.GetConnection(o[t]).then((t=>{t.typeId==n.mainConcept?n.internalConnections.includes(t.id)||n.internalConnections.push(t.id):n.linkers.includes(t.id)||n.linkers.push(t.id),n.conceptIds.includes(t.toTheConceptId)||n.conceptIds.push(t.toTheConceptId),n.compositionIds.includes(t.ofTheConceptId)||n.compositionIds.push(t.ofTheConceptId)})));n.isUpdating=!1,yield n.bind(),n.notify()}))}),200)}}))}bind(){return or(this,void 0,void 0,(function*(){console.log("this is the old execute data")}))}subscribe(t){return or(this,void 0,void 0,(function*(){return this.subscribers.push(t),console.log("again executing data"),yield this.bind(),t(this.data)}))}unsubscribe(t){return this.subscribers.filter((e=>e!=t)),this.subscribers.length}notify(){console.log("notifiers",this.subscribers),this.subscribers.map((t=>{console.log("notify"),t(this.data)}))}}class rr extends ir{constructor(t,e,n=hi){super(),this.searchQuery=[],this.format=hi,this.searchQuery=t,this.format=n}bind(){return t=this,e=void 0,o=function*(){return this.data=yield Ii(this.searchQuery,"",this,this.format),this.mainConcept=this.searchQuery[0].composition,this.listenToEvent(this.mainConcept),console.log("this is the data",this.data),this.data},new((n=void 0)||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}));var t,e,n,o}}function cr(t,e,n=hi){return new rr(t,null!=e?e:"",n)}var ar=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class sr extends ir{constructor(t,e=ui){super(),this.id=t,this.format=e}bind(){return ar(this,void 0,void 0,(function*(){if(!this.isDataLoaded){let t=yield function(t){return Pt(this,void 0,void 0,(function*(){let e=[];e=yield _t(t);let n=[];for(let t=0;t<e.length;t++)n.includes(e[t].ofTheConceptId)||n.push(e[t].ofTheConceptId);return{connectionList:e,compositionList:n}}))}(this.id);this.mainConcept=this.id,this.compositionIds=t.compositionList;let e=t.connectionList;for(let t=0;t<e.length;t++)this.internalConnections.push(e[t].id);this.isDataLoaded=!0,this.listenToEvent(this.mainConcept)}return yield this.build()}))}build(){return ar(this,void 0,void 0,(function*(){let t=[],e=this.internalConnections;for(let n=0;n<e.length;n++)t.push(yield Z.GetConnection(e[n]));return this.format==ui?(console.log("this is the data for the build layer",t,this.mainConcept,this.internalConnections,this.compositionIds),this.data=yield Ut(this.mainConcept,t,this.compositionIds)):this.format==hi?this.data=yield function(t,e,n){return Pt(this,void 0,void 0,(function*(){var o,i;let r={},c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield qt(t,e,n);r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a;let s={};return s.created_at=c.entryTimeStamp,s.data=r,s.id=t,s}))}(this.mainConcept,t,this.compositionIds):this.format==di?this.data=yield function(t,e,n){return Pt(this,void 0,void 0,(function*(){var o,i;let r={},c=yield k.GetConcept(t);0==c.id&&null!=t&&null!=t&&(c=yield bt(t));let a=yield $t(c,e,n);return r[null!==(i=null===(o=null==c?void 0:c.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:""]=a,r}))}(this.mainConcept,t,this.compositionIds):this.data=yield Ut(this.mainConcept,t,this.compositionIds),this.data}))}}function lr(t,e=ui){return new sr(t,e)}var dr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class hr extends ir{constructor(t,e,n,o,i){super(),this.data=[],this.startPage=0,this.compositionName=t,this.userId=e,this.inpage=n,this.page=o,this.format=i}bind(){return dr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){console.log("again data loading mechanism");var t=yield Kt(this.compositionName);if(t){yield E(this.compositionName,this.userId),console.log("getting the user data",t.id,this.userId);let o=yield k.GetConceptsByTypeIdAndUser(t.id,this.userId);console.log("this is the concept list",o);for(var e=this.inpage*(this.page-1),n=e;n<e+this.inpage;n++)o[n]&&this.compositionIds.push(o[n].id)}yield it(this.compositionIds),this.isDataLoaded=!0,this.listenToEventType(t.id);for(let t=0;t<this.compositionIds.length;t++)console.log("list listen",this.compositionIds[t]),this.listenToEvent(this.compositionIds[t])}return yield this.build()}))}build(){return dr(this,void 0,void 0,(function*(){if(this.data=[],console.log("this is building the data list"),this.format==ui){for(let t=this.startPage;t<this.startPage+this.inpage;t++)if(this.compositionIds[t]){let e=yield Et(this.compositionIds[t]);this.data.push(e)}}else if(this.format==hi){for(let t=this.startPage;t<this.startPage+this.inpage;t++)if(this.compositionIds[t]){let e=yield Vt(this.compositionIds[t]);this.data.push(e)}}else if(this.format==di){for(let t=this.startPage;t<this.startPage+this.inpage;t++)if(this.compositionIds[t]){let e=yield Ot(this.compositionIds[t]);this.data.push(e)}}else for(let t=this.startPage;t<this.startPage+this.inpage;t++)if(this.compositionIds[t]){let e=yield Et(this.compositionIds[t]);this.data.push(e)}return this.data}))}}function ur(t,e,n,o,i=ui){return new hr(t,e,n,o,i)}var fr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class yr extends ir{constructor(t,e,n,o,i){super(),this.connections=[],this.data=[],this.mainConcept=t,this.linker=e,this.inpage=n,this.page=o,this.format=i}bind(){return fr(this,void 0,void 0,(function*(){var t;if(!this.isDataLoaded){let o=yield dn(this.mainConcept),i=(null===(t=o.type)||void 0===t?void 0:t.characterValue)+"_s_"+this.linker,r=yield Ie(i,16);if(r.id>0){let t=yield Ye(r.id,o.id,o.userId,this.inpage,this.page);this.connections=t;for(var e=[],n=0;n<this.connections.length;n++)e.push(this.connections[n].toTheConceptId),this.listenToEvent(this.connections[n].toTheConceptId);yield it(e)}this.isDataLoaded=!0,this.listenToEvent(this.mainConcept)}return yield this.build()}))}build(){return fr(this,void 0,void 0,(function*(){this.connections=yield Yn(this.linkers);for(var t=0;t<this.connections.length;t++){let e=this.connections[t].toTheConceptId,n=yield dn(e);if(console.log("this is the format",this.format),this.format==di){let t=yield Vt(n.id);this.data.push(t)}else if(this.format==ui){let t=yield Et(n.id);this.data.push(t)}else if(this.format==fi){let t=yield Mt(n.id);this.data.push(t)}else{let t=yield Mt(n.id);this.data.push(t)}}return this.data}))}}function pr(t,e,n,o,i=di){return new yr(t,e,n,o,i)}var vr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class gr extends ir{constructor(t,e,n="",o){super(),this.searchText="",this.connections=[],this.externalConnectionIds=[],this.data=[],this.mainConcept=t,this.searchLinkers=e,this.textSearch=n,o&&(this.format=o)}bind(){return vr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){this.isDataLoaded=!0;const t=yield fo(this.mainConcept,this.searchLinkers,this.textSearch);this.compositionIds=t.compositionIds||[],this.internalConnections=t.internalConnections||[],this.externalConnectionIds=t.externalConnections||[],this.connections=yield Yn(this.externalConnectionIds);for(let t=0;t<this.compositionIds.length;t++)this.listenToEvent(this.compositionIds[t])}return yield this.build()}))}build(){return vr(this,void 0,void 0,(function*(){return this.format&&this.format==yi?this.data={compositionIds:this.compositionIds,internalConnections:this.internalConnections,externalConnections:this.externalConnectionIds}:this.data=yield oo(this.compositionIds,this.internalConnections),this.data}))}}function mr(t,e,n="",o){return new gr(t,e,n,o)}var Cr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Nr extends ir{constructor(t,e,n,o=hi){super(),this.searchQuery=[],this.format=hi,this.mainCompositionIds=[],this.searchCharacter="",this.token="",this.searchStructure=t,this.searchQuery=e,this.searchQuery[0].type=t.composition,this.searchCharacter=t.composition,this.format=o,this.token=b.BearerAccessToken}listenToEventType(t){window.addEventListener(`${t}`,(t=>{if(this.isUpdating)console.log("rejected this");else{this.isUpdating=!0;let e=this;setTimeout((function(){return Cr(this,void 0,void 0,(function*(){let n=t;e.mainCompositionIds.includes(null==n?void 0:n.detail)||(e.mainCompositionIds.unshift(null==n?void 0:n.detail),e.conceptIds.push(null==n?void 0:n.detail),e.listenToEvent(null==n?void 0:n.detail),Z.GetConnectionsOfConcept(null==n?void 0:n.detail).then((t=>{for(let n=0;n<t.length;n++)e.linkers.push(t[n].id)}))),e.isUpdating=!1,yield e.bind(),e.notify()}))}),200)}}))}bind(){return Cr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){this.isDataLoaded=!0;var t=yield Kt(this.searchCharacter);let e=yield nr(this.searchStructure,this.searchQuery,this.token);this.conceptIds=e.compositionIds,this.internalConnections=e.internalConnections,this.linkers=e.linkers,this.reverse=e.reverse,this.mainCompositionIds=e.mainCompositionIds,this.listenToEventType(t.id);for(let t=0;t<this.mainCompositionIds.length;t++)this.listenToEvent(this.mainCompositionIds[t])}return yield this.build()}))}build(){return Cr(this,void 0,void 0,(function*(){return yield X(this.conceptIds),this.format==hi?this.data=yield function(t,e,n,o,i){return mi(this,void 0,void 0,(function*(){let r=yield co(t),c=yield ao(e,n),a=yield function(t,e,n,o){return Ti(this,arguments,void 0,(function*(t,e,n,o,i=[]){(new Date).getTime();let r=[],c=[];for(let e=0;e<t.length;e++)c.push(t[e].toTheConceptId),c.push(t[e].ofTheConceptId),c.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1;if(i.includes(t[n].id)&&(o=!0),1==o){if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].toTheConceptId],i=yield dn(t[n].typeId),r=null==o?void 0:o.data,c=Object.keys(r)[0];try{let o=i.characterValue+"_reverse";"string"==typeof r&&(r={}),Array.isArray(r[c][o])||("string"==typeof r[c]&&(r[c]={}),r[c][o]=[]),r[c][o].push(e[t[n].ofTheConceptId])}catch(t){console.log("this is error",t)}}}else if(e[t[n].ofTheConceptId]&&e[t[n].toTheConceptId]){let o=e[t[n].ofTheConceptId],i=yield dn(t[n].typeId),r=null==o?void 0:o.data,c=Object.keys(r)[0];try{"string"==typeof r&&(r={}),Array.isArray(r[c][i.characterValue])||("string"==typeof r[c]&&(r[c]={}),r[c][i.characterValue]=[]),r[c][i.characterValue].push(e[t[n].toTheConceptId])}catch(t){console.log("this is error",t)}}}for(let t=0;t<o.length;t++){let n=e[o[t]];r.push(n)}return r}))}(r,c,e,o,i);return a}))}(this.linkers,this.conceptIds,this.internalConnections,this.mainCompositionIds,this.reverse):this.data=yield Ni(this.linkers,this.conceptIds,this.internalConnections,this.mainCompositionIds,this.reverse),this.data}))}}function Tr(t,e,n,o=hi){return new Nr(t,e,n,o)}class Ir{constructor(t,e,n,i,r,c,a,s=!1,l,d,h){this.structureType="lconcept",this.isComposition=!1,this.isTemp=!1,this.isSynced=!1,this.applicationId=o.BASE_RANDOMIZER,this.id=t,this.userId=e,this.typeId=n,this.ghostId=t,this.categoryId=i,this.characterValue=c,this.accessId=r,this.type=null,this.isNew=s,this.typeCharacter=a,this.entryTimeStamp=l,this.updatedTimeStamp=d,this.isSynced=!1,this.referentId=h}getType(){console.log(this.typeId)}}class wr{constructor(t,e,n,i,r,c){this.isTemp=!1,this.applicationId=o.BASE_RANDOMIZER,this.type=C(),this.id=t,this.ofTheConceptId=e,this.toTheConceptId=n,this.typeId=i,this.ghostId=t,this.orderId=r,this.typeCharacter="",this.accessId=c,this.typeCharacter="",this.entryTimeStamp=new Date,this.terminationDateTime=new Date,this.localSyncTime=new Date}}class kr{constructor(){this.compositionId=0,this.userId=999,this.sessionId=999,this.accessId=4,this.ofTheCompositionId=0,this.patchObject={}}}class Ar{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 xr{constructor(){this.type="",this.search="",this.logicoperator="=",this.index=0,this.composition=!0,this.name="",this.operateon=""}}class Sr{constructor(){this.type="",this.search="",this.composition="",this.internalComposition="",this.userId=999,this.inpage=10,this.page=1,this.auth=!0}}var Lr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))},Rr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class br{}br.isUpdated=!1,br.isOnlineSync=!1;var Gr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function _r(){return Gr(this,arguments,void 0,(function*(t=!0){try{if(yield a("concepts"),yield st("concepts"),t){var e=yield new Promise((function(t,e){let o="settings";a(o).then((i=>{let r=i.transaction(o,"readwrite").objectStore(o).getAll();r.onsuccess=()=>{let e=new n(!1),o=r.result;for(let t=0;t<o.length;t++)e=o[t];t(e)},r.onerror=t=>{e(t)}})).catch((t=>{e({status:400,ok:!1,message:"Cannot get last object from database because you cannot open the database",data:t})}))}));if(e.isOnlineSync)return!0;yield function(){return Rr(this,void 0,void 0,(function*(){try{const i=(new Date).getTime();var t=_("application/x-www-form-urlencoded");const r=yield fetch(o.GetAllAiData(),{method:"GET",headers:t});r.ok||(console.log("Ai Error Message: ","Cannot get response"),L(r));const c=yield r.json();for(var e=0;e<c.length;e++)k.AddConcept(c[e]);!function(){Gr(this,void 0,void 0,(function*(){br.isOnlineSync=!0;var t,e=new n(br.isOnlineSync);t=e,new Promise((function(e,n){let o="settings";a(o).then((i=>{const r=i.transaction(o,"readwrite").objectStore(o).put(t);r.onsuccess=n=>{e(t)},r.onerror=e=>{n({status:400,ok:!1,message:"Cannot update AI flag",data:e,body:t})}})).catch((t=>{n({status:400,ok:!1,message:"Cannot update AI flag because you cannot open the database",data:t})}))}))}))}();let s=(new Date).getTime()-i;console.log("The time taken is ",s)}catch(t){t instanceof Error?console.log("Ai Error Message: ",t.message):console.log("Ai Error Message: ",t),R(t,o.GetAllAiData())}}))}()}return!0}catch(t){let e={message:"cannot initlize the AI system",ok:!1,status:400,data:t};return console.log(e),!0}}))}const Br={number:/^\d+(\.\d+)?$/,text:/^[\s\S]*$/,textOnly:/^[A-Za-z\s]+$/,email:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,document:/\.(pdf|docx?|pptx?|xlsx?)$/i,sound:/\.(mp3|wav|ogg|flac)$/i,image:/\.(jpg|jpeg|png|gif|bmp|svg|webp)$/i,video:/\.(mp4|avi|mov|mkv|flv|webm)$/i,url:/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,date:/^\d{4}-\d{2}-\d{2}$/,time:/^(?:[01]\d|2[0-3]):[0-5]\d$/,password:/^.{6,}$/,ipaddress:/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4})$/,uuid:/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/};var Pr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Ur{constructor(){Ur.cacheInitialized||Ur.initializeAnomalyParameters()}static initializeAnomalyParameters(){return Pr(this,void 0,void 0,(function*(){try{yield Ur.getAnomalyParameters(),Ur.refreshCache(),Ur.cacheInitialized=!0}catch(t){console.error("Error during anomaly parameter initialization:",t)}}))}static getAnomalyParameters(){return Pr(this,void 0,void 0,(function*(){const t=Date.now();if(Ur.anomalyParamsCache&&t-Ur.lastFetchedTime<Ur.cacheExpiryThreshold)return console.log("Returning cached anomaly parameters"),Ur.anomalyParamsCache;try{return yield Ur.fetchAnomalyParameters()}catch(t){throw console.error("Error fetching anomaly parameters:",t),t}}))}static fetchAnomalyParameters(){return Pr(this,void 0,void 0,(function*(){try{const t=yield fetch("https://devai.freeschema.com/v1/get-frontend-anomaly-parameters",{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch anomaly parameters");const e=yield t.json();return Ur.anomalyParamsCache=e.data,Ur.lastFetchedTime=Date.now(),e.data}catch(t){throw console.error("API Fetch Error:",t),t}}))}static refreshCache(){return Pr(this,void 0,void 0,(function*(){try{Date.now()-Ur.lastFetchedTime>Ur.cacheExpiryThreshold&&(yield Ur.getAnomalyParameters())}catch(t){console.error("Error refreshing anomaly parameters cache:",t)}}))}detectDataType(t){for(const[e,n]of Object.entries(Br))if(n.test(t))return e;return null}checkConceptAnomaly(t,e){return Pr(this,void 0,void 0,(function*(){const n=[];try{if(!e)return n.push("Null value"),{valid:!1,warnings:n};const o=Ur.anomalyParamsCache;t.startsWith("the_")||(t=`the_${t}`);const i=o[t];if(console.log("Concept Details : ",i),!i)return console.warn(`No concept details found for type: ${t}`),n.push(`No concept details found for type: ${t}`),{valid:!1,warnings:n};const r=e.length,{min_length:c,max_length:a,data_types:s}=i,l=r>=c&&r<=a,d=this.detectDataType(e),h=s.includes(d);return l||n.push(`Length of '${e}' is outside the allowed range (min: ${c}, max: ${a}). Current length: ${r}.`),h||n.push(`Type mismatch for '${e}'. Expected types: ${s.join(", ")}, detected type: ${d}.`),l&&h&&n.push(`Concept ${t} is valid. Length: ${r}, Type: ${d}`),{valid:l&&h,warnings:n}}catch(o){return console.error(`Error checking anomaly for ${t} with value ${e}:`,o),{valid:!1,warnings:n}}}))}static checkAnomalyInBulk(t){return Pr(this,void 0,void 0,(function*(){Ur.cacheInitialized||(yield Ur.initializeAnomalyParameters());try{const e={};for(const[n,o]of Object.entries(t)){const t=o.value,{valid:i,warnings:r}=yield(new Ur).checkConceptAnomaly(n,t);e[n]={valid:i,warnings:r}}return e}catch(t){throw console.error("Bulk Anomaly Check Error:",t),t}}))}}Ur.anomalyParamsCache=null,Ur.cacheInitialized=!1,Ur.lastFetchedTime=0,Ur.cacheExpiryThreshold=6e5;var Fr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class Dr{checkUniqueness(t,e){return Fr(this,void 0,void 0,(function*(){t.startsWith("the_")||(t="the_"+t);let n=(yield _n(t,999,999,999)).id,o=yield Ie(e,n);return!o||!o.id}))}validateField(t,e,n,o,i,r,c,a,s,l,d){return Fr(this,arguments,void 0,(function*(t,e,n,o,i,r,c,a,s,l,d,h=!1){var u;const f=[];if(!d||null!==n&&""!==n||f.push(`${t} is required`),e&&n){const o=Br[e];o&&""!==n&&!o.test(n)&&f.push(`Invalid format for ${e} in ${t}`)}if(n&&null!==i&&n.length>i&&f.push(`${t} exceeds the maximum length of ${i}`),n&&null!==r&&n.length<r&&f.push(`${t} must be at least ${r} characters long`),null!==c&&n&&!isNaN(Number(n))&&Number(n)<c&&f.push(`${t} must be greater than or equal to ${c}`),null!==a&&n&&!isNaN(Number(n))&&Number(n)>a&&f.push(`${t} must be less than or equal to ${a}`),"file"===e&&l&&s){const e=s.split(",").map((t=>t.trim().toLowerCase())),n=null===(u=l.name.split(".").pop())||void 0===u?void 0:u.toLowerCase();n&&!e.includes(n)&&f.push(`${t} must be a valid file type: ${e.join(", ")}`)}return o&&h&&n&&((yield this.checkUniqueness(o,n))||f.push(`${t} is not unique`)),f}))}validateForm(t){return Fr(this,void 0,void 0,(function*(){const e={};for(const n in t){const{value:o,dataType:i,conceptType:r,maxLength:c=null,minLength:a=null,minValue:s=null,maxValue:l=null,accept:d=null,file:h=null,required:u,isUnique:f}=t[n],y=yield this.validateField(n,i,o,r,c,a,s,l,d,h,u,f);y.length>0&&(e[n]=y)}return e}))}}const Er=t=>{const e=document.getElementsByName(t)[0];if(!e)return console.warn(`Element with NAME "${t}" not found.`),{value:null,dataType:null,conceptType:null,maxLength:null,minLength:null,minValue:null,maxValue:null,accept:null,required:!1,isUnique:!0};const n=e.hasAttribute("required")||"true"===e.getAttribute("data-required"),o=e.hasAttribute("isUnique")&&"true"===e.getAttribute("isUnique");return{value:e.value,dataType:e.getAttribute("data-type"),conceptType:e.getAttribute("concept-type"),maxLength:e.getAttribute("data-maxlength")?parseInt(e.getAttribute("data-maxlength")):null,minLength:e.getAttribute("data-minlength")?parseInt(e.getAttribute("data-minlength")):null,minValue:e.getAttribute("data-min")?parseInt(e.getAttribute("data-min")):null,maxValue:e.getAttribute("data-max")?parseInt(e.getAttribute("data-max")):null,accept:e.getAttribute("accept")||null,required:n,isUnique:o}};class Or{constructor(){this.subscribers=[]}notify(){this.subscribers.map((t=>{t(this.data)}))}dataChange(t){return this.subscribers.push(t),t(this.data)}}class Vr extends Or{constructor(){super(...arguments),this.elementIdentifier=0,this.widgetMounted=!1}getComponent(){return document.getElementById(this.elementIdentifier.toString())}getElementById(t){let e=this.getComponent(),n=document.body;if(e){let o=e.querySelector("#"+t);if(o)return n=o,n}return null}createWidgetWrapperIdentifier(){return this.elementIdentifier=1e4*Math.random(),this.elementIdentifier.toString()}}class jr extends Vr{constructor(){super(...arguments),this.childWidgets=[],this.parentElement="",this.element=null}setTitle(t){document.title=t}getHtml(){return""}UpdateChildData(t,e){let n=e;n.data=t,n.render(),n.updateWidget()}updateWidget(){}setState(t){this.data=t,this.notify(),this.render()}loadChildWidgets(){this.childWidgets.map((t=>{let e=this.getElementById(t.parentElement);e&&(e.innerHTML=""),t.mount(e)}))}render(){this.element&&(this.element.innerHTML=this.getHtml()),this.addEvents(),this.widgetMounted&&this.loadChildWidgets()}mountChildWidgets(){}mount(t){return e=this,n=void 0,i=function*(){t&&(this.element=document.createElement("div"),this.element.id=this.createWidgetWrapperIdentifier(),this.element.innerHTML=yield this.getHtml(),t.appendChild(this.element),this.parentElement=t.id,0==this.widgetMounted?(this.widgetDidMount(),this.mountChildWidgets(),this.widgetMounted=!0):this.render())},new((o=void 0)||(o=Promise))((function(t,r){function c(t){try{s(i.next(t))}catch(t){r(t)}}function a(t){try{s(i.throw(t))}catch(t){r(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,a)}s((i=i.apply(e,n||[])).next())}));var e,n,o,i}widgetDidMount(){this.render()}addEvents(){}}var Mr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Hr(t,e){return Mr(this,void 0,void 0,(function*(){let n=yield On(t);for(let t=0;t<n.length;t++)Z.AddConnection(n[t]);let o=yield Z.GetConnectionsOfConcept(t),i=yield Kt(e),r=[];for(let t=0;t<o.length;t++)o[t].typeId==i.id&&r.push(o[t]);for(let t=0;t<r.length;t++)sn(r[t].id)}))}class Wr{constructor(){this.type="",this.inpage=10,this.page=1,this.concepts=[],this.conceptIds=[],this.selectors=[],this.freeschemaQueries=[],this.filters=[],this.filterLogic="",this.typeConnection="",this.outputFormat=di,this.name="",this.reverse=!1}}var $r=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function qr(t){return $r(this,arguments,void 0,(function*(t,e=""){var n=_("application/json",e);const i=o.FreeschemaQueryUrl(),r=JSON.stringify(t);try{const t=yield fetch(i,{method:"POST",headers:n,body:r});return t.ok?yield t.json():(L(t),console.log("This is the freeschema query error",t.status),[])}catch(t){console.log("This is the freeschema query error others",t),R(t,i)}}))}var Jr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};class zr extends ir{constructor(t,e){super(),this.mainCompositionIds=[],this.query=new Wr,this.query=t,this.format=t.outputFormat}bind(){return Jr(this,void 0,void 0,(function*(){if(!this.isDataLoaded){this.isDataLoaded=!0,this.query.outputFormat=pi;let t=yield qr(this.query,"");this.conceptIds=t.conceptIds,this.internalConnections=t.internalConnections,this.linkers=t.linkers,this.reverse=t.reverse,this.mainCompositionIds=t.mainCompositionIds}return yield this.build()}))}build(){return Jr(this,void 0,void 0,(function*(){return this.format==hi?this.data=yield function(t,e,n,o){return mi(this,void 0,void 0,(function*(){let e=yield co(t),i=[];i=yield function(t,e){return gi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let h=0;h<t.length;h++){let u=!1,f=yield dn(t[h].ofTheConceptId),y=yield dn(t[h].toTheConceptId);if(n.includes(t[h].id)&&(u=!0),1==u){if(0!=f.id&&0!=y.id){let n,a=yield dn(t[h].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[h].toTheConceptId in e?n=e[t[h].toTheConceptId]:(n={},n[s]={},e[t[h].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;(a.characterValue+"_reverse").includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=yield dn(t[h].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[h].ofTheConceptId in e?n=e[t[h].ofTheConceptId]:(n={},n[i]={},e[t[h].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;o.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n)}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o),console.log("this is the format data builders BEFORE",i),i=yield function(t,e){return gi(this,arguments,void 0,(function*(t,e,n=[]){var o,i,r,c,a,s,l,d;let h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let h=0;h<t.length;h++){let u=!1,f=yield dn(t[h].ofTheConceptId),y=yield dn(t[h].toTheConceptId);if(n.includes(t[h].id)&&(u=!0),1==u){if(0!=f.id&&0!=y.id){let n,a=yield dn(t[h].typeId),s=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[h].toTheConceptId in e?(n=e[t[h].toTheConceptId],s in n||(n[s]={})):(n={},n[s]={},e[t[h].toTheConceptId]=n);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o={id:f.id,data:{[t]:e}},i=a.characterValue+"_reverse";i.includes("_s_")||("string"==typeof n[s]&&(n[s]={}),n[s][i]=o)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=yield dn(t[h].typeId),i=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[h].ofTheConceptId in e?(n=e[t[h].ofTheConceptId],i in n||(n[i]={})):(n={},n[i]={},e[t[h].ofTheConceptId]=n);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",e=y.characterValue,r={id:y.id,data:{[t]:e}};o.characterValue.includes("_s_")||("string"==typeof n[i]&&(n[i]={}),n[i][o.characterValue]=r)}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o),console.log("this is the format data builders",i);let r=yield function(t,e,n,o){return gi(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c,a,s;(new Date).getTime();let l=[],d=[];for(let e=0;e<t.length;e++)d.push(t[e].toTheConceptId),d.push(t[e].ofTheConceptId),d.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1,l=yield dn(t[n].ofTheConceptId),d=yield dn(t[n].toTheConceptId);if(i.includes(t[n].id)&&(o=!0),1==o){if(0!=l.id&&0!=d.id&&d.id in e){let o,i=yield dn(t[n].typeId),a=null!==(c=null===(r=d.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self",s=!1;t[n].toTheConceptId in e&&(s=!0),t[n].toTheConceptId in e?o=e[t[n].toTheConceptId]:(o={},o[a]={},e[t[n].toTheConceptId]=o);try{if(e[t[n].ofTheConceptId]){let r={id:l.id,data:e[t[n].ofTheConceptId]},c=i.characterValue+"_reverse";Array.isArray(o[a][c])?o[a][c].push(r):c.includes("_s_")?(o[a][c]=[],o[a][c].push(r)):o[a][c]=r}}catch(t){console.log("this is error",t)}}}else if(0!=l.id&&0!=d.id&&l.id in e){let o,i=yield dn(t[n].typeId),r=null!==(s=null===(a=l.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self",c=!1;t[n].toTheConceptId in e&&(c=!0),t[n].ofTheConceptId in e?o=e[t[n].ofTheConceptId]:(o={},o[r]={},e[t[n].ofTheConceptId]=o);try{if(e[t[n].toTheConceptId]){let c={id:d.id,data:e[t[n].toTheConceptId]};Array.isArray(o[r][i.characterValue])?o[r][i.characterValue].push(c):i.characterValue.includes("_s_")?(o[r][i.characterValue]=[],o[r][i.characterValue].push(c)):o[r][i.characterValue]=c}}catch(t){console.log("this is error",t)}}}console.log("these are the main datas",e);for(let t=0;t<o.length;t++){let n={};n.id=o[t],n.data=e[o[t]],l.push(n)}return l}))}(e,i,[],n,o);return r}))}(this.linkers,this.conceptIds,this.mainCompositionIds,this.reverse):this.data=yield function(t,e,n,o){return mi(this,void 0,void 0,(function*(){let e=yield co(t),i=[];i=yield function(t,e,n){return gi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let h=0;h<t.length;h++){let u=!1;n.includes(t[h].id)&&(u=!0);let f=yield dn(t[h].ofTheConceptId),y=yield dn(t[h].toTheConceptId);if(1==u){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[h].toTheConceptId in e?n=e[t[h].toTheConceptId]:(n={},n[a]={},e[t[h].toTheConceptId]=n);let s=yield dn(t[h].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",n=f.characterValue;s.characterValue,s.characterValue.includes("_s_")&&(f.id in e||(e[f.id]={}),e[f.id][t]=n)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[h].ofTheConceptId in e?n=e[t[h].ofTheConceptId]:(n={},n[o]={},e[t[h].ofTheConceptId]=n);let i=yield dn(t[h].typeId);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",n=y.characterValue;i.characterValue.includes("_s_")&&(y.id in e||(e[y.id]={}),e[y.id][t]=n)}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o),console.log("this is the format normal builders BEFORE",i),i=yield function(t,e,n){return gi(this,void 0,void 0,(function*(){var o,i,r,c,a,s,l,d;let h=[];for(let e=0;e<t.length;e++)h.push(t[e].toTheConceptId),h.push(t[e].ofTheConceptId),h.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let h=0;h<t.length;h++){let u=!1;n.includes(t[h].id)&&(u=!0);let f=yield dn(t[h].ofTheConceptId),y=yield dn(t[h].toTheConceptId);if(1==u){if(0!=f.id&&0!=y.id){let n,a=null!==(i=null===(o=y.type)||void 0===o?void 0:o.characterValue)&&void 0!==i?i:"self";t[h].toTheConceptId in e?(n=e[t[h].toTheConceptId],a in n||(n[a]={})):(n={},n[a]={},e[t[h].toTheConceptId]=n);let s=yield dn(t[h].typeId);try{let t=null!==(c=null===(r=null==f?void 0:f.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"none",e=f.characterValue,o={[t]:e},i=s.characterValue+"_reverse";s.characterValue.includes("_s_")||("string"==typeof n[a]&&(n[a]={}),n[a][i]=o)}catch(t){console.log("this is error",t)}}}else if(0!=f.id&&0!=y.id){let n,o=null!==(s=null===(a=f.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[h].ofTheConceptId in e?(n=e[t[h].ofTheConceptId],o in n||(n[o]={})):(n={},n[o]={},e[t[h].ofTheConceptId]=n);let i=yield dn(t[h].typeId);try{let t=null!==(d=null===(l=null==y?void 0:y.type)||void 0===l?void 0:l.characterValue)&&void 0!==d?d:"none",e=y.characterValue,r={[t]:e};i.characterValue.includes("_s_")||("string"==typeof n[o]&&(n[o]={}),n[o][i.characterValue]=r)}catch(t){console.log("this is error",t)}}}return e}))}(e,i,o),console.log("this is the format normal builders",i);let r=yield function(t,e,n,o){return gi(this,arguments,void 0,(function*(t,e,n,o,i=[]){var r,c,a,s;let l=[],d=[];for(let e=0;e<t.length;e++)d.push(t[e].toTheConceptId),d.push(t[e].ofTheConceptId),d.push(t[e].typeId);t.sort((function(t,e){return e.id-t.id}));for(let n=0;n<t.length;n++){let o=!1;i.includes(t[n].id)&&(o=!0);let l=yield dn(t[n].ofTheConceptId),d=yield dn(t[n].toTheConceptId);if(1==o){if(0!=l.id&&0!=d.id&&d.id in e){let o,i=null!==(c=null===(r=d.type)||void 0===r?void 0:r.characterValue)&&void 0!==c?c:"self";t[n].toTheConceptId in e?o=e[t[n].toTheConceptId]:(o={},o[i]={},e[t[n].toTheConceptId]=o);let a=yield dn(t[n].typeId);try{let r=a.characterValue+"_reverse",c=e[t[n].ofTheConceptId];c&&(Array.isArray(o[i][r])?o[i][r].push(c):a.characterValue.includes("_s_")?(o[i][r]=[],o[i][r].push(c)):o[i][r]=c)}catch(t){console.log("this is error",t)}}}else if(0!=l.id&&0!=d.id&&l.id in e){let o,i=null!==(s=null===(a=l.type)||void 0===a?void 0:a.characterValue)&&void 0!==s?s:"self";t[n].ofTheConceptId in e?o=e[t[n].ofTheConceptId]:(o={},o[i]={},e[t[n].ofTheConceptId]=o);let r=yield dn(t[n].typeId);try{let c=e[t[n].toTheConceptId];c&&(Array.isArray(o[i][r.characterValue])?o[i][r.characterValue].push(c):r.characterValue.includes("_s_")?(o[i][r.characterValue]=[],o[i][r.characterValue].push(c)):o[i][r.characterValue]=c)}catch(t){console.log("this is error",t)}}}for(let t=0;t<n.length;t++){let o=e[n[t]];o.id=n[t],l.push(o)}return l}))}(e,i,n,[],o);return r}))}(this.linkers,this.conceptIds,this.mainCompositionIds,this.reverse),this.data}))}}function Qr(t,e){return new zr(t,e)}var Zr=function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function c(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((o=o.apply(t,e||[])).next())}))};function Kr(t=""){b.BearerAccessToken=t}function Xr(){return Zr(this,arguments,void 0,(function*(t="",e="",n="",i="",r=!0,c="",a=!1){try{o.BASE_URL=t,o.AI_URL=e,o.NODE_URL=i,o.BASE_APPLICATION=c,b.BearerAccessToken=n;let s=Math.floor(1e8*Math.random());if(o.BASE_RANDOMIZER=s,a)return u.isDataLoaded=!0,u.isCharacterLoaded=!0,u.isTypeLoaded=!0,u.isLocalDataLoaded=!0,u.isLocalTypeLoaded=!0,u.isLocalCharacterLoaded=!0,u.isConnectionLoaded=!0,u.isConnectionTypeLoaded=!0,u.isLocalConnectionLoaded=!0,!0;console.log("This ist he base url",o.BASE_URL,s),yield _r(r);const l=(new Date).getTime();return yield x().then((()=>{let t=(new Date).getTime()-l;console.log("The time taken to prepare concept data is ",t)})).catch((t=>{throw t})),yield Fe().then((()=>{let t=(new Date).getTime()-l;console.log("The time taken to prepare local concept ",t)})).catch((t=>{throw t})),yield function(){return Lr(this,void 0,void 0,(function*(){try{let t=yield lt("localconnection");if(Array.isArray(t))for(let e=0;e<t.length;e++)xt.AddConnectionToMemory(t[e])}catch(t){throw{message:"Cannot create Local Connection Binary Tree Concept",ok:!1,status:400,data:t}}}))}().then((()=>{u.isLocalConnectionLoaded=!0})).catch((t=>{throw t})),De().then((()=>{})).catch((t=>{throw console.log("This is the error in populating binary tree"),t})),yield function(){return Lr(this,void 0,void 0,(function*(){try{let t=yield d("connection");if(Array.isArray(t))for(let e=0;e<t.length;e++)Z.AddConnectionToMemory(t[e])}catch(t){throw{message:"Cannot create Connection Binary Tree Concept",ok:!1,status:400,data:t}}}))}().then((()=>{u.isConnectionLoaded=!0,u.isConnectionTypeLoaded=!0;let t=(new Date).getTime()-l;console.log("The time taken to prepare connections ",t)})).catch((t=>{throw t})),!0}catch(t){console.log("cannot initialize the system",t)}}))}var Yr=exports;for(var tc in e)Yr[tc]=e[tc];e.__esModule&&Object.defineProperty(Yr,"__esModule",{value:!0})})();
2
2
  //# sourceMappingURL=bundle.js.map