@overmap-ai/core 1.0.74-geojson-layers.2 → 1.0.74-geojson-layers.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
- (function(i,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("@redux-offline/redux-offline/lib/types"),require("@reduxjs/toolkit"),require("superagent"),require("uuid"),require("file-saver"),require("@redux-offline/redux-offline"),require("@redux-offline/redux-offline/lib/defaults"),require("buffer"),require("localforage"),require("redux-persist-migrate"),require("@overmap-ai/forms"),require("idb"),require("@redux-offline/redux-offline/lib/constants"),require("jwt-decode"),require("dependency-graph"),require("@tiptap/core")):typeof define=="function"&&define.amd?define(["exports","@redux-offline/redux-offline/lib/types","@reduxjs/toolkit","superagent","uuid","file-saver","@redux-offline/redux-offline","@redux-offline/redux-offline/lib/defaults","buffer","localforage","redux-persist-migrate","@overmap-ai/forms","idb","@redux-offline/redux-offline/lib/constants","jwt-decode","dependency-graph","@tiptap/core"],j):(i=typeof globalThis<"u"?globalThis:i||self,j(i["overmap-core"]={},null,i.toolkit,i.request,i.uuid,i.fileSaver,i.reduxOffline,i.offlineConfig,null,i.localforage,i.createMigration,null,i.idb,i.constants,i.jwtDecode,i.dependencyGraph))})(this,function(i,j,l,we,Te,Fh,Ih,Ga,gg,Rh,Ph,bg,Oh,_h,vh,wh){"use strict";var fg=Object.defineProperty;var Sg=(i,j,l)=>j in i?fg(i,j,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[j]=l;var f=(i,j,l)=>Sg(i,typeof j!="symbol"?j+"":j,l);var Th;const $a=Object.freeze([]),La=Object.freeze({});var jt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(jt||{}),qt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(qt||{}),h=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(h||{}),Ba=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(Ba||{}),Mt=(t=>(t[t.LOWEST=0]="LOWEST",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=6]="HIGH",t[t.HIGHEST=8]="HIGHEST",t))(Mt||{}),kt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(kt||{}),v=(t=>(t.STATUS="status",t.PRIORITY="priority",t.CATEGORY="category",t.DESCRIPTION="description",t.TITLE="title",t.ASSIGNED_TO="assigned_to",t.DUE_DATE="due_date",t))(v||{}),Na=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Na||{}),Ja=(t=>(t[t.PRO=0]="PRO",t))(Ja||{}),Ha=(t=>(t[t.ACTIVE=0]="ACTIVE",t[t.PAUSED=2]="PAUSED",t[t.CANCELLED=4]="CANCELLED",t[t.INACTIVE=6]="INACTIVE",t[t.PAST_DUE=8]="PAST_DUE",t))(Ha||{});const Eh=kt.BACKLOG,jh=Mt.MEDIUM,Wa=6e4;function T(t){return{addOne:(p,A)=>{const y=t(A.payload);p.instances[y]=A.payload},addMany:(p,A)=>{for(const y of A.payload){const b=t(y);p.instances[b]=y}},setOne:(p,A)=>{const y=t(A.payload);p.instances[y]=A.payload},setMany:(p,A)=>{for(const y of A.payload){const b=t(y);p.instances[b]=y}},updateOne:(p,A)=>{const y=t(A.payload);p.instances[y]=A.payload},updateMany:(p,A)=>{for(const y of A.payload){const b=t(y);p.instances[b]=y}},deleteOne:(p,A)=>{delete p.instances[A.payload]},deleteMany:(p,A)=>{for(const y of A.payload)delete p.instances[y]},initialize:(p,A)=>{p.instances={};for(const y of A.payload){const b=t(y);p.instances[b]=y}},getInitialState:p=>({...p,instances:{}})}}function qh(){return{initializeSelection:(m,d)=>{m.selection=Array.from(new Set(d.payload))},selectOne:(m,d)=>{new Set(m.selection).has(d.payload)||m.selection.push(d.payload)},selectMany:(m,d)=>{const u=new Set(m.selection);for(const p of d.payload)u.has(p)||u.add(p);m.selection=Array.from(u)},unselectOne:(m,d)=>{const u=new Set(m.selection);u.has(d.payload)&&(u.delete(d.payload),m.selection=Array.from(u))},unselectMany:(m,d)=>{const u=new Set(m.selection);for(const p of d.payload)u.has(p)&&u.delete(p);m.selection=Array.from(u)},toggleOne:(m,d)=>{const u=new Set(m.selection);u.has(d.payload)?u.delete(d.payload):u.add(d.payload),m.selection=Array.from(u)},toggleMany:(m,d)=>{const u=new Set(m.selection);for(const p of d.payload)u.has(p)?u.delete(p):u.add(p);m.selection=Array.from(u)},getInitialState:m=>({...m,selection:[]})}}Th=Symbol.toStringTag;class Ka{constructor(){f(this,Th,"Promise");f(this,"_promise");f(this,"_resolve");f(this,"_reject");f(this,"_state","pending");this._resolve=null,this._reject=null,this._promise=new Promise((e,s)=>{this._resolve=e,this._reject=s})}get state(){return this._state}then(e,s){return this._promise.then(e,s)}catch(e){return this._promise.catch(e)}resolve(e){if(!this._resolve)throw new Error("No resolve callback");this._resolve(e),this._state="fulfilled"}reject(e){if(!this._reject)throw e;this._reject(e),this._state="rejected"}finally(e){throw new Error("`finally` not implemented")}}const Mh=t=>({type:"Point",coordinates:t}),kh=t=>({type:"MultiPoint",coordinates:t}),Ch=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Ct=!1;["true","1"].includes("".toLowerCase())&&(Ct=!0);function zh(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;const s=Object.keys(t),a=Object.keys(e),n=s.length;if(n!==a.length)return!1;for(let c=0;c<n;c++){const r=s[c];if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1}return!0}function zt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Ct&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Ct&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Dh(t,e){if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}const S=t=>t.length===0?$a:t,Ee=t=>Object.keys(t).length===0?La:t,Ya=zt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===Dt.getFullYear(),a={day:"numeric",month:"short"};return s||(a.year="numeric"),e.toLocaleDateString([],a)}),Uh=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),Vh=1e3*86400,Dt=new Date,Gh=t=>new Date(t).toDateString()===Dt.toDateString(),$h=zt((t,e,s)=>{const a=Math.round((new Date(t).getTime()-Dt.getTime())/Vh);return a<e||a>s?Ya(t):Uh.format(a,"days")});function Lh(t){return new Uint8Array(t).reduce((s,a)=>s+a.toString(16).padStart(2,"0"),"")}const Ut=async(t,e)=>{e||(e=await je(t));let s=t.type;if(s.includes("/")&&(s=s.split("/")[1]),!s)throw new Error(`Could not extract file type from ${t.type}`);return`${e}.${s}`};function je(t){return new Promise((e,s)=>{const a=new FileReader;a.onload=()=>{const n=a.result;if(!n){s(new Error("FileReader did not return a valid ArrayBuffer."));return}crypto.subtle.digest("SHA-1",n).then(c=>{const r=Lh(c);e(r)})},a.readAsArrayBuffer(t)})}function Bh(t){if(!t.name||!t.type||!t.size){const e="File has no name, type, and/or size";throw new Error(e)}return`${t.name}&${t.type}${t.size}`}function Xa(t,e){return new File([t],e,{type:t.type})}function Nh(t,e){const s=document.createElement("a");s.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e)),s.setAttribute("download",t),s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}const Jh=async t=>{const e={};for(const s of t){const a=await je(s);e[a]={sha1:a,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},Qa=async t=>(await fetch(t)).blob(),Hh=t=>new Promise((e,s)=>{const a=new FileReader;a.onloadend=()=>{var n;e(((n=a.result)==null?void 0:n.toString())||"")},a.readAsDataURL(t)});function Wh(t){const e=new Blob([t]);Fh.saveAs(e,t.name)}const Za={};function Kh(t,e,s,...a){const n=Za[t];let c=!1;n?n[e]||(n[e]=!0,c=!0):(Za[t]={[e]:!0},c=!0),c&&console[s](...a)}const xa=["created_at","updated_at","index","revision"];function F(t){return{...t,uuid:Te.v4()}}function en(t){const e={};for(const s of t)e[s.uuid]=s;return e}function Yh(t,e=void 0,s=255){let a=t.replace(/[^a-z0-9_\-.]/gi,"_").replace(/_{2,}/g,"_");if(!e){const c=t.split(".");c.length>1&&(e=c[c.length-1])}e&&!e.startsWith(".")&&(e="."+e);const n=e?e.length:0;return a.length+n>s&&(a=a.slice(0,s-n)+(e||"")),a}function Xh(t){return t.toLowerCase().replace(" ","-")}function Qh(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Zh(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const g=t=>e=>s=>t(s,e);function tn(t,e,s){return s.findIndex(a=>a.uuid===t.uuid)===e}function xh(t,e,s){return s.findIndex(a=>a.file_sha1===t.file_sha1)===e}const em=/^.+@.+\..+$/;function O(t){const e={...t};for(const s of[...xa,"created_by"])s in e&&delete e[s];return e}const Ve=T(t=>t.uuid),sn=Ve.getInitialState({}),Vt=l.createSlice({name:"agents",initialState:sn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sn)),reducers:{initializeConversations:Ve.initialize,addConversation:Ve.addOne,setConversation:Ve.setOne,updateConversation:Ve.updateOne}}),{initializeConversations:an,addConversation:nn,setConversation:cn,updateConversation:rn}=Vt.actions,Gt=t=>t.agentsReducer.instances,tm=l.createSelector([Gt],t=>Object.values(t)),sm=g(l.createSelector([Gt,(t,e)=>e],(t,e)=>t[e])),dn=Vt.reducer,C=T(t=>t.uuid),on=C.getInitialState({}),$t=l.createSlice({name:"assetAttachments",initialState:on,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,on)),reducers:{initializeAssetAttachments:C.initialize,addAssetAttachment:C.addOne,addAssetAttachments:C.addMany,setAssetAttachment:C.setOne,setAssetAttachments:C.setMany,updateAssetAttachment:C.updateOne,updateAssetAttachments:C.updateMany,deleteAssetAttachment:C.deleteOne,deleteAssetAttachments:C.deleteMany}}),{initializeAssetAttachments:Lt,addAssetAttachment:im,addAssetAttachments:Bt,setAssetAttachment:un,setAssetAttachments:am,updateAssetAttachment:nm,updateAssetAttachments:ln,deleteAssetAttachment:hn,deleteAssetAttachments:Nt}=$t.actions,mn=t=>t.assetAttachmentReducer.instances,pn=l.createSelector([mn],t=>Object.values(t)),An=t=>e=>e.assetAttachmentReducer.instances[t],yn=g(l.createSelector([pn,(t,e)=>e],(t,e)=>S(t.filter(({asset:s})=>e===s)))),fn=$t.reducer,z=T(t=>t.uuid),Sn=z.getInitialState({}),Jt=l.createSlice({name:"assetProcedureAttachments",initialState:Sn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sn)),reducers:{initializeAssetProcedureAttachments:z.initialize,addAssetProcedureAttachment:z.addOne,addAssetProcedureAttachments:z.addMany,setAssetProcedureAttachment:z.setOne,setAssetProcedureAttachments:z.setMany,updateAssetProcedureAttachment:z.updateOne,updateAssetProcedureAttachments:z.updateMany,deleteAssetProcedureAttachment:z.deleteOne,deleteAssetProcedureAttachments:z.deleteMany}}),{initializeAssetProcedureAttachments:gn,addAssetProcedureAttachment:cm,addAssetProcedureAttachments:bn,setAssetProcedureAttachment:Tn,setAssetProcedureAttachments:rm,updateAssetProcedureAttachment:dm,updateAssetProcedureAttachments:Fn,deleteAssetProcedureAttachment:In,deleteAssetProcedureAttachments:Rn}=Jt.actions,Pn=t=>t.assetProcedureAttachmentReducer.instances,On=l.createSelector([Pn],t=>Object.values(t)),_n=t=>e=>e.assetProcedureAttachmentReducer.instances[t],om=g(l.createSelector([On,(t,e)=>e],(t,e)=>S(t.filter(({asset_procedure:s})=>e===s)))),vn=Jt.reducer,D=T(t=>t.uuid),wn=D.getInitialState({}),Ht=l.createSlice({name:"assetProcedureFieldsAttachments",initialState:wn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wn)),reducers:{initializeAssetProcedureFieldsAttachments:D.initialize,addAssetProcedureFieldsAttachment:D.addOne,addAssetProcedureFieldsAttachments:D.addMany,setAssetProcedureFieldsAttachment:D.setOne,setAssetProcedureFieldsAttachments:D.setMany,updateAssetProcedureFieldsAttachment:D.updateOne,updateAssetProcedureFieldsAttachments:D.updateMany,deleteAssetProcedureFieldsAttachment:D.deleteOne,deleteAssetProcedureFieldsAttachments:D.deleteMany}}),{initializeAssetProcedureFieldsAttachments:En,addAssetProcedureFieldsAttachment:um,addAssetProcedureFieldsAttachments:jn,setAssetProcedureFieldsAttachment:lm,setAssetProcedureFieldsAttachments:hm,updateAssetProcedureFieldsAttachment:mm,updateAssetProcedureFieldsAttachments:qn,deleteAssetProcedureFieldsAttachment:pm,deleteAssetProcedureFieldsAttachments:Mn}=Ht.actions,kn=t=>t.assetProcedureFieldsAttachmentReducer.instances,Cn=l.createSelector([kn],t=>Object.values(t)),Am=g(l.createSelector([Cn,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),ym=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],zn=Ht.reducer,U=T(t=>t.uuid),Dn=U.getInitialState({}),Wt=l.createSlice({name:"assetProcedureFields",initialState:Dn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dn)),reducers:{initializeAssetProcedureFields:U.initialize,addAssetProcedureFields:U.addOne,addAssetProcedureFieldsMany:U.addMany,setAssetProcedureFields:U.setOne,setAssetProcedureFieldsMany:U.setMany,updateAssetProcedureFields:U.updateOne,updateAssetProcedureFieldsMany:U.updateMany,deleteAssetProcedureFields:U.deleteOne,deleteAssetProcedureFieldsMany:U.deleteMany}}),{initializeAssetProcedureFields:Un,addAssetProcedureFields:Vn,addAssetProcedureFieldsMany:fm,setAssetProcedureFields:Sm,setAssetProcedureFieldsMany:gm,updateAssetProcedureFields:Gn,updateAssetProcedureFieldsMany:bm,deleteAssetProcedureFields:$n,deleteAssetProcedureFieldsMany:Tm}=Wt.actions,Ln=t=>t.assetProcedureFieldsReducer.instances,Kt=l.createSelector([Ln],t=>Object.values(t)),Fm=g(l.createSelector([Kt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Im=g(l.createSelector([Kt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,a)=>s.submitted_at>a.submitted_at?-1:1)[0])),Rm=t=>e=>e.assetProcedureFieldsReducer.instances[t],Bn=Wt.reducer,V=T(t=>t.uuid),Nn=V.getInitialState({}),Yt=l.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:Nn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Nn)),reducers:{initializeAssetProcedureFieldValuesAttachments:V.initialize,addAssetProcedureFieldValuesAttachment:V.addOne,addAssetProcedureFieldValuesAttachments:V.addMany,setAssetProcedureFieldValuesAttachment:V.setOne,setAssetProcedureFieldValuesAttachments:V.setMany,updateAssetProcedureFieldValuesAttachment:V.updateOne,updateAssetProcedureFieldValuesAttachments:V.updateMany,deleteAssetProcedureFieldValuesAttachment:V.deleteOne,deleteAssetProcedureFieldValuesAttachments:V.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:Jn,addAssetProcedureFieldValuesAttachment:Pm,addAssetProcedureFieldValuesAttachments:it,setAssetProcedureFieldValuesAttachment:Om,setAssetProcedureFieldValuesAttachments:_m,updateAssetProcedureFieldValuesAttachment:vm,updateAssetProcedureFieldValuesAttachments:Hn,deleteAssetProcedureFieldValuesAttachment:wm,deleteAssetProcedureFieldValuesAttachments:at}=Yt.actions,Xt=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,Wn=l.createSelector([Xt],t=>Object.values(t)),Em=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],Kn=g(l.createSelector([Xt,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),Yn=g(l.createSelector([Wn,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),Xn=Yt.reducer,G=T(t=>t.uuid),Qn=G.getInitialState({}),Qt=l.createSlice({name:"assetProcedureFieldValues",initialState:Qn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qn)),reducers:{initializeAssetProcedureFieldValues:G.initialize,addAssetProcedureFieldValues:G.addOne,addAssetProcedureFieldValuesMany:G.addMany,setAssetProcedureFieldValues:G.setOne,setAssetProcedureFieldValuesMany:G.setMany,updateAssetProcedureFieldValues:G.updateOne,updateAssetProcedureFieldValuesMany:G.updateMany,deleteAssetProcedureFieldValues:G.deleteOne,deleteAssetProcedureFieldValuesMany:G.deleteMany}}),{initializeAssetProcedureFieldValues:Zn,addAssetProcedureFieldValues:Zt,addAssetProcedureFieldValuesMany:xn,setAssetProcedureFieldValues:jm,setAssetProcedureFieldValuesMany:qm,updateAssetProcedureFieldValues:Ge,updateAssetProcedureFieldValuesMany:ec,deleteAssetProcedureFieldValues:xt,deleteAssetProcedureFieldValuesMany:tc}=Qt.actions,sc=t=>t.assetProcedureFieldValuesReducer.instances,es=l.createSelector([sc],t=>Object.values(t)),Mm=g(l.createSelector([es,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),km=g(l.createSelector([es,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure_instance===e)))),ts=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],ic=Qt.reducer,$=T(t=>t.uuid),ac=$.getInitialState({}),ss=l.createSlice({name:"assetProcedureInstances",initialState:ac,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ac)),reducers:{initializeAssetProcedureInstances:$.initialize,addAssetProcedureInstance:$.addOne,addAssetProcedureInstances:$.addMany,setAssetProcedureInstance:$.setOne,setAssetProcedureInstances:$.setMany,updateAssetProcedureInstance:$.updateOne,updateAssetProcedureInstances:$.updateMany,deleteAssetProcedureInstance:$.deleteOne,deleteAssetProcedureInstances:$.deleteMany}}),{initializeAssetProcedureInstances:nc,addAssetProcedureInstance:is,addAssetProcedureInstances:cc,updateAssetProcedureInstance:$e,updateAssetProcedureInstances:Cm,deleteAssetProcedureInstance:as,deleteAssetProcedureInstances:rc,setAssetProcedureInstance:zm,setAssetProcedureInstances:Dm}=ss.actions,ns=t=>t.assetProcedureInstanceReducer.instances,cs=l.createSelector([ns],t=>Object.values(t)),dc=g(l.createSelector([cs,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Um=g(l.createSelector([cs,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),rs=t=>e=>e.assetProcedureInstanceReducer.instances[t],Vm=g(l.createSelector([ns,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),oc=ss.reducer,L=T(t=>t.uuid),uc=L.getInitialState({}),ds=l.createSlice({name:"assetProcedures",initialState:uc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uc)),reducers:{initializeAssetProcedures:L.initialize,addAssetProcedure:L.addOne,addAssetProcedures:L.addMany,setAssetProcedure:L.setOne,setAssetProcedures:L.setMany,updateAssetProcedure:L.updateOne,updateAssetProcedures:L.updateMany,deleteAssetProcedure:L.deleteOne,deleteAssetProcedures:L.deleteMany}}),{initializeAssetProcedures:lc,addAssetProcedure:os,addAssetProcedures:Gm,updateAssetProcedure:Le,updateAssetProcedures:$m,deleteAssetProcedure:us,deleteAssetProcedures:Lm,setAssetProcedure:Bm,setAssetProcedures:Nm}=ds.actions,ls=t=>t.assetProcedureReducer.instances,hc=l.createSelector([ls],t=>Object.values(t)),Jm=g(l.createSelector([hc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),hs=t=>e=>e.assetProcedureReducer.instances[t],Hm=g(l.createSelector([ls,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),mc=ds.reducer,B=T(t=>t.uuid),pc=B.getInitialState({}),ms=l.createSlice({name:"assets",initialState:pc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pc)),reducers:{initializeAssets:B.initialize,addAsset:B.addOne,addAssets:B.addMany,setAsset:B.setOne,setAssets:B.setMany,updateAsset:B.updateOne,updateAssets:B.updateMany,deleteAsset:B.deleteOne,deleteAssets:B.deleteMany}}),{initializeAssets:Ac,addAsset:ps,addAssets:As,updateAsset:Be,updateAssets:Wm,deleteAsset:ys,deleteAssets:yc,setAsset:Km,setAssets:Ym}=ms.actions,fs=t=>t.assetReducer.instances,fc=l.createSelector([fs],t=>S(Object.values(t))),Ss=g(l.createSelector([fc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),gs=t=>e=>e.assetReducer.instances[t],Xm=g(l.createSelector([fs,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),Qm=t=>e=>Ss(t)(e).length,Sc=ms.reducer,Se=T(t=>t.uuid),gc=Se.getInitialState({}),bs=l.createSlice({name:"assetStageCompletions",initialState:gc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gc)),reducers:{initializeAssetStageCompletions:Se.initialize,addAssetStageCompletion:Se.addOne,addAssetStageCompletions:Se.addMany,updateAssetStageCompletion:Se.updateOne,updateAssetStageCompletions:Se.updateMany,deleteAssetStageCompletion:Se.deleteOne,deleteAssetStageCompletions:Se.deleteMany}}),{initializeAssetStageCompletions:bc,addAssetStageCompletion:Ts,addAssetStageCompletions:Fs,updateAssetStageCompletion:Tc,updateAssetStageCompletions:Fc,deleteAssetStageCompletion:Is,deleteAssetStageCompletions:Rs}=bs.actions,Ic=bs.reducer,Ps=t=>t.assetStageCompletionReducer.instances,Zm=l.createSelector([Ps],t=>Object.values(t)),Rc=t=>e=>e.assetStageCompletionReducer.instances[t],Pc=g(l.createSelector([Ps,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),N=T(t=>t.uuid),Oc=N.getInitialState({}),Os=l.createSlice({name:"assetStages",initialState:Oc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Oc)),reducers:{initializeAssetStages:N.initialize,setAssetStage:N.setOne,setAssetStages:N.setMany,addAssetStage:N.addOne,addAssetStages:N.addMany,updateAssetStage:N.updateOne,updateAssetStages:N.updateMany,deleteAssetStage:N.deleteOne,deleteAssetStages:N.deleteMany}}),{initializeAssetStages:_c,setAssetStage:vc,setAssetStages:xm,addAssetStage:ep,addAssetStages:_s,updateAssetStage:vs,updateAssetStages:nt,deleteAssetStage:tp,deleteAssetStages:ws}=Os.actions,wc=Os.reducer,ct=t=>t.assetStageReducer.instances,Ec=t=>e=>e.assetStageReducer.instances[t],jc=l.createSelector([ct],t=>Object.values(t)),sp=g(l.createSelector([ct,(t,e)=>e],(t,e)=>{const s={};for(const[a,n]of Object.entries(t))n.asset_procedure===e&&(s[a]=n);return Ee(s)})),ip=g(l.createSelector([jc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Es=g(l.createSelector([ct,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectStagesFromStageIds: No stage exists with the id",a)}return S(s)})),J=T(t=>t.uuid),qc=J.getInitialState({}),js=l.createSlice({name:"assetTypeAttachments",initialState:qc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,qc)),reducers:{initializeAssetTypeAttachments:J.initialize,addAssetTypeAttachment:J.addOne,addAssetTypeAttachments:J.addMany,setAssetTypeAttachment:J.setOne,setAssetTypeAttachments:J.setMany,updateAssetTypeAttachment:J.updateOne,updateAssetTypeAttachments:J.updateMany,deleteAssetTypeAttachment:J.deleteOne,deleteAssetTypeAttachments:J.deleteMany}}),{initializeAssetTypeAttachments:Mc,addAssetTypeAttachment:ap,addAssetTypeAttachments:qs,setAssetTypeAttachment:kc,setAssetTypeAttachments:np,updateAssetTypeAttachment:cp,updateAssetTypeAttachments:Cc,deleteAssetTypeAttachment:zc,deleteAssetTypeAttachments:Ms}=js.actions,Dc=t=>t.assetTypeAttachmentReducer.instances,Uc=l.createSelector([Dc],t=>Object.values(t)),Vc=t=>e=>e.assetTypeAttachmentReducer.instances[t],Gc=g(l.createSelector([Uc,(t,e)=>e],(t,e)=>S(t.filter(({asset_type:s})=>e===s)))),$c=js.reducer,H=T(t=>t.uuid),Lc=H.getInitialState({}),ks=l.createSlice({name:"assetTypeFieldsAttachments",initialState:Lc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lc)),reducers:{initializeAssetTypeFieldsAttachments:H.initialize,addAssetTypeFieldsAttachment:H.addOne,addAssetTypeFieldsAttachments:H.addMany,setAssetTypeFieldsAttachment:H.setOne,setAssetTypeFieldsAttachments:H.setMany,updateAssetTypeFieldsAttachment:H.updateOne,updateAssetTypeFieldsAttachments:H.updateMany,deleteAssetTypeFieldsAttachment:H.deleteOne,deleteAssetTypeFieldsAttachments:H.deleteMany}}),{initializeAssetTypeFieldsAttachments:Bc,addAssetTypeFieldsAttachment:rp,addAssetTypeFieldsAttachments:Nc,setAssetTypeFieldsAttachment:dp,setAssetTypeFieldsAttachments:op,updateAssetTypeFieldsAttachment:up,updateAssetTypeFieldsAttachments:Jc,deleteAssetTypeFieldsAttachment:lp,deleteAssetTypeFieldsAttachments:Hc}=ks.actions,Wc=t=>t.assetTypeFieldsAttachmentReducer.instances,Kc=l.createSelector([Wc],t=>Object.values(t)),hp=g(l.createSelector([Kc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),mp=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Yc=ks.reducer,W=T(t=>t.uuid),Xc=W.getInitialState({}),Cs=l.createSlice({name:"assetTypeFields",initialState:Xc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Xc)),reducers:{initializeAssetTypeFields:W.initialize,addAssetTypeFields:W.addOne,addAssetTypeFieldsMany:W.addMany,setAssetTypeFields:W.setOne,setAssetTypeFieldsMany:W.setMany,updateAssetTypeFields:W.updateOne,updateAssetTypeFieldsMany:W.updateMany,deleteAssetTypeFields:W.deleteOne,deleteAssetTypeFieldsMany:W.deleteMany}}),{initializeAssetTypeFields:Qc,addAssetTypeFields:Zc,addAssetTypeFieldsMany:pp,setAssetTypeFields:Ap,setAssetTypeFieldsMany:yp,updateAssetTypeFields:xc,updateAssetTypeFieldsMany:fp,deleteAssetTypeFields:er,deleteAssetTypeFieldsMany:Sp}=Cs.actions,tr=t=>t.assetTypeFieldsReducer.instances,rt=l.createSelector([tr],t=>Object.values(t)),gp=g(l.createSelector([rt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),bp=g(l.createSelector([rt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,a)=>s.submitted_at>a.submitted_at?-1:1)[0])),Tp=t=>e=>e.assetTypeFieldsReducer.instances[t],sr=Cs.reducer,K=T(t=>t.uuid),ir=K.getInitialState({}),zs=l.createSlice({name:"assetTypeFieldValuesAttachments",initialState:ir,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ir)),reducers:{initializeAssetTypeFieldValuesAttachments:K.initialize,addAssetTypeFieldValuesAttachment:K.addOne,addAssetTypeFieldValuesAttachments:K.addMany,setAssetTypeFieldValuesAttachment:K.setOne,setAssetTypeFieldValuesAttachments:K.setMany,updateAssetTypeFieldValuesAttachment:K.updateOne,updateAssetTypeFieldValuesAttachments:K.updateMany,deleteAssetTypeFieldValuesAttachment:K.deleteOne,deleteAssetTypeFieldValuesAttachments:K.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:ar,addAssetTypeFieldValuesAttachment:Fp,addAssetTypeFieldValuesAttachments:dt,setAssetTypeFieldValuesAttachment:Ip,setAssetTypeFieldValuesAttachments:Rp,updateAssetTypeFieldValuesAttachment:Pp,updateAssetTypeFieldValuesAttachments:nr,deleteAssetTypeFieldValuesAttachment:Op,deleteAssetTypeFieldValuesAttachments:ot}=zs.actions,Ds=t=>t.assetTypeFieldValuesAttachmentReducer.instances,cr=l.createSelector([Ds],t=>Object.values(t)),_p=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],rr=g(l.createSelector([Ds,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),dr=g(l.createSelector([cr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),or=zs.reducer,Y=T(t=>t.uuid),ur=Y.getInitialState({}),Us=l.createSlice({name:"assetTypeFieldValues",initialState:ur,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ur)),reducers:{initializeAssetTypeFieldValues:Y.initialize,addAssetTypeFieldValues:Y.addOne,addAssetTypeFieldValuesMany:Y.addMany,setAssetTypeFieldValues:Y.setOne,setAssetTypeFieldValuesMany:Y.setMany,updateAssetTypeFieldValues:Y.updateOne,updateAssetTypeFieldValuesMany:Y.updateMany,deleteAssetTypeFieldValues:Y.deleteOne,deleteAssetTypeFieldValuesMany:Y.deleteMany}}),{initializeAssetTypeFieldValues:lr,addAssetTypeFieldValues:Vs,addAssetTypeFieldValuesMany:hr,setAssetTypeFieldValues:vp,setAssetTypeFieldValuesMany:wp,updateAssetTypeFieldValues:Ne,updateAssetTypeFieldValuesMany:mr,deleteAssetTypeFieldValues:Gs,deleteAssetTypeFieldValuesMany:pr}=Us.actions,Ar=t=>t.assetTypeFieldValuesReducer.instances,$s=l.createSelector([Ar],t=>Object.values(t)),Ep=g(l.createSelector([$s,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),jp=g(l.createSelector([rt,$s,(t,e)=>e],(t,e,s)=>{const a=new Set(t.filter(n=>n.asset_type===s).map(n=>n.uuid));return S(e.filter(n=>a.has(n.fields_revision)))})),Ls=t=>e=>e.assetTypeFieldValuesReducer.instances[t],yr=Us.reducer,X=T(t=>t.uuid),fr=X.getInitialState({}),Bs=l.createSlice({name:"assetTypes",initialState:fr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,fr)),reducers:{initializeAssetTypes:X.initialize,setAssetType:X.setOne,setAssetTypes:X.setMany,addAssetType:X.addOne,addAssetTypes:X.addMany,updateAssetType:X.updateOne,updateAssetTypes:X.updateMany,deleteAssetType:X.deleteOne,deleteAssetTypes:X.deleteMany}}),{initializeAssetTypes:Sr,setAssetType:qp,setAssetTypes:Mp,addAssetType:Ns,addAssetTypes:kp,updateAssetType:Je,updateAssetTypes:Cp,deleteAssetType:Js,deleteAssetTypes:zp}=Bs.actions,Hs=t=>t.assetTypeReducer.instances,Dp=l.createSelector([Hs],t=>Object.values(t)),Ws=t=>e=>e.assetTypeReducer.instances[t],Up=g(l.createSelector([Hs,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectAssetTypesByIds: No assetType exists with the id",a)}return S(s)})),gr=Bs.reducer,br={accessToken:"",refreshToken:"",isLoggedIn:!1},ut=l.createSlice({name:"auth",initialState:br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,br)),reducers:{setTokens:(t,e)=>{t.accessToken=e.payload.accessToken,t.refreshToken=e.payload.refreshToken},clearTokens:t=>{t.accessToken="",t.refreshToken=""},setLoggedIn:(t,e)=>{e.payload||ut.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Vp,clearTokens:Gp,setLoggedIn:Tr}=ut.actions,$p=t=>t.authReducer.accessToken,Lp=t=>t.authReducer.isLoggedIn,Fr=ut.reducer,He=T(t=>t.uuid),Ir=He.getInitialState({}),Ks=l.createSlice({name:"categories",initialState:Ir,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ir)),reducers:{initializeCategories:He.initialize,addCategory:He.addOne,updateCategory:He.updateOne,deleteCategory:He.deleteOne}}),{initializeCategories:Rr,addCategory:Ys,updateCategory:Pr,deleteCategory:Or}=Ks.actions,Xs=t=>t.categoryReducer.instances,Bp=l.createSelector([Xs],t=>Object.values(t)),Qs=t=>e=>e.categoryReducer.instances[t],Np=g(l.createSelector([Xs,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectCategoryByIds: No category exists with the id",a)}return S(s)})),Jp=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,_r=Ks.reducer,Q=T(t=>t.uuid),vr=Q.getInitialState({}),Zs=l.createSlice({name:"documentAttachments",initialState:vr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vr)),reducers:{initializeDocumentAttachments:Q.initialize,addDocumentAttachment:Q.addOne,addDocumentAttachments:Q.addMany,setDocumentAttachment:Q.setOne,setDocumentAttachments:Q.setMany,updateDocumentAttachment:Q.updateOne,updateDocumentAttachments:Q.updateMany,deleteDocumentAttachment:Q.deleteOne,deleteDocumentAttachments:Q.deleteMany}}),{initializeDocumentAttachments:wr,addDocumentAttachment:Hp,addDocumentAttachments:Er,setDocumentAttachment:jr,setDocumentAttachments:Wp,updateDocumentAttachment:Kp,updateDocumentAttachments:qr,deleteDocumentAttachment:Mr,deleteDocumentAttachments:kr}=Zs.actions,Cr=t=>t.documentAttachmentReducer.instances,zr=l.createSelector([Cr],t=>Object.values(t)),Dr=t=>e=>e.documentAttachmentReducer.instances[t],Yp=g(l.createSelector([zr,(t,e)=>e],(t,e)=>S(t.filter(({document:s})=>e===s)))),Ur=Zs.reducer,Vr={documents:{}},xs=l.createSlice({name:"documents",initialState:Vr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Vr)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(tn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=en(e.payload)},addDocuments:(t,e)=>{for(const s of e.payload)if(s.uuid in t.documents)throw new Error(`attempting to add a document with uuid ${s.uuid} which already exists in state.documents.`);for(const s of e.payload){if(s.parent_document&&t.documents[s.parent_document]){const a=t.documents[s.parent_document];t.documents[s.parent_document]={...a,children_documents:[...a.children_documents,s.uuid]}}t.documents[s.uuid]=s}},updateDocuments:(t,e)=>{for(const s of e.payload)if(!(s.uuid in t.documents))throw new Error(`attempting to update a document with uuid ${s.uuid} which doesn't exists in state.documents.`);for(const s of e.payload){const a=t.documents[s.uuid];if(s.organization!==void 0&&s.organization!==a.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==a.project)throw new Error("project cannot be updated");t.documents[s.uuid]={...a,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:a,position:n}=e.payload;if(!(s in t.documents))throw new Error(`attempting to move a document with uuid ${s} which doesn't exist in state.documents`);const c=t.documents[s];if(c.parent_document&&t.documents[c.parent_document]){const{children_documents:r}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(r.indexOf(c.uuid),1)}if(a){const r=t.documents[a],o=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(n){case"left":if(!o)throw new Error("attempting to move a document to the left of a document with no parent_document");t.documents[r.parent_document].children_documents.splice(o.children_documents.indexOf(r.uuid),0,c.uuid),t.documents[s].parent_document=o.uuid;break;case"right":if(!o)throw new Error("attempting to move a document to the left of a document with no parent_document");t.documents[r.parent_document].children_documents.splice(o.children_documents.indexOf(r.uuid)+1,0,c.uuid),t.documents[s].parent_document=o.uuid;break;case"left-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[a].children_documents.unshift(c.uuid),t.documents[s].parent_document=r.uuid;break;case"right-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[a].children_documents.push(c.uuid),t.documents[s].parent_document=r.uuid}}else t.documents[s].parent_document=null},removeDocuments:(t,e)=>{for(const s of e.payload)if(!(s in t.documents))throw new Error(`attempting to delete a document with uuid ${s} which doesn't exists in state.documents.`);for(const s of e.payload){const a=t.documents[s];if(a.parent_document&&t.documents[a.parent_document]){const n=t.documents[a.parent_document];t.documents[a.parent_document]={...n,children_documents:n.children_documents.filter(c=>c!==a.uuid)}}delete t.documents[s]}}}}),{setDocuments:Gr,addDocuments:$r,updateDocuments:ge,moveDocument:Lr,removeDocuments:ei}=xs.actions,qe=t=>t.documentsReducer.documents,Br=l.createSelector([qe],t=>Object.values(t)),Nr=t=>e=>e.documentsReducer.documents[t],Xp=g(l.createSelector([qe,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectDocumentByIds: No document exists with the id",a)}return S(s)})),Qp=g(l.createSelector([qe,(t,e)=>e],(t,e)=>{const s=[],a=t[e];if(!a||!a.parent_document)return s;let n=t[a.parent_document];for(;n;)s.push(n.uuid),n=t[n.parent_document??""];return S(s)})),Zp=l.createSelector([Br],t=>S(t.filter(e=>!e.parent_document))),Jr=xs.reducer,lt=T(t=>t.uuid),xp=lt.getInitialState({}),ti=l.createSlice({name:"emailDomains",initialState:xp,reducers:{initializeEmailDomains:lt.initialize,addEmailDomain:lt.addOne,deleteEmailDomain:lt.deleteOne}}),{initializeEmailDomains:Hr,addEmailDomain:Wr,deleteEmailDomain:Kr}=ti.actions,Yr=t=>t.emailDomainsReducer.instances,Xr=l.createSelector([Yr],t=>Object.values(t)),eA=g(l.createSelector([Xr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),Qr=ti.reducer,Zr={s3Urls:{}},xr=1e3*60*60,tA=xr*24*7,si=l.createSlice({name:"file",initialState:Zr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zr)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:a,sha1:n}=e.payload,c=new Date,r=new Date(c.getTime()+tA);t.s3Urls[n]={url:s,fields:a,exp:r.getTime()}}}}),{setUploadUrl:ed}=si.actions,td=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const a=new Date().getTime();if(!((s.exp??a)-a<xr))return s},sd=si.reducer,Z=T(t=>t.uuid),id=Z.getInitialState({}),ii=l.createSlice({name:"formRevisionAttachments",initialState:id,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,id)),reducers:{initializeFormRevisionAttachments:Z.initialize,addFormRevisionAttachment:Z.addOne,addFormRevisionAttachments:Z.addMany,setFormRevisionAttachment:Z.setOne,setFormRevisionAttachments:Z.setMany,updateFormRevisionAttachment:Z.updateOne,updateFormRevisionAttachments:Z.updateMany,deleteFormRevisionAttachment:Z.deleteOne,deleteFormRevisionAttachments:Z.deleteMany}}),{initializeFormRevisionAttachments:ad,addFormRevisionAttachment:sA,addFormRevisionAttachments:nd,setFormRevisionAttachment:iA,setFormRevisionAttachments:aA,updateFormRevisionAttachment:nA,updateFormRevisionAttachments:cd,deleteFormRevisionAttachment:cA,deleteFormRevisionAttachments:rd}=ii.actions,dd=t=>t.formRevisionAttachmentReducer.instances,rA=g(l.createSelector([dd,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_revision===e)))),od=ii.reducer,dA=(t,e)=>{const s=t.revision,a=e.revision;return s===void 0&&a===void 0?t.submitted_at<e.submitted_at?-1:1:s===void 0?1:a===void 0||s<a?-1:1},Fe=T(t=>t.uuid),ud=Fe.getInitialState({}),ai=l.createSlice({name:"formRevisions",initialState:ud,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ud)),reducers:{initializeFormRevisions:Fe.initialize,setFormRevision:Fe.setOne,addFormRevision:Fe.addOne,addFormRevisions:Fe.addMany,deleteFormRevision:Fe.deleteOne,deleteFormRevisions:Fe.deleteMany}}),{setFormRevision:ld,initializeFormRevisions:hd,addFormRevision:ni,addFormRevisions:md,deleteFormRevision:ci,deleteFormRevisions:pd}=ai.actions,ht=t=>t.formRevisionReducer.instances,Ad=l.createSelector([ht],t=>Object.values(t)),oA=t=>e=>e.formRevisionReducer.instances[t],uA=g(l.createSelector([ht,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const n=s.sort(dA)[s.length-1];return t[n.uuid]})),yd=g(l.createSelector([Ad,(t,e)=>e],(t,e)=>S(t.filter(s=>s.form===e)))),fd=ai.reducer,Ie=T(t=>t.uuid),Sd=Ie.getInitialState({}),ri=l.createSlice({name:"forms",initialState:Sd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sd)),reducers:{initializeForms:Ie.initialize,setForm:Ie.setOne,addForm:Ie.addOne,addForms:Ie.addMany,updateForm:Ie.updateOne,deleteForm:Ie.deleteOne}}),{initializeForms:gd,setForm:lA,addForm:di,addForms:hA,updateForm:mA,deleteForm:oi}=ri.actions,bd=ri.reducer,Td=t=>t.formReducer.instances,pA=l.createSelector([Td],t=>Object.values(t)),Fd=t=>e=>e.formReducer.instances[t],x=T(t=>t.uuid),Id=x.getInitialState({}),ui=l.createSlice({name:"formSubmissionAttachments",initialState:Id,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Id)),reducers:{initializeFormSubmissionAttachments:x.initialize,addFormSubmissionAttachment:x.addOne,addFormSubmissionAttachments:x.addMany,setFormSubmissionAttachment:x.setOne,setFormSubmissionAttachments:x.setMany,updateFormSubmissionAttachment:x.updateOne,updateFormSubmissionAttachments:x.updateMany,deleteFormSubmissionAttachment:x.deleteOne,deleteFormSubmissionAttachments:x.deleteMany}}),{initializeFormSubmissionAttachments:Rd,addFormSubmissionAttachment:AA,addFormSubmissionAttachments:mt,setFormSubmissionAttachment:yA,setFormSubmissionAttachments:fA,updateFormSubmissionAttachment:SA,updateFormSubmissionAttachments:Pd,deleteFormSubmissionAttachment:gA,deleteFormSubmissionAttachments:pt}=ui.actions,li=t=>t.formSubmissionAttachmentReducer.instances,Od=g(l.createSelector([li,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),_d=g(l.createSelector([li,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_submission===e)))),vd=ui.reducer,ee=T(t=>t.uuid),wd=ee.getInitialState({}),hi=l.createSlice({name:"formSubmissions",initialState:wd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wd)),reducers:{initializeFormSubmissions:ee.initialize,setFormSubmission:ee.setOne,setFormSubmissions:ee.setMany,addFormSubmission:ee.addOne,addFormSubmissions:ee.addMany,updateFormSubmission:ee.updateOne,updateFormSubmissions:ee.updateMany,deleteFormSubmission:ee.deleteOne,deleteFormSubmissions:ee.deleteMany}}),{initializeFormSubmissions:Ed,setFormSubmission:At,setFormSubmissions:bA,addFormSubmission:mi,addFormSubmissions:yt,updateFormSubmission:jd,updateFormSubmissions:TA,deleteFormSubmission:pi,deleteFormSubmissions:ft}=hi.actions,Ai=t=>t.formSubmissionReducer.instances,yi=l.createSelector([Ai],t=>Object.values(t)),fi=t=>e=>e.formSubmissionReducer.instances[t],qd=g(l.createSelector([Ai,ht,(t,e)=>e],(t,e,s)=>{const a=new Set;for(const n of Object.values(e))n.form===s&&a.add(n.uuid);return Object.values(t).filter(n=>a.has(n.form_revision))})),Md=g(l.createSelector([yi,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),kd=g(l.createSelector([yi,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),Cd=hi.reducer,te=T(t=>t.uuid),zd=te.getInitialState({}),Si=l.createSlice({name:"geoImages",initialState:zd,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,zd)})},reducers:{initializeGeoImages:te.initialize,setGeoImage:te.setOne,setGeoImages:te.setMany,addGeoImage:te.addOne,addGeoImages:te.addMany,updateGeoImage:te.updateOne,updateGeoImages:te.updateMany,deleteGeoImage:te.deleteOne,deleteGeoImages:te.deleteMany}}),{initializeGeoImages:Dd,setGeoImage:We,setGeoImages:Ud,addGeoImage:Vd,addGeoImages:Gd,updateGeoImage:$d,updateGeoImages:FA,deleteGeoImage:gi,deleteGeoImages:Ld}=Si.actions,Bd=t=>t.geoImageReducer.instances,Nd=l.createSelector([Bd],t=>Object.values(t)),bi=t=>e=>e.geoImageReducer.instances[t],IA=g(l.createSelector([Nd,(t,e)=>e],(t,e)=>S(t.filter(s=>s.project===e)))),Jd=Si.reducer,se=T(t=>t.uuid),Hd=se.getInitialState({}),Ti=l.createSlice({name:"geoJsonFeatures",initialState:Hd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Hd)),reducers:{initializeGeoJsonFeatures:se.initialize,addGeoJsonFeature:se.addOne,addGeoJsonFeatures:se.addMany,setGeoJsonFeature:se.setOne,setGeoJsonFeatures:se.setMany,updateGeoJsonFeature:se.updateOne,updateGeoJsonFeatures:se.updateMany,deleteGeoJsonFeature:se.deleteOne,deleteGeoJsonFeatures:se.deleteMany}}),{initializeGeoJsonFeatures:Wd,addGeoJsonFeature:Fi,addGeoJsonFeatures:Kd,updateGeoJsonFeature:Ke,updateGeoJsonFeatures:RA,deleteGeoJsonFeature:Ii,deleteGeoJsonFeatures:Yd,setGeoJsonFeature:PA,setGeoJsonFeatures:OA}=Ti.actions,Ri=t=>t.geoJsonFeatureReducer.instances,Xd=l.createSelector([Ri],t=>S(Object.values(t))),Qd=g(l.createSelector([Xd,(t,e)=>e],(t,e)=>S(t.filter(s=>s.geojson_layer===e)))),Pi=t=>e=>e.geoJsonFeatureReducer.instances[t],_A=g(l.createSelector([Ri,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),Zd=Ti.reducer,ie=T(t=>t.uuid),xd=ie.getInitialState({}),Oi=l.createSlice({name:"geoJsonLayers",initialState:xd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,xd)),reducers:{initializeGeoJsonLayers:ie.initialize,addGeoJsonLayer:ie.addOne,addGeoJsonLayers:ie.addMany,setGeoJsonLayer:ie.setOne,setGeoJsonLayers:ie.setMany,updateGeoJsonLayer:ie.updateOne,updateGeoJsonLayers:ie.updateMany,deleteGeoJsonLayer:ie.deleteOne,deleteGeoJsonLayers:ie.deleteMany}}),{initializeGeoJsonLayers:eo,addGeoJsonLayer:_i,addGeoJsonLayers:vA,updateGeoJsonLayer:Ye,updateGeoJsonLayers:wA,deleteGeoJsonLayer:vi,deleteGeoJsonLayers:EA,setGeoJsonLayer:jA,setGeoJsonLayers:qA}=Oi.actions,wi=t=>t.geoJsonLayerReducer.instances,to=l.createSelector([wi],t=>S(Object.values(t))),MA=g(l.createSelector([to,(t,e)=>e],(t,e)=>S(t.filter(s=>s.project===e)))),Ei=t=>e=>e.geoJsonLayerReducer.instances[t],kA=g(l.createSelector([wi,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),so=Oi.reducer,ae=T(t=>t.uuid),io=ae.getInitialState({}),ji=l.createSlice({name:"issueAssociations",initialState:io,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,io)),reducers:{initializeIssueAssociations:ae.initialize,addIssueAssociation:ae.addOne,addIssueAssociations:ae.addMany,setIssueAssociation:ae.setOne,setIssueAssociations:ae.setMany,updateIssueAssociation:ae.updateOne,updateIssueAssociations:ae.updateMany,deleteIssueAssociation:ae.deleteOne,deleteIssueAssociations:ae.deleteMany}}),{initializeIssueAssociations:ao,setIssueAssociations:CA,setIssueAssociation:zA,updateIssueAssociation:no,updateIssueAssociations:DA,addIssueAssociation:qi,addIssueAssociations:Mi,deleteIssueAssociation:ki,deleteIssueAssociations:Ci}=ji.actions,Xe=t=>t.issueAssociationReducer.instances,UA=l.createSelector([Xe],t=>Object.values(t)),co=t=>e=>e.issueAssociationReducer.instances[t],ro=g(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.associated_issue===e)))),oo=g(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),uo=g(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.asset===e)))),lo=ji.reducer,ne=T(t=>t.uuid),ho=ne.getInitialState({}),zi=l.createSlice({name:"issueAttachments",initialState:ho,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ho)),reducers:{initializeIssueAttachments:ne.initialize,addIssueAttachment:ne.addOne,addIssueAttachments:ne.addMany,setIssueAttachment:ne.setOne,setIssueAttachments:ne.setMany,updateIssueAttachment:ne.updateOne,updateIssueAttachments:ne.updateMany,deleteIssueAttachment:ne.deleteOne,deleteIssueAttachments:ne.deleteMany}}),{initializeIssueAttachments:Di,addIssueAttachment:VA,addIssueAttachments:Ui,setIssueAttachment:mo,setIssueAttachments:GA,updateIssueAttachment:$A,updateIssueAttachments:po,deleteIssueAttachment:Ao,deleteIssueAttachments:Vi}=zi.actions,yo=t=>t.issueAttachmentReducer.instances,fo=l.createSelector([yo],t=>Object.values(t)),So=g(l.createSelector([fo,(t,e)=>e],(t,e)=>S(t.filter(({issue:s})=>e===s)))),go=t=>e=>e.issueAttachmentReducer.instances[t],bo=zi.reducer,ce=T(t=>t.uuid),To=ce.getInitialState({}),Gi=l.createSlice({name:"issueCommentAttachments",initialState:To,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,To)),reducers:{initializeIssueCommentAttachments:ce.initialize,addIssueCommentAttachment:ce.addOne,addIssueCommentAttachments:ce.addMany,setIssueCommentAttachment:ce.setOne,setIssueCommentAttachments:ce.setMany,updateIssueCommentAttachment:ce.updateOne,updateIssueCommentAttachments:ce.updateMany,deleteIssueCommentAttachment:ce.deleteOne,deleteIssueCommentAttachments:ce.deleteMany}}),{initializeIssueCommentAttachments:$i,addIssueCommentAttachment:LA,addIssueCommentAttachments:Fo,setIssueCommentAttachment:Io,setIssueCommentAttachments:BA,updateIssueCommentAttachment:NA,updateIssueCommentAttachments:Ro,deleteIssueCommentAttachment:Po,deleteIssueCommentAttachments:Oo}=Gi.actions,_o=t=>t.issueCommentAttachmentReducer.instances,vo=l.createSelector([_o],t=>Object.values(t)),wo=t=>e=>e.issueCommentAttachmentReducer.instances[t],JA=g(l.createSelector([vo,(t,e)=>e],(t,e)=>S(t.filter(({issue_comment:s})=>e===s)))),Eo=Gi.reducer,Re=T(t=>t.uuid),jo=Re.getInitialState({}),Li=l.createSlice({name:"issueComments",initialState:jo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jo)),reducers:{addIssueComment:Re.addOne,addIssueComments:Re.addMany,setIssueComment:Re.setOne,setIssueComments:Re.setMany,deleteIssueComment:Re.deleteOne,deleteIssueComments:Re.deleteMany}}),{setIssueComments:qo,setIssueComment:Bi,addIssueComment:Ni,addIssueComments:HA,deleteIssueComment:Ji,deleteIssueComments:WA}=Li.actions,Mo=t=>t.issueCommentReducer.instances,Hi=t=>e=>e.issueCommentReducer.instances[t],KA=g(l.createSelector([Mo,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),ko=Li.reducer,Pe=T(t=>t.uuid),Co=Pe.getInitialState({}),Wi=l.createSlice({name:"issues",initialState:Co,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Co)}),reducers:{initializeIssues:Pe.initialize,addIssue:Pe.addOne,addIssues:Pe.addMany,updateIssue:Pe.updateOne,deleteIssue:Pe.deleteOne,deleteIssues:Pe.deleteMany}}),{initializeIssues:zo,addIssue:Ki,addIssues:Do,updateIssue:St,deleteIssue:Yi,deleteIssues:Uo}=Wi.actions,Vo=t=>t.issueReducer.instances,Xi=t=>e=>e.issueReducer.instances[t],YA=g(l.createSelector([Vo,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectIssuesByIds: No issue exists with the id",a)}return S(s)})),Go=Wi.reducer,re=T(t=>t.uuid),$o=re.getInitialState({}),Qi=l.createSlice({name:"issueTypeAttachments",initialState:$o,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,$o)),reducers:{initializeIssueTypeAttachments:re.initialize,addIssueTypeAttachment:re.addOne,addIssueTypeAttachments:re.addMany,setIssueTypeAttachment:re.setOne,setIssueTypeAttachments:re.setMany,updateIssueTypeAttachment:re.updateOne,updateIssueTypeAttachments:re.updateMany,deleteIssueTypeAttachment:re.deleteOne,deleteIssueTypeAttachments:re.deleteMany}}),{initializeIssueTypeAttachments:Zi,addIssueTypeAttachment:XA,addIssueTypeAttachments:Lo,setIssueTypeAttachment:Bo,setIssueTypeAttachments:QA,updateIssueTypeAttachment:ZA,updateIssueTypeAttachments:No,deleteIssueTypeAttachment:Jo,deleteIssueTypeAttachments:Ho}=Qi.actions,Wo=t=>t.issueTypeAttachmentReducer.instances,Ko=l.createSelector([Wo],t=>Object.values(t)),Yo=t=>e=>e.issueTypeAttachmentReducer.instances[t],xA=g(l.createSelector([Ko,(t,e)=>e],(t,e)=>S(t.filter(({issue_type:s})=>e===s)))),Xo=Qi.reducer,de=T(t=>t.uuid),Qo=de.getInitialState({}),xi=l.createSlice({name:"issueTypeFieldsAttachments",initialState:Qo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qo)),reducers:{initializeIssueTypeFieldsAttachments:de.initialize,addIssueTypeFieldsAttachment:de.addOne,addIssueTypeFieldsAttachments:de.addMany,setIssueTypeFieldsAttachment:de.setOne,setIssueTypeFieldsAttachments:de.setMany,updateIssueTypeFieldsAttachment:de.updateOne,updateIssueTypeFieldsAttachments:de.updateMany,deleteIssueTypeFieldsAttachment:de.deleteOne,deleteIssueTypeFieldsAttachments:de.deleteMany}}),{initializeIssueTypeFieldsAttachments:Zo,addIssueTypeFieldsAttachment:ey,addIssueTypeFieldsAttachments:xo,setIssueTypeFieldsAttachment:ty,setIssueTypeFieldsAttachments:sy,updateIssueTypeFieldsAttachment:iy,updateIssueTypeFieldsAttachments:eu,deleteIssueTypeFieldsAttachment:ay,deleteIssueTypeFieldsAttachments:tu}=xi.actions,su=t=>t.issueTypeFieldsAttachmentReducer.instances,iu=l.createSelector([su],t=>Object.values(t)),ny=g(l.createSelector([iu,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),cy=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],au=xi.reducer,oe=T(t=>t.uuid),nu=oe.getInitialState({}),ea=l.createSlice({name:"issueTypeFieldValues",initialState:nu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,nu)),reducers:{initializeIssueTypeFieldValues:oe.initialize,addIssueTypeFieldValues:oe.addOne,addIssueTypeFieldValuesMany:oe.addMany,setIssueTypeFieldValues:oe.setOne,setIssueTypeFieldValuesMany:oe.setMany,updateIssueTypeFieldValues:oe.updateOne,updateIssueTypeFieldValuesMany:oe.updateMany,deleteIssueTypeFieldValues:oe.deleteOne,deleteIssueTypeFieldValuesMany:oe.deleteMany}}),{initializeIssueTypeFieldValues:cu,addIssueTypeFieldValues:ta,addIssueTypeFieldValuesMany:ry,setIssueTypeFieldValues:dy,setIssueTypeFieldValuesMany:oy,updateIssueTypeFieldValues:Qe,updateIssueTypeFieldValuesMany:uy,deleteIssueTypeFieldValues:sa,deleteIssueTypeFieldValuesMany:ly}=ea.actions,ru=t=>t.issueTypeFieldValuesReducer.instances,ia=l.createSelector([ru],t=>Object.values(t)),hy=g(l.createSelector([ia,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue===e)))),aa=t=>e=>e.issueTypeFieldValuesReducer.instances[t],du=ea.reducer,ue=T(t=>t.uuid),ou=ue.getInitialState({}),na=l.createSlice({name:"issueTypeFields",initialState:ou,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ou)),reducers:{initializeIssueTypeFields:ue.initialize,addIssueTypeFields:ue.addOne,addIssueTypeFieldsMany:ue.addMany,setIssueTypeFields:ue.setOne,setIssueTypeFieldsMany:ue.setMany,updateIssueTypeFields:ue.updateOne,updateIssueTypeFieldsMany:ue.updateMany,deleteIssueTypeFields:ue.deleteOne,deleteIssueTypeFieldsMany:ue.deleteMany}}),{initializeIssueTypeFields:uu,addIssueTypeFields:lu,addIssueTypeFieldsMany:my,setIssueTypeFields:py,setIssueTypeFieldsMany:Ay,updateIssueTypeFields:hu,updateIssueTypeFieldsMany:yy,deleteIssueTypeFields:mu,deleteIssueTypeFieldsMany:fy}=na.actions,pu=t=>t.issueTypeFieldsReducer.instances,gt=l.createSelector([pu],t=>Object.values(t)),Sy=g(l.createSelector([gt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue_type===e)))),gy=g(l.createSelector([gt,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,a)=>s.submitted_at>a.submitted_at?-1:1)[0])),by=g(l.createSelector([gt,ia,(t,e)=>e],(t,e,s)=>{const a=new Set(t.filter(n=>n.issue_type===s).map(n=>n.uuid));return S(e.filter(n=>a.has(n.fields_revision)))})),Ty=t=>e=>e.issueTypeFieldsReducer.instances[t],Au=na.reducer,le=T(t=>t.uuid),yu=le.getInitialState({}),ca=l.createSlice({name:"issueTypeFieldValuesAttachments",initialState:yu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,yu)),reducers:{initializeIssueTypeFieldValuesAttachments:le.initialize,addIssueTypeFieldValuesAttachment:le.addOne,addIssueTypeFieldValuesAttachments:le.addMany,setIssueTypeFieldValuesAttachment:le.setOne,setIssueTypeFieldValuesAttachments:le.setMany,updateIssueTypeFieldValuesAttachment:le.updateOne,updateIssueTypeFieldValuesAttachments:le.updateMany,deleteIssueTypeFieldValuesAttachment:le.deleteOne,deleteIssueTypeFieldValuesAttachments:le.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:fu,addIssueTypeFieldValuesAttachment:Fy,addIssueTypeFieldValuesAttachments:bt,setIssueTypeFieldValuesAttachment:Iy,setIssueTypeFieldValuesAttachments:Ry,updateIssueTypeFieldValuesAttachment:Py,updateIssueTypeFieldValuesAttachments:Su,deleteIssueTypeFieldValuesAttachment:Oy,deleteIssueTypeFieldValuesAttachments:Tt}=ca.actions,ra=t=>t.issueTypeFieldValuesAttachmentReducer.instances,gu=l.createSelector([ra],t=>Object.values(t)),_y=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],bu=g(l.createSelector([ra,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),Tu=g(l.createSelector([gu,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),Fu=ca.reducer,Me=T(t=>t.uuid),Iu=Me.getInitialState({}),da=l.createSlice({name:"issueTypes",initialState:Iu,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Iu)}),reducers:{initializeIssueTypes:Me.initialize,setIssueType:Me.setOne,addIssueType:Me.addOne,updateIssueType:Me.updateOne,removeIssueType:Me.deleteOne}}),{initializeIssueTypes:Ru,setIssueType:Ze,addIssueType:Pu,updateIssueType:Ou,removeIssueType:oa}=da.actions,_u=t=>t.issueTypeReducer.instances,vu=l.createSelector(_u,t=>Object.values(t)),ua=t=>e=>e.issueTypeReducer.instances[t],vy=t=>e=>{const s=[];for(const a of t){const n=e.issueTypeReducer.instances[a];n?s.push(n):console.warn("selectIssueTypesByIds: No issue type exists with the id",a)}return s},wy=g(l.createSelector([vu,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),la=g(l.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue_type===e)))),Ey=t=>e=>la(t)(e).length,wu=da.reducer,Oe=T(t=>t.uuid),Eu=Oe.getInitialState({}),ha=l.createSlice({name:"issueUpdates",initialState:Eu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Eu)),reducers:{initializeIssueUpdates:Oe.setMany,setIssueUpdate:Oe.setOne,addIssueUpdate:Oe.addOne,addIssueUpdates:Oe.addMany,deleteIssueUpdate:Oe.deleteOne,deleteIssueUpdates:Oe.deleteMany}}),{initializeIssueUpdates:ju,setIssueUpdate:jy,addIssueUpdate:qu,addIssueUpdates:Mu,deleteIssueUpdate:ku,deleteIssueUpdates:Cu}=ha.actions,zu=t=>t.issueUpdateReducer.instances,Du=g(l.createSelector([zu,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),Uu=ha.reducer,Ft=T(t=>t.uuid),Vu=Ft.getInitialState({}),ma=l.createSlice({name:"license",initialState:Vu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vu)),reducers:{initializeLicences:Ft.initialize,addLicenses:Ft.addMany,updateLicense:Ft.updateOne}}),{initializeLicences:Gu,addLicenses:qy,updateLicense:fe}=ma.actions,It=t=>t.licenseReducer.instances,My=t=>e=>e.licenseReducer.instances[t],$u=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),ky=l.createSelector([It],t=>S(Object.values(t).filter(e=>e.is_active))),Cy=l.createSelector([It],t=>Ee(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),Lu=ma.reducer,k=T(t=>t.id),Bu=k.getInitialState({currentUser:null}),pa=l.createSlice({name:"users",initialState:Bu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bu)),reducers:{initializeUsers:k.initialize,setUsers:k.setMany,setUser:k.setOne,addUsers:k.addMany,addUser:k.addOne,updateUsers:k.updateMany,updateUser:k.updateOne,deleteUser:k.deleteOne,deleteUsers:k.deleteMany,removeUser:k.deleteOne,setCurrentUser:(t,e)=>{t.currentUser=e.payload},setProfilePicture:(t,e)=>{if(!t.currentUser)return;t.currentUser.profile.file=e.payload.file??null,t.currentUser.profile.file_sha1=e.payload.file_sha1??null;const s=t.instances[t.currentUser.id];if(!s)throw new Error("Unable to find current user in users slice");s.profile.file=e.payload.file??null,s.profile.file_sha1=e.payload.file_sha1??null}}}),{initializeUsers:Nu,setUsers:zy,setUser:Dy,addUsers:Uy,addUser:Vy,updateUsers:Gy,updateUser:$y,deleteUser:Ly,deleteUsers:By,removeUser:Ju,setCurrentUser:Ny,setProfilePicture:Jy}=pa.actions,Hu=pa.reducer,Rt=t=>t.userReducer.currentUser,Pt=t=>t.userReducer.instances,Hy=t=>e=>e.userReducer.instances[t],Wy=g(l.createSelector([Pt,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectUsersByIds: No user exists with the uuid",a)}return S(s)})),Ot=T(t=>t.uuid),Wu=Ot.getInitialState({}),Aa=l.createSlice({name:"organizationAccess",initialState:Wu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wu)),reducers:{initializeOrganizationAccesses:Ot.initialize,updateOrganizationAccess:Ot.updateOne,deleteOrganizationAccess:Ot.deleteOne}}),{initializeOrganizationAccesses:Ku,updateOrganizationAccess:Yu,deleteOrganizationAccess:Xu}=Aa.actions,ya=t=>t.organizationAccessReducer.instances,Ky=t=>e=>e.organizationAccessReducer.instances[t],Yy=l.createSelector([Rt,ya],(t,e)=>Object.values(e).find(a=>a.user===(t==null?void 0:t.id))??null),Xy=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),Qu=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return Ee(e)},Zu=Aa.reducer,xe=T(t=>t.uuid),xu=xe.getInitialState({}),fa=l.createSlice({name:"projectAccess",initialState:xu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,xu)),reducers:{initializeProjectAccesses:xe.initialize,updateProjectAccess:xe.updateOne,deleteProjectAccess:xe.deleteOne,deleteProjectAccesses:xe.deleteMany}}),{initializeProjectAccesses:Sa,updateProjectAccess:el,deleteProjectAccess:tl,deleteProjectAccesses:sl}=fa.actions,ga=t=>t.projectAccessReducer.instances,il=l.createSelector(ga,t=>Object.values(t)),Qy=t=>e=>e.projectAccessReducer.instances[t],Zy=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),al=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return Ee(e)},nl=fa.reducer,he=T(t=>t.uuid),cl=he.getInitialState({}),ba=l.createSlice({name:"projects",initialState:cl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,cl)),reducers:{initializeProjects:he.initialize,setProjects:he.setMany,setProject:he.setOne,addProjects:he.addMany,addProject:he.addOne,updateProjects:he.updateMany,updateProject:he.updateOne,deleteProject:he.deleteOne,deleteProjects:he.deleteMany,acceptProjectInvite:(t,e)=>{if(e.payload in t.instances)t.instances[e.payload].invited=!1;else throw new Error("Accept project invite: user is not in this project")}}}),{initializeProjects:xy,setProjects:rl,setProject:ef,addProjects:tf,addProject:sf,updateProjects:af,updateProject:dl,deleteProject:ol,deleteProjects:nf,acceptProjectInvite:ul}=ba.actions,ll=ba.reducer,_t=t=>t.projectReducer.instances,cf=l.createSelector([_t],t=>S(Object.values(t))),rf=t=>e=>e.projectReducer.instances[t],hl=l.createSelector([ga],t=>Object.values(t).map(e=>e.user)),ml=l.createSelector([hl,Pt],(t,e)=>t.reduce((s,a)=>({...s,[a]:e[a]}),{})),df=l.createSelector([Rt,ml,al],(t,e,s)=>S(Object.values(e).sort((a,n)=>{if(a.id===(t==null?void 0:t.id))return-1;if(n.id===(t==null?void 0:t.id))return 1;const c=s[a.id],r=s[n.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?a.username.localeCompare(n.username):(c==null?void 0:c.access_level)===jt.ADMIN?-1:1}))),me=T(t=>t.uuid),pl=me.getInitialState({}),Ta=l.createSlice({name:"organizations",initialState:pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pl)),reducers:{initializeOrganizations:me.initialize,setOrganizations:me.setMany,setOrganization:me.setOne,addOrganizations:me.addMany,addOrganization:me.addOne,updateOrganizations:me.updateMany,updateOrganization:me.updateOne,deleteOrganization:me.deleteOne,deleteOrganizations:me.deleteMany}}),{initializeOrganizations:of,setOrganizations:Al,setOrganization:uf,addOrganizations:lf,addOrganization:hf,updateOrganizations:mf,updateOrganization:pf,deleteOrganization:Af,deleteOrganizations:yf}=Ta.actions,yl=t=>t.organizationReducer.instances,fl=l.createSelector([yl],t=>Object.values(t)),ff=t=>e=>e.organizationReducer.instances[t],Sf=l.createSelector([fl],t=>S(Object.values(t).filter(e=>e.has_access))),Sl=l.createSelector([ya],t=>Object.values(t).map(e=>e.user)),gf=g(l.createSelector([_t,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),bf=g(l.createSelector([It,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),gl=l.createSelector([Sl,Pt],(t,e)=>Ee(t.reduce((s,a)=>({...s,[a]:e[a]}),{}))),Tf=l.createSelector([Rt,gl,Qu],(t,e,s)=>S(Object.values(e).sort((a,n)=>{if(a.id===(t==null?void 0:t.id))return-1;if(n.id===(t==null?void 0:t.id))return 1;const c=s[a.id],r=s[n.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?a.username.localeCompare(n.username):(c==null?void 0:c.access_level)===qt.ADMIN?-1:1}))),bl=Ta.reducer,Tl=(t,e,s)=>{const a=t.uuid?t:{...t,uuid:Te.v4()};return{payload:a,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:a,BASE_URL:e,serviceName:s}}}}},Fl={deletedRequests:[],latestRetryTime:0},Fa=l.createSlice({name:"outbox",initialState:Fl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Fl)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...a}=t;return Tl(a,e,s)}},markForDeletion(t,e){t.deletedRequests.push(e.payload)},markAsDeleted(t,e){const s=t.deletedRequests.indexOf(e.payload);s!==-1&&t.deletedRequests.splice(s,1)},_setLatestRetryTime:(t,e)=>{t.latestRetryTime=e.payload}}}),Ff=t=>t.outboxReducer.deletedRequests,If=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Il,markForDeletion:Rf,markAsDeleted:Rl,_setLatestRetryTime:Pl}=Fa.actions,Ol=Fa.reducer,pe=T(t=>t.uuid),_l=pe.getInitialState({}),Ia=l.createSlice({name:"projectAttachments",initialState:_l,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,_l)),reducers:{initializeProjectAttachments:pe.initialize,addProjectAttachment:pe.addOne,addProjectAttachments:pe.addMany,setProjectAttachment:pe.setOne,setProjectAttachments:pe.setMany,updateProjectAttachment:pe.updateOne,updateProjectAttachments:pe.updateMany,deleteProjectAttachment:pe.deleteOne,deleteProjectAttachments:pe.deleteMany}}),{initializeProjectAttachments:vl,addProjectAttachment:Pf,addProjectAttachments:wl,setProjectAttachment:El,setProjectAttachments:jl,updateProjectAttachment:Of,updateProjectAttachments:ql,deleteProjectAttachment:Ml,deleteProjectAttachments:Ra}=Ia.actions,kl=t=>t.projectAttachmentReducer.instances,Cl=l.createSelector([kl],t=>Object.values(t)),zl=t=>e=>e.projectAttachmentReducer.instances[t],Dl=g(l.createSelector([Cl,(t,e)=>e],(t,e)=>S(t.filter(({project:s})=>e===s)))),Ul=Ia.reducer,Ae=T(t=>t.uuid),Vl=Ae.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),Pa=l.createSlice({name:"projectFiles",initialState:Vl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vl)),reducers:{initializeProjectFiles:Ae.initialize,setProjectFile:Ae.setOne,setProjectFiles:Ae.setMany,addProjectFile:Ae.addOne,addProjectFiles:Ae.addMany,updateProjectFile:Ae.updateOne,updateProjectFiles:Ae.updateMany,deleteProjectFile:Ae.deleteOne,deleteProjectFiles:Ae.deleteMany,setIsImportingProjectFile:(t,e)=>{t.isImportingProjectFile=e.payload},saveActiveProjectFileBounds:(t,e)=>{const s=t.activeProjectFileId;if(!s)throw new Error("Tried to save bounds for active project file, but no active project file was set.");if(!t.instances[s])throw new Error(`Tried to save bounds for active project file, but project file with ID ${s}
2
- doesn't exist.`);t.instances[s].bounds=e.payload},setActiveProjectFileId:(t,e)=>{t.activeProjectFileId=e.payload},resetProjectFileObjectUrls:(t,...e)=>{for(const s in t.instances)delete t.instances[s].objectURL}}}),{initializeProjectFiles:Gl,setProjectFile:_f,setProjectFiles:vf,addProjectFile:wf,addProjectFiles:$l,updateProjectFile:Oa,updateProjectFiles:Ef,deleteProjectFile:Ll,deleteProjectFiles:Bl,setIsImportingProjectFile:Nl,setActiveProjectFileId:Jl,saveActiveProjectFileBounds:Hl,resetProjectFileObjectUrls:jf}=Pa.actions,Wl=t=>t.projectFileReducer.instances,Kl=l.createSelector([Wl],t=>S(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),qf=t=>e=>e.projectFileReducer.instances[t],Mf=t=>t.projectFileReducer.activeProjectFileId,kf=t=>t.projectFileReducer.isImportingProjectFile,Yl=Pa.reducer,Cf={isRehydrated:!1},_a=l.createSlice({name:"rehydrated",initialState:Cf,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:zf}=_a.actions,Df=t=>t.rehydratedReducer.isRehydrated,Xl=_a.reducer,ke=T(t=>t.uuid),Ql=ke.getInitialState({}),va=l.createSlice({name:"teams",initialState:Ql,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ql)),reducers:{setTeam:ke.setOne,initializeTeams:ke.initialize,addTeam:ke.addOne,updateTeam:ke.updateOne,deleteTeam:ke.deleteOne}}),{setTeam:Ce,initializeTeams:Zl,addTeam:xl,updateTeam:wa,deleteTeam:Ea}=va.actions,ja=t=>t.teamReducer.instances,qa=l.createSelector([ja],t=>Object.values(t)),ze=t=>e=>e.teamReducer.instances[t],Uf=g(l.createSelector([ja,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectTeamsByIds: No team exists with the id",a)}return S(s)})),Vf=g(l.createSelector([qa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),Gf=g(l.createSelector([qa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.members.includes(e))))),eh=va.reducer,$f={version:0},th=l.createSlice({name:"versioning",initialState:$f,reducers:{}}),sh=th.reducer;let ih;function Lf(t){ih=t}function et(){return ih}let ah;function Bf(t){ah=t}function Nf(){return ah}const nh={};class ch{constructor(e){f(this,"client");nh[this.constructor.name]=this,this.client=e}async enqueueRequest(e){return this.client.enqueueRequest(e,this.host,this.constructor.name)}dispatch(e){this.client.store.dispatch(e)}}const rh="versioning",dh=()=>lh.length-1,oh=t=>(t[rh]={version:dh()},t),uh=()=>oh({}),Jf=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Hf=t=>e=>{var s;return e===void 0&&(e={}),((s=e[rh])==null?void 0:s.version)===dh()?e:t(e)},lh=[oh,uh,uh,Jf],Wf=Object.fromEntries(lh.map((t,e)=>[e,Hf(t)])),Ma="versioning",hh={[Ma]:sh,fileReducer:sd,authReducer:Fr,categoryReducer:_r,assetReducer:Sc,assetAttachmentReducer:fn,assetStageCompletionReducer:Ic,assetStageReducer:wc,assetTypeReducer:gr,assetTypeAttachmentReducer:$c,issueReducer:Go,issueAttachmentReducer:bo,issueTypeReducer:wu,issueTypeAttachmentReducer:Xo,organizationReducer:bl,outboxReducer:Ol,projectReducer:ll,projectAttachmentReducer:Ul,projectAccessReducer:nl,organizationAccessReducer:Zu,projectFileReducer:Yl,rehydratedReducer:Xl,formReducer:bd,formRevisionReducer:fd,formRevisionAttachmentReducer:od,formSubmissionAttachmentReducer:vd,formSubmissionReducer:Cd,userReducer:Hu,emailDomainsReducer:Qr,licenseReducer:Lu,documentsReducer:Jr,documentAttachmentReducer:Ur,teamReducer:eh,agentsReducer:dn,issueCommentReducer:ko,issueCommentAttachmentReducer:Eo,issueUpdateReducer:Uu,geoImageReducer:Jd,geoJsonFeatureReducer:Zd,geoJsonLayerReducer:so,issueAssociationReducer:lo,issueTypeFieldsReducer:Au,issueTypeFieldValuesReducer:du,issueTypeFieldsAttachmentReducer:au,issueTypeFieldValuesAttachmentReducer:Fu,assetTypeFieldsReducer:sr,assetTypeFieldValuesReducer:yr,assetTypeFieldsAttachmentReducer:Yc,assetTypeFieldValuesAttachmentReducer:or,assetProcedureReducer:mc,assetProcedureInstanceReducer:oc,assetProcedureFieldsReducer:Bn,assetProcedureFieldValuesReducer:ic,assetProcedureFieldsAttachmentReducer:zn,assetProcedureFieldValuesAttachmentReducer:Xn,assetProcedureAttachmentReducer:vn},mh=l.combineReducers(hh),ph="RESET",Kf=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?mh(void 0,e):mh(t,e);let ka=null;function _e(){const t=et();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(ka)return ka;const e=t.getState().offline.outbox,s=Ue._fromOutbox(e);return ka=s,s}const Yf=t=>{if(t)throw t;const e=et();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},Ah=(t,e,s)=>{const a=_e();return a?(a.addRequest(e),a.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},yh=(t,e,s)=>{const a=_e();if(!a)return console.warn("Outbox coordinator not set; cannot dequeue request yet."),[];const c=e.meta.offlineAction.payload.uuid;return a.remove(c),a.getQueue()};async function Xf(t,e){if(!e.payload)throw new Error("Received empty payload");return nS(e)}const Qf={...Ga,effect:Xf,discard:za,returnPromises:!0,persistCallback:Yf,retry:rS,persistOptions:{storage:Rh},queue:{...Ga.queue,enqueue:Ah,dequeue:yh,peek:(...t)=>cS(...t)}},Zf=Ph(Wf,Ma),xf=l.compose(Ih.offline(Qf),Zf);function eS(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(n=>n in s)}if(e(t))return t;if(typeof t=="object"&&t!==null){const s=t;if(e(s.response))return s.response;if(s.response&&e(s.response.response))return s.response.response}}async function Ca(t,e){const s=nh[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const a=s instanceof P;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");a&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const c={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:o,headers:m,method:d,queryParams:u,attachmentHash:p,isExternalUrl:A,isAuthNeeded:y,isResponseBlob:b}={...c,...r.request},I=r.request;let R=I.url;const _=p?await e.files.fetchCache(p):void 0;if(p&&!_)throw new Error(`Cannot upload file ${p} because it's not cached.`);!A&&!R.startsWith("http")&&(!R.startsWith("/")&&!R.startsWith("blob:")&&(R="/"+R),R=t.meta.offline.effect.BASE_URL+R);const M=w=>{if(p){const ye=I.s3url;if(!ye)throw new Error(`No S3 URL for file ${p}`);if("warning"in ye)throw new Error(`S3 URL warning for file ${p}`);if(!_)throw new Error(`No file for file ${p}`);const st=ye.fields["x-amz-checksum-sha1"];if(!st)throw new Error(`No checksum for file ${p}`);return w.set("x-amz-checksum-sha1",st).field({...o,...ye.fields}).attach("file",_)}return w.send(o)},yg={[h.GET]:()=>b?we.get(R.toString()).responseType("blob"):we.get(R.toString()),[h.POST]:()=>{const w=we.post(R.toString());return M(w)},[h.PATCH]:()=>{const w=we.patch(R.toString());return M(w)},[h.PUT]:()=>{const w=we.put(R.toString());return M(w)},[h.DELETE]:()=>{const w=we.delete(R.toString());return M(w)}}[d];let ve=yg();if(y&&a){const w=s.auth.getAuthHeader();ve=ve.set("Authorization",w)}m&&(ve=ve.set(m));try{return await ve.query(u)}catch(w){const ye=eS(w),st=ye==null?void 0:ye.status;if(a&&st===401)return await s.auth.handleUnauthorized(ve,ye),ve.query(u);throw new q({response:ye,innerError:w,discard:Sh.includes(st)})}}class tS{constructor(e){f(this,"_all");f(this,"_previous");this._all=[e],this._previous=e,this.then=this.then.bind(this),this.compile=this.compile.bind(this)}then(e){return this._previous&&(this._previous.next=e),this._all.push(e),this._previous=e,{then:this.then,compile:this.compile}}compile(){return this._all}}class fh{constructor(){f(this,"next");this.next=null}then(e){return new tS(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!et())throw new Error("Client store not set");const a=Nf();if(!a)throw new Error("Client SDK not set");return Ca(e,a)}}}class sS extends fh{async run(e){return super.run(e)}}class iS extends fh{async run(e){return super.run(e)}}const aS=new sS().then(new iS).compile();function nS(t){var e;return(e=aS[0])==null?void 0:e.run(t)}const Sh=[400,409,403,404,405,500];function za(t,e,s=0){var d;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
1
+ (function(i,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("@redux-offline/redux-offline/lib/types"),require("@reduxjs/toolkit"),require("superagent"),require("uuid"),require("file-saver"),require("@redux-offline/redux-offline"),require("@redux-offline/redux-offline/lib/defaults"),require("buffer"),require("localforage"),require("redux-persist-migrate"),require("@overmap-ai/forms"),require("idb"),require("@redux-offline/redux-offline/lib/constants"),require("jwt-decode"),require("dependency-graph"),require("@tiptap/core")):typeof define=="function"&&define.amd?define(["exports","@redux-offline/redux-offline/lib/types","@reduxjs/toolkit","superagent","uuid","file-saver","@redux-offline/redux-offline","@redux-offline/redux-offline/lib/defaults","buffer","localforage","redux-persist-migrate","@overmap-ai/forms","idb","@redux-offline/redux-offline/lib/constants","jwt-decode","dependency-graph","@tiptap/core"],j):(i=typeof globalThis<"u"?globalThis:i||self,j(i["overmap-core"]={},null,i.toolkit,i.request,i.uuid,i.fileSaver,i.reduxOffline,i.offlineConfig,null,i.localforage,i.createMigration,null,i.idb,i.constants,i.jwtDecode,i.dependencyGraph))})(this,function(i,j,l,we,Te,Fh,Ih,Ga,gg,Rh,Ph,bg,Oh,_h,vh,wh){"use strict";var fg=Object.defineProperty;var Sg=(i,j,l)=>j in i?fg(i,j,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[j]=l;var f=(i,j,l)=>Sg(i,typeof j!="symbol"?j+"":j,l);var Th;const $a=Object.freeze([]),La=Object.freeze({});var jt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(jt||{}),qt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(qt||{}),h=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(h||{}),Ba=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(Ba||{}),Mt=(t=>(t[t.LOWEST=0]="LOWEST",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=6]="HIGH",t[t.HIGHEST=8]="HIGHEST",t))(Mt||{}),Ct=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Ct||{}),v=(t=>(t.STATUS="status",t.PRIORITY="priority",t.CATEGORY="category",t.DESCRIPTION="description",t.TITLE="title",t.ASSIGNED_TO="assigned_to",t.DUE_DATE="due_date",t))(v||{}),Na=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Na||{}),Ja=(t=>(t[t.PRO=0]="PRO",t))(Ja||{}),Ha=(t=>(t[t.ACTIVE=0]="ACTIVE",t[t.PAUSED=2]="PAUSED",t[t.CANCELLED=4]="CANCELLED",t[t.INACTIVE=6]="INACTIVE",t[t.PAST_DUE=8]="PAST_DUE",t))(Ha||{});const Eh=Ct.BACKLOG,jh=Mt.MEDIUM,Wa=6e4;function T(t){return{addOne:(m,A)=>{const y=t(A.payload);m.instances[y]=A.payload},addMany:(m,A)=>{for(const y of A.payload){const b=t(y);m.instances[b]=y}},setOne:(m,A)=>{const y=t(A.payload);m.instances[y]=A.payload},setMany:(m,A)=>{for(const y of A.payload){const b=t(y);m.instances[b]=y}},updateOne:(m,A)=>{const y=t(A.payload);m.instances[y]=A.payload},updateMany:(m,A)=>{for(const y of A.payload){const b=t(y);m.instances[b]=y}},deleteOne:(m,A)=>{delete m.instances[A.payload]},deleteMany:(m,A)=>{for(const y of A.payload)delete m.instances[y]},initialize:(m,A)=>{m.instances={};for(const y of A.payload){const b=t(y);m.instances[b]=y}},getInitialState:m=>({...m,instances:{}})}}function qh(t){return{initializeSelection:(d,u)=>{d[t]=Array.from(new Set(u.payload))},selectOne:(d,u)=>{new Set(d[t]).has(u.payload)||d[t].push(u.payload)},selectMany:(d,u)=>{const m=new Set(d[t]);for(const A of u.payload)m.has(A)||m.add(A);d[t]=Array.from(m)},unselectOne:(d,u)=>{const m=new Set(d[t]);m.has(u.payload)&&(m.delete(u.payload),d[t]=Array.from(m))},unselectMany:(d,u)=>{const m=new Set(d[t]);for(const A of u.payload)m.has(A)&&m.delete(A);d[t]=Array.from(m)},toggleOne:(d,u)=>{const m=new Set(d[t]);m.has(u.payload)?m.delete(u.payload):m.add(u.payload),d[t]=Array.from(m)},toggleMany:(d,u)=>{const m=new Set(d[t]);for(const A of u.payload)m.has(A)?m.delete(A):m.add(A);d[t]=Array.from(m)},getInitialState:d=>({...d,[t]:[]})}}Th=Symbol.toStringTag;class Ka{constructor(){f(this,Th,"Promise");f(this,"_promise");f(this,"_resolve");f(this,"_reject");f(this,"_state","pending");this._resolve=null,this._reject=null,this._promise=new Promise((e,s)=>{this._resolve=e,this._reject=s})}get state(){return this._state}then(e,s){return this._promise.then(e,s)}catch(e){return this._promise.catch(e)}resolve(e){if(!this._resolve)throw new Error("No resolve callback");this._resolve(e),this._state="fulfilled"}reject(e){if(!this._reject)throw e;this._reject(e),this._state="rejected"}finally(e){throw new Error("`finally` not implemented")}}const Mh=t=>({type:"Point",coordinates:t}),Ch=t=>({type:"MultiPoint",coordinates:t}),zh=(t,e)=>t[0]===e[0]&&t[1]===e[1];let zt=!1;["true","1"].includes("".toLowerCase())&&(zt=!0);function kh(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;const s=Object.keys(t),a=Object.keys(e),n=s.length;if(n!==a.length)return!1;for(let c=0;c<n;c++){const r=s[c];if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1}return!0}function kt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(zt&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(zt&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Dh(t,e){if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}const S=t=>t.length===0?$a:t,Ee=t=>Object.keys(t).length===0?La:t,Ya=kt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===Dt.getFullYear(),a={day:"numeric",month:"short"};return s||(a.year="numeric"),e.toLocaleDateString([],a)}),Uh=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),Vh=1e3*86400,Dt=new Date,Gh=t=>new Date(t).toDateString()===Dt.toDateString(),$h=kt((t,e,s)=>{const a=Math.round((new Date(t).getTime()-Dt.getTime())/Vh);return a<e||a>s?Ya(t):Uh.format(a,"days")});function Lh(t){return new Uint8Array(t).reduce((s,a)=>s+a.toString(16).padStart(2,"0"),"")}const Ut=async(t,e)=>{e||(e=await je(t));let s=t.type;if(s.includes("/")&&(s=s.split("/")[1]),!s)throw new Error(`Could not extract file type from ${t.type}`);return`${e}.${s}`};function je(t){return new Promise((e,s)=>{const a=new FileReader;a.onload=()=>{const n=a.result;if(!n){s(new Error("FileReader did not return a valid ArrayBuffer."));return}crypto.subtle.digest("SHA-1",n).then(c=>{const r=Lh(c);e(r)})},a.readAsArrayBuffer(t)})}function Bh(t){if(!t.name||!t.type||!t.size){const e="File has no name, type, and/or size";throw new Error(e)}return`${t.name}&${t.type}${t.size}`}function Xa(t,e){return new File([t],e,{type:t.type})}function Nh(t,e){const s=document.createElement("a");s.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e)),s.setAttribute("download",t),s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}const Jh=async t=>{const e={};for(const s of t){const a=await je(s);e[a]={sha1:a,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},Qa=async t=>(await fetch(t)).blob(),Hh=t=>new Promise((e,s)=>{const a=new FileReader;a.onloadend=()=>{var n;e(((n=a.result)==null?void 0:n.toString())||"")},a.readAsDataURL(t)});function Wh(t){const e=new Blob([t]);Fh.saveAs(e,t.name)}const Za={};function Kh(t,e,s,...a){const n=Za[t];let c=!1;n?n[e]||(n[e]=!0,c=!0):(Za[t]={[e]:!0},c=!0),c&&console[s](...a)}const xa=["created_at","updated_at","index","revision"];function F(t){return{...t,uuid:Te.v4()}}function en(t){const e={};for(const s of t)e[s.uuid]=s;return e}function Yh(t,e=void 0,s=255){let a=t.replace(/[^a-z0-9_\-.]/gi,"_").replace(/_{2,}/g,"_");if(!e){const c=t.split(".");c.length>1&&(e=c[c.length-1])}e&&!e.startsWith(".")&&(e="."+e);const n=e?e.length:0;return a.length+n>s&&(a=a.slice(0,s-n)+(e||"")),a}function Xh(t){return t.toLowerCase().replace(" ","-")}function Qh(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Zh(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const g=t=>e=>s=>t(s,e);function tn(t,e,s){return s.findIndex(a=>a.uuid===t.uuid)===e}function xh(t,e,s){return s.findIndex(a=>a.file_sha1===t.file_sha1)===e}const em=/^.+@.+\..+$/;function O(t){const e={...t};for(const s of[...xa,"created_by"])s in e&&delete e[s];return e}const Ve=T(t=>t.uuid),sn=Ve.getInitialState({}),Vt=l.createSlice({name:"agents",initialState:sn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sn)),reducers:{initializeConversations:Ve.initialize,addConversation:Ve.addOne,setConversation:Ve.setOne,updateConversation:Ve.updateOne}}),{initializeConversations:an,addConversation:nn,setConversation:cn,updateConversation:rn}=Vt.actions,Gt=t=>t.agentsReducer.instances,tm=l.createSelector([Gt],t=>Object.values(t)),sm=g(l.createSelector([Gt,(t,e)=>e],(t,e)=>t[e])),dn=Vt.reducer,z=T(t=>t.uuid),on=z.getInitialState({}),$t=l.createSlice({name:"assetAttachments",initialState:on,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,on)),reducers:{initializeAssetAttachments:z.initialize,addAssetAttachment:z.addOne,addAssetAttachments:z.addMany,setAssetAttachment:z.setOne,setAssetAttachments:z.setMany,updateAssetAttachment:z.updateOne,updateAssetAttachments:z.updateMany,deleteAssetAttachment:z.deleteOne,deleteAssetAttachments:z.deleteMany}}),{initializeAssetAttachments:Lt,addAssetAttachment:im,addAssetAttachments:Bt,setAssetAttachment:un,setAssetAttachments:am,updateAssetAttachment:nm,updateAssetAttachments:ln,deleteAssetAttachment:hn,deleteAssetAttachments:Nt}=$t.actions,mn=t=>t.assetAttachmentReducer.instances,pn=l.createSelector([mn],t=>Object.values(t)),An=t=>e=>e.assetAttachmentReducer.instances[t],yn=g(l.createSelector([pn,(t,e)=>e],(t,e)=>S(t.filter(({asset:s})=>e===s)))),fn=$t.reducer,k=T(t=>t.uuid),Sn=k.getInitialState({}),Jt=l.createSlice({name:"assetProcedureAttachments",initialState:Sn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sn)),reducers:{initializeAssetProcedureAttachments:k.initialize,addAssetProcedureAttachment:k.addOne,addAssetProcedureAttachments:k.addMany,setAssetProcedureAttachment:k.setOne,setAssetProcedureAttachments:k.setMany,updateAssetProcedureAttachment:k.updateOne,updateAssetProcedureAttachments:k.updateMany,deleteAssetProcedureAttachment:k.deleteOne,deleteAssetProcedureAttachments:k.deleteMany}}),{initializeAssetProcedureAttachments:gn,addAssetProcedureAttachment:cm,addAssetProcedureAttachments:bn,setAssetProcedureAttachment:Tn,setAssetProcedureAttachments:rm,updateAssetProcedureAttachment:dm,updateAssetProcedureAttachments:Fn,deleteAssetProcedureAttachment:In,deleteAssetProcedureAttachments:Rn}=Jt.actions,Pn=t=>t.assetProcedureAttachmentReducer.instances,On=l.createSelector([Pn],t=>Object.values(t)),_n=t=>e=>e.assetProcedureAttachmentReducer.instances[t],om=g(l.createSelector([On,(t,e)=>e],(t,e)=>S(t.filter(({asset_procedure:s})=>e===s)))),vn=Jt.reducer,D=T(t=>t.uuid),wn=D.getInitialState({}),Ht=l.createSlice({name:"assetProcedureFieldsAttachments",initialState:wn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wn)),reducers:{initializeAssetProcedureFieldsAttachments:D.initialize,addAssetProcedureFieldsAttachment:D.addOne,addAssetProcedureFieldsAttachments:D.addMany,setAssetProcedureFieldsAttachment:D.setOne,setAssetProcedureFieldsAttachments:D.setMany,updateAssetProcedureFieldsAttachment:D.updateOne,updateAssetProcedureFieldsAttachments:D.updateMany,deleteAssetProcedureFieldsAttachment:D.deleteOne,deleteAssetProcedureFieldsAttachments:D.deleteMany}}),{initializeAssetProcedureFieldsAttachments:En,addAssetProcedureFieldsAttachment:um,addAssetProcedureFieldsAttachments:jn,setAssetProcedureFieldsAttachment:lm,setAssetProcedureFieldsAttachments:hm,updateAssetProcedureFieldsAttachment:mm,updateAssetProcedureFieldsAttachments:qn,deleteAssetProcedureFieldsAttachment:pm,deleteAssetProcedureFieldsAttachments:Mn}=Ht.actions,Cn=t=>t.assetProcedureFieldsAttachmentReducer.instances,zn=l.createSelector([Cn],t=>Object.values(t)),Am=g(l.createSelector([zn,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),ym=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],kn=Ht.reducer,U=T(t=>t.uuid),Dn=U.getInitialState({}),Wt=l.createSlice({name:"assetProcedureFields",initialState:Dn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dn)),reducers:{initializeAssetProcedureFields:U.initialize,addAssetProcedureFields:U.addOne,addAssetProcedureFieldsMany:U.addMany,setAssetProcedureFields:U.setOne,setAssetProcedureFieldsMany:U.setMany,updateAssetProcedureFields:U.updateOne,updateAssetProcedureFieldsMany:U.updateMany,deleteAssetProcedureFields:U.deleteOne,deleteAssetProcedureFieldsMany:U.deleteMany}}),{initializeAssetProcedureFields:Un,addAssetProcedureFields:Vn,addAssetProcedureFieldsMany:fm,setAssetProcedureFields:Sm,setAssetProcedureFieldsMany:gm,updateAssetProcedureFields:Gn,updateAssetProcedureFieldsMany:bm,deleteAssetProcedureFields:$n,deleteAssetProcedureFieldsMany:Tm}=Wt.actions,Ln=t=>t.assetProcedureFieldsReducer.instances,Kt=l.createSelector([Ln],t=>Object.values(t)),Fm=g(l.createSelector([Kt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Im=g(l.createSelector([Kt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,a)=>s.submitted_at>a.submitted_at?-1:1)[0])),Rm=t=>e=>e.assetProcedureFieldsReducer.instances[t],Bn=Wt.reducer,V=T(t=>t.uuid),Nn=V.getInitialState({}),Yt=l.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:Nn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Nn)),reducers:{initializeAssetProcedureFieldValuesAttachments:V.initialize,addAssetProcedureFieldValuesAttachment:V.addOne,addAssetProcedureFieldValuesAttachments:V.addMany,setAssetProcedureFieldValuesAttachment:V.setOne,setAssetProcedureFieldValuesAttachments:V.setMany,updateAssetProcedureFieldValuesAttachment:V.updateOne,updateAssetProcedureFieldValuesAttachments:V.updateMany,deleteAssetProcedureFieldValuesAttachment:V.deleteOne,deleteAssetProcedureFieldValuesAttachments:V.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:Jn,addAssetProcedureFieldValuesAttachment:Pm,addAssetProcedureFieldValuesAttachments:it,setAssetProcedureFieldValuesAttachment:Om,setAssetProcedureFieldValuesAttachments:_m,updateAssetProcedureFieldValuesAttachment:vm,updateAssetProcedureFieldValuesAttachments:Hn,deleteAssetProcedureFieldValuesAttachment:wm,deleteAssetProcedureFieldValuesAttachments:at}=Yt.actions,Xt=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,Wn=l.createSelector([Xt],t=>Object.values(t)),Em=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],Kn=g(l.createSelector([Xt,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),Yn=g(l.createSelector([Wn,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),Xn=Yt.reducer,G=T(t=>t.uuid),Qn=G.getInitialState({}),Qt=l.createSlice({name:"assetProcedureFieldValues",initialState:Qn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qn)),reducers:{initializeAssetProcedureFieldValues:G.initialize,addAssetProcedureFieldValues:G.addOne,addAssetProcedureFieldValuesMany:G.addMany,setAssetProcedureFieldValues:G.setOne,setAssetProcedureFieldValuesMany:G.setMany,updateAssetProcedureFieldValues:G.updateOne,updateAssetProcedureFieldValuesMany:G.updateMany,deleteAssetProcedureFieldValues:G.deleteOne,deleteAssetProcedureFieldValuesMany:G.deleteMany}}),{initializeAssetProcedureFieldValues:Zn,addAssetProcedureFieldValues:Zt,addAssetProcedureFieldValuesMany:xn,setAssetProcedureFieldValues:jm,setAssetProcedureFieldValuesMany:qm,updateAssetProcedureFieldValues:Ge,updateAssetProcedureFieldValuesMany:ec,deleteAssetProcedureFieldValues:xt,deleteAssetProcedureFieldValuesMany:tc}=Qt.actions,sc=t=>t.assetProcedureFieldValuesReducer.instances,es=l.createSelector([sc],t=>Object.values(t)),Mm=g(l.createSelector([es,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),Cm=g(l.createSelector([es,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure_instance===e)))),ts=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],ic=Qt.reducer,$=T(t=>t.uuid),ac=$.getInitialState({}),ss=l.createSlice({name:"assetProcedureInstances",initialState:ac,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ac)),reducers:{initializeAssetProcedureInstances:$.initialize,addAssetProcedureInstance:$.addOne,addAssetProcedureInstances:$.addMany,setAssetProcedureInstance:$.setOne,setAssetProcedureInstances:$.setMany,updateAssetProcedureInstance:$.updateOne,updateAssetProcedureInstances:$.updateMany,deleteAssetProcedureInstance:$.deleteOne,deleteAssetProcedureInstances:$.deleteMany}}),{initializeAssetProcedureInstances:nc,addAssetProcedureInstance:is,addAssetProcedureInstances:cc,updateAssetProcedureInstance:$e,updateAssetProcedureInstances:zm,deleteAssetProcedureInstance:as,deleteAssetProcedureInstances:rc,setAssetProcedureInstance:km,setAssetProcedureInstances:Dm}=ss.actions,ns=t=>t.assetProcedureInstanceReducer.instances,cs=l.createSelector([ns],t=>Object.values(t)),dc=g(l.createSelector([cs,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Um=g(l.createSelector([cs,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),rs=t=>e=>e.assetProcedureInstanceReducer.instances[t],Vm=g(l.createSelector([ns,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),oc=ss.reducer,L=T(t=>t.uuid),uc=L.getInitialState({}),ds=l.createSlice({name:"assetProcedures",initialState:uc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uc)),reducers:{initializeAssetProcedures:L.initialize,addAssetProcedure:L.addOne,addAssetProcedures:L.addMany,setAssetProcedure:L.setOne,setAssetProcedures:L.setMany,updateAssetProcedure:L.updateOne,updateAssetProcedures:L.updateMany,deleteAssetProcedure:L.deleteOne,deleteAssetProcedures:L.deleteMany}}),{initializeAssetProcedures:lc,addAssetProcedure:os,addAssetProcedures:Gm,updateAssetProcedure:Le,updateAssetProcedures:$m,deleteAssetProcedure:us,deleteAssetProcedures:Lm,setAssetProcedure:Bm,setAssetProcedures:Nm}=ds.actions,ls=t=>t.assetProcedureReducer.instances,hc=l.createSelector([ls],t=>Object.values(t)),Jm=g(l.createSelector([hc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),hs=t=>e=>e.assetProcedureReducer.instances[t],Hm=g(l.createSelector([ls,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),mc=ds.reducer,B=T(t=>t.uuid),pc=B.getInitialState({}),ms=l.createSlice({name:"assets",initialState:pc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pc)),reducers:{initializeAssets:B.initialize,addAsset:B.addOne,addAssets:B.addMany,setAsset:B.setOne,setAssets:B.setMany,updateAsset:B.updateOne,updateAssets:B.updateMany,deleteAsset:B.deleteOne,deleteAssets:B.deleteMany}}),{initializeAssets:Ac,addAsset:ps,addAssets:As,updateAsset:Be,updateAssets:Wm,deleteAsset:ys,deleteAssets:yc,setAsset:Km,setAssets:Ym}=ms.actions,fs=t=>t.assetReducer.instances,fc=l.createSelector([fs],t=>S(Object.values(t))),Ss=g(l.createSelector([fc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),gs=t=>e=>e.assetReducer.instances[t],Xm=g(l.createSelector([fs,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),Qm=t=>e=>Ss(t)(e).length,Sc=ms.reducer,Se=T(t=>t.uuid),gc=Se.getInitialState({}),bs=l.createSlice({name:"assetStageCompletions",initialState:gc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gc)),reducers:{initializeAssetStageCompletions:Se.initialize,addAssetStageCompletion:Se.addOne,addAssetStageCompletions:Se.addMany,updateAssetStageCompletion:Se.updateOne,updateAssetStageCompletions:Se.updateMany,deleteAssetStageCompletion:Se.deleteOne,deleteAssetStageCompletions:Se.deleteMany}}),{initializeAssetStageCompletions:bc,addAssetStageCompletion:Ts,addAssetStageCompletions:Fs,updateAssetStageCompletion:Tc,updateAssetStageCompletions:Fc,deleteAssetStageCompletion:Is,deleteAssetStageCompletions:Rs}=bs.actions,Ic=bs.reducer,Ps=t=>t.assetStageCompletionReducer.instances,Zm=l.createSelector([Ps],t=>Object.values(t)),Rc=t=>e=>e.assetStageCompletionReducer.instances[t],Pc=g(l.createSelector([Ps,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),N=T(t=>t.uuid),Oc=N.getInitialState({}),Os=l.createSlice({name:"assetStages",initialState:Oc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Oc)),reducers:{initializeAssetStages:N.initialize,setAssetStage:N.setOne,setAssetStages:N.setMany,addAssetStage:N.addOne,addAssetStages:N.addMany,updateAssetStage:N.updateOne,updateAssetStages:N.updateMany,deleteAssetStage:N.deleteOne,deleteAssetStages:N.deleteMany}}),{initializeAssetStages:_c,setAssetStage:vc,setAssetStages:xm,addAssetStage:ep,addAssetStages:_s,updateAssetStage:vs,updateAssetStages:nt,deleteAssetStage:tp,deleteAssetStages:ws}=Os.actions,wc=Os.reducer,ct=t=>t.assetStageReducer.instances,Ec=t=>e=>e.assetStageReducer.instances[t],jc=l.createSelector([ct],t=>Object.values(t)),sp=g(l.createSelector([ct,(t,e)=>e],(t,e)=>{const s={};for(const[a,n]of Object.entries(t))n.asset_procedure===e&&(s[a]=n);return Ee(s)})),ip=g(l.createSelector([jc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Es=g(l.createSelector([ct,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectStagesFromStageIds: No stage exists with the id",a)}return S(s)})),J=T(t=>t.uuid),qc=J.getInitialState({}),js=l.createSlice({name:"assetTypeAttachments",initialState:qc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,qc)),reducers:{initializeAssetTypeAttachments:J.initialize,addAssetTypeAttachment:J.addOne,addAssetTypeAttachments:J.addMany,setAssetTypeAttachment:J.setOne,setAssetTypeAttachments:J.setMany,updateAssetTypeAttachment:J.updateOne,updateAssetTypeAttachments:J.updateMany,deleteAssetTypeAttachment:J.deleteOne,deleteAssetTypeAttachments:J.deleteMany}}),{initializeAssetTypeAttachments:Mc,addAssetTypeAttachment:ap,addAssetTypeAttachments:qs,setAssetTypeAttachment:Cc,setAssetTypeAttachments:np,updateAssetTypeAttachment:cp,updateAssetTypeAttachments:zc,deleteAssetTypeAttachment:kc,deleteAssetTypeAttachments:Ms}=js.actions,Dc=t=>t.assetTypeAttachmentReducer.instances,Uc=l.createSelector([Dc],t=>Object.values(t)),Vc=t=>e=>e.assetTypeAttachmentReducer.instances[t],Gc=g(l.createSelector([Uc,(t,e)=>e],(t,e)=>S(t.filter(({asset_type:s})=>e===s)))),$c=js.reducer,H=T(t=>t.uuid),Lc=H.getInitialState({}),Cs=l.createSlice({name:"assetTypeFieldsAttachments",initialState:Lc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lc)),reducers:{initializeAssetTypeFieldsAttachments:H.initialize,addAssetTypeFieldsAttachment:H.addOne,addAssetTypeFieldsAttachments:H.addMany,setAssetTypeFieldsAttachment:H.setOne,setAssetTypeFieldsAttachments:H.setMany,updateAssetTypeFieldsAttachment:H.updateOne,updateAssetTypeFieldsAttachments:H.updateMany,deleteAssetTypeFieldsAttachment:H.deleteOne,deleteAssetTypeFieldsAttachments:H.deleteMany}}),{initializeAssetTypeFieldsAttachments:Bc,addAssetTypeFieldsAttachment:rp,addAssetTypeFieldsAttachments:Nc,setAssetTypeFieldsAttachment:dp,setAssetTypeFieldsAttachments:op,updateAssetTypeFieldsAttachment:up,updateAssetTypeFieldsAttachments:Jc,deleteAssetTypeFieldsAttachment:lp,deleteAssetTypeFieldsAttachments:Hc}=Cs.actions,Wc=t=>t.assetTypeFieldsAttachmentReducer.instances,Kc=l.createSelector([Wc],t=>Object.values(t)),hp=g(l.createSelector([Kc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),mp=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Yc=Cs.reducer,W=T(t=>t.uuid),Xc=W.getInitialState({}),zs=l.createSlice({name:"assetTypeFields",initialState:Xc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Xc)),reducers:{initializeAssetTypeFields:W.initialize,addAssetTypeFields:W.addOne,addAssetTypeFieldsMany:W.addMany,setAssetTypeFields:W.setOne,setAssetTypeFieldsMany:W.setMany,updateAssetTypeFields:W.updateOne,updateAssetTypeFieldsMany:W.updateMany,deleteAssetTypeFields:W.deleteOne,deleteAssetTypeFieldsMany:W.deleteMany}}),{initializeAssetTypeFields:Qc,addAssetTypeFields:Zc,addAssetTypeFieldsMany:pp,setAssetTypeFields:Ap,setAssetTypeFieldsMany:yp,updateAssetTypeFields:xc,updateAssetTypeFieldsMany:fp,deleteAssetTypeFields:er,deleteAssetTypeFieldsMany:Sp}=zs.actions,tr=t=>t.assetTypeFieldsReducer.instances,rt=l.createSelector([tr],t=>Object.values(t)),gp=g(l.createSelector([rt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),bp=g(l.createSelector([rt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,a)=>s.submitted_at>a.submitted_at?-1:1)[0])),Tp=t=>e=>e.assetTypeFieldsReducer.instances[t],sr=zs.reducer,K=T(t=>t.uuid),ir=K.getInitialState({}),ks=l.createSlice({name:"assetTypeFieldValuesAttachments",initialState:ir,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ir)),reducers:{initializeAssetTypeFieldValuesAttachments:K.initialize,addAssetTypeFieldValuesAttachment:K.addOne,addAssetTypeFieldValuesAttachments:K.addMany,setAssetTypeFieldValuesAttachment:K.setOne,setAssetTypeFieldValuesAttachments:K.setMany,updateAssetTypeFieldValuesAttachment:K.updateOne,updateAssetTypeFieldValuesAttachments:K.updateMany,deleteAssetTypeFieldValuesAttachment:K.deleteOne,deleteAssetTypeFieldValuesAttachments:K.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:ar,addAssetTypeFieldValuesAttachment:Fp,addAssetTypeFieldValuesAttachments:dt,setAssetTypeFieldValuesAttachment:Ip,setAssetTypeFieldValuesAttachments:Rp,updateAssetTypeFieldValuesAttachment:Pp,updateAssetTypeFieldValuesAttachments:nr,deleteAssetTypeFieldValuesAttachment:Op,deleteAssetTypeFieldValuesAttachments:ot}=ks.actions,Ds=t=>t.assetTypeFieldValuesAttachmentReducer.instances,cr=l.createSelector([Ds],t=>Object.values(t)),_p=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],rr=g(l.createSelector([Ds,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),dr=g(l.createSelector([cr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),or=ks.reducer,Y=T(t=>t.uuid),ur=Y.getInitialState({}),Us=l.createSlice({name:"assetTypeFieldValues",initialState:ur,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ur)),reducers:{initializeAssetTypeFieldValues:Y.initialize,addAssetTypeFieldValues:Y.addOne,addAssetTypeFieldValuesMany:Y.addMany,setAssetTypeFieldValues:Y.setOne,setAssetTypeFieldValuesMany:Y.setMany,updateAssetTypeFieldValues:Y.updateOne,updateAssetTypeFieldValuesMany:Y.updateMany,deleteAssetTypeFieldValues:Y.deleteOne,deleteAssetTypeFieldValuesMany:Y.deleteMany}}),{initializeAssetTypeFieldValues:lr,addAssetTypeFieldValues:Vs,addAssetTypeFieldValuesMany:hr,setAssetTypeFieldValues:vp,setAssetTypeFieldValuesMany:wp,updateAssetTypeFieldValues:Ne,updateAssetTypeFieldValuesMany:mr,deleteAssetTypeFieldValues:Gs,deleteAssetTypeFieldValuesMany:pr}=Us.actions,Ar=t=>t.assetTypeFieldValuesReducer.instances,$s=l.createSelector([Ar],t=>Object.values(t)),Ep=g(l.createSelector([$s,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),jp=g(l.createSelector([rt,$s,(t,e)=>e],(t,e,s)=>{const a=new Set(t.filter(n=>n.asset_type===s).map(n=>n.uuid));return S(e.filter(n=>a.has(n.fields_revision)))})),Ls=t=>e=>e.assetTypeFieldValuesReducer.instances[t],yr=Us.reducer,X=T(t=>t.uuid),fr=X.getInitialState({}),Bs=l.createSlice({name:"assetTypes",initialState:fr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,fr)),reducers:{initializeAssetTypes:X.initialize,setAssetType:X.setOne,setAssetTypes:X.setMany,addAssetType:X.addOne,addAssetTypes:X.addMany,updateAssetType:X.updateOne,updateAssetTypes:X.updateMany,deleteAssetType:X.deleteOne,deleteAssetTypes:X.deleteMany}}),{initializeAssetTypes:Sr,setAssetType:qp,setAssetTypes:Mp,addAssetType:Ns,addAssetTypes:Cp,updateAssetType:Je,updateAssetTypes:zp,deleteAssetType:Js,deleteAssetTypes:kp}=Bs.actions,Hs=t=>t.assetTypeReducer.instances,Dp=l.createSelector([Hs],t=>Object.values(t)),Ws=t=>e=>e.assetTypeReducer.instances[t],Up=g(l.createSelector([Hs,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectAssetTypesByIds: No assetType exists with the id",a)}return S(s)})),gr=Bs.reducer,br={accessToken:"",refreshToken:"",isLoggedIn:!1},ut=l.createSlice({name:"auth",initialState:br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,br)),reducers:{setTokens:(t,e)=>{t.accessToken=e.payload.accessToken,t.refreshToken=e.payload.refreshToken},clearTokens:t=>{t.accessToken="",t.refreshToken=""},setLoggedIn:(t,e)=>{e.payload||ut.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Vp,clearTokens:Gp,setLoggedIn:Tr}=ut.actions,$p=t=>t.authReducer.accessToken,Lp=t=>t.authReducer.isLoggedIn,Fr=ut.reducer,He=T(t=>t.uuid),Ir=He.getInitialState({}),Ks=l.createSlice({name:"categories",initialState:Ir,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ir)),reducers:{initializeCategories:He.initialize,addCategory:He.addOne,updateCategory:He.updateOne,deleteCategory:He.deleteOne}}),{initializeCategories:Rr,addCategory:Ys,updateCategory:Pr,deleteCategory:Or}=Ks.actions,Xs=t=>t.categoryReducer.instances,Bp=l.createSelector([Xs],t=>Object.values(t)),Qs=t=>e=>e.categoryReducer.instances[t],Np=g(l.createSelector([Xs,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectCategoryByIds: No category exists with the id",a)}return S(s)})),Jp=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,_r=Ks.reducer,Q=T(t=>t.uuid),vr=Q.getInitialState({}),Zs=l.createSlice({name:"documentAttachments",initialState:vr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vr)),reducers:{initializeDocumentAttachments:Q.initialize,addDocumentAttachment:Q.addOne,addDocumentAttachments:Q.addMany,setDocumentAttachment:Q.setOne,setDocumentAttachments:Q.setMany,updateDocumentAttachment:Q.updateOne,updateDocumentAttachments:Q.updateMany,deleteDocumentAttachment:Q.deleteOne,deleteDocumentAttachments:Q.deleteMany}}),{initializeDocumentAttachments:wr,addDocumentAttachment:Hp,addDocumentAttachments:Er,setDocumentAttachment:jr,setDocumentAttachments:Wp,updateDocumentAttachment:Kp,updateDocumentAttachments:qr,deleteDocumentAttachment:Mr,deleteDocumentAttachments:Cr}=Zs.actions,zr=t=>t.documentAttachmentReducer.instances,kr=l.createSelector([zr],t=>Object.values(t)),Dr=t=>e=>e.documentAttachmentReducer.instances[t],Yp=g(l.createSelector([kr,(t,e)=>e],(t,e)=>S(t.filter(({document:s})=>e===s)))),Ur=Zs.reducer,Vr={documents:{}},xs=l.createSlice({name:"documents",initialState:Vr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Vr)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(tn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=en(e.payload)},addDocuments:(t,e)=>{for(const s of e.payload)if(s.uuid in t.documents)throw new Error(`attempting to add a document with uuid ${s.uuid} which already exists in state.documents.`);for(const s of e.payload){if(s.parent_document&&t.documents[s.parent_document]){const a=t.documents[s.parent_document];t.documents[s.parent_document]={...a,children_documents:[...a.children_documents,s.uuid]}}t.documents[s.uuid]=s}},updateDocuments:(t,e)=>{for(const s of e.payload)if(!(s.uuid in t.documents))throw new Error(`attempting to update a document with uuid ${s.uuid} which doesn't exists in state.documents.`);for(const s of e.payload){const a=t.documents[s.uuid];if(s.organization!==void 0&&s.organization!==a.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==a.project)throw new Error("project cannot be updated");t.documents[s.uuid]={...a,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:a,position:n}=e.payload;if(!(s in t.documents))throw new Error(`attempting to move a document with uuid ${s} which doesn't exist in state.documents`);const c=t.documents[s];if(c.parent_document&&t.documents[c.parent_document]){const{children_documents:r}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(r.indexOf(c.uuid),1)}if(a){const r=t.documents[a],o=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(n){case"left":if(!o)throw new Error("attempting to move a document to the left of a document with no parent_document");t.documents[r.parent_document].children_documents.splice(o.children_documents.indexOf(r.uuid),0,c.uuid),t.documents[s].parent_document=o.uuid;break;case"right":if(!o)throw new Error("attempting to move a document to the left of a document with no parent_document");t.documents[r.parent_document].children_documents.splice(o.children_documents.indexOf(r.uuid)+1,0,c.uuid),t.documents[s].parent_document=o.uuid;break;case"left-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[a].children_documents.unshift(c.uuid),t.documents[s].parent_document=r.uuid;break;case"right-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[a].children_documents.push(c.uuid),t.documents[s].parent_document=r.uuid}}else t.documents[s].parent_document=null},removeDocuments:(t,e)=>{for(const s of e.payload)if(!(s in t.documents))throw new Error(`attempting to delete a document with uuid ${s} which doesn't exists in state.documents.`);for(const s of e.payload){const a=t.documents[s];if(a.parent_document&&t.documents[a.parent_document]){const n=t.documents[a.parent_document];t.documents[a.parent_document]={...n,children_documents:n.children_documents.filter(c=>c!==a.uuid)}}delete t.documents[s]}}}}),{setDocuments:Gr,addDocuments:$r,updateDocuments:ge,moveDocument:Lr,removeDocuments:ei}=xs.actions,qe=t=>t.documentsReducer.documents,Br=l.createSelector([qe],t=>Object.values(t)),Nr=t=>e=>e.documentsReducer.documents[t],Xp=g(l.createSelector([qe,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectDocumentByIds: No document exists with the id",a)}return S(s)})),Qp=g(l.createSelector([qe,(t,e)=>e],(t,e)=>{const s=[],a=t[e];if(!a||!a.parent_document)return s;let n=t[a.parent_document];for(;n;)s.push(n.uuid),n=t[n.parent_document??""];return S(s)})),Zp=l.createSelector([Br],t=>S(t.filter(e=>!e.parent_document))),Jr=xs.reducer,lt=T(t=>t.uuid),xp=lt.getInitialState({}),ti=l.createSlice({name:"emailDomains",initialState:xp,reducers:{initializeEmailDomains:lt.initialize,addEmailDomain:lt.addOne,deleteEmailDomain:lt.deleteOne}}),{initializeEmailDomains:Hr,addEmailDomain:Wr,deleteEmailDomain:Kr}=ti.actions,Yr=t=>t.emailDomainsReducer.instances,Xr=l.createSelector([Yr],t=>Object.values(t)),eA=g(l.createSelector([Xr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),Qr=ti.reducer,Zr={s3Urls:{}},xr=1e3*60*60,tA=xr*24*7,si=l.createSlice({name:"file",initialState:Zr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zr)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:a,sha1:n}=e.payload,c=new Date,r=new Date(c.getTime()+tA);t.s3Urls[n]={url:s,fields:a,exp:r.getTime()}}}}),{setUploadUrl:ed}=si.actions,td=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const a=new Date().getTime();if(!((s.exp??a)-a<xr))return s},sd=si.reducer,Z=T(t=>t.uuid),id=Z.getInitialState({}),ii=l.createSlice({name:"formRevisionAttachments",initialState:id,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,id)),reducers:{initializeFormRevisionAttachments:Z.initialize,addFormRevisionAttachment:Z.addOne,addFormRevisionAttachments:Z.addMany,setFormRevisionAttachment:Z.setOne,setFormRevisionAttachments:Z.setMany,updateFormRevisionAttachment:Z.updateOne,updateFormRevisionAttachments:Z.updateMany,deleteFormRevisionAttachment:Z.deleteOne,deleteFormRevisionAttachments:Z.deleteMany}}),{initializeFormRevisionAttachments:ad,addFormRevisionAttachment:sA,addFormRevisionAttachments:nd,setFormRevisionAttachment:iA,setFormRevisionAttachments:aA,updateFormRevisionAttachment:nA,updateFormRevisionAttachments:cd,deleteFormRevisionAttachment:cA,deleteFormRevisionAttachments:rd}=ii.actions,dd=t=>t.formRevisionAttachmentReducer.instances,rA=g(l.createSelector([dd,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_revision===e)))),od=ii.reducer,dA=(t,e)=>{const s=t.revision,a=e.revision;return s===void 0&&a===void 0?t.submitted_at<e.submitted_at?-1:1:s===void 0?1:a===void 0||s<a?-1:1},Fe=T(t=>t.uuid),ud=Fe.getInitialState({}),ai=l.createSlice({name:"formRevisions",initialState:ud,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ud)),reducers:{initializeFormRevisions:Fe.initialize,setFormRevision:Fe.setOne,addFormRevision:Fe.addOne,addFormRevisions:Fe.addMany,deleteFormRevision:Fe.deleteOne,deleteFormRevisions:Fe.deleteMany}}),{setFormRevision:ld,initializeFormRevisions:hd,addFormRevision:ni,addFormRevisions:md,deleteFormRevision:ci,deleteFormRevisions:pd}=ai.actions,ht=t=>t.formRevisionReducer.instances,Ad=l.createSelector([ht],t=>Object.values(t)),oA=t=>e=>e.formRevisionReducer.instances[t],uA=g(l.createSelector([ht,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const n=s.sort(dA)[s.length-1];return t[n.uuid]})),yd=g(l.createSelector([Ad,(t,e)=>e],(t,e)=>S(t.filter(s=>s.form===e)))),fd=ai.reducer,Ie=T(t=>t.uuid),Sd=Ie.getInitialState({}),ri=l.createSlice({name:"forms",initialState:Sd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sd)),reducers:{initializeForms:Ie.initialize,setForm:Ie.setOne,addForm:Ie.addOne,addForms:Ie.addMany,updateForm:Ie.updateOne,deleteForm:Ie.deleteOne}}),{initializeForms:gd,setForm:lA,addForm:di,addForms:hA,updateForm:mA,deleteForm:oi}=ri.actions,bd=ri.reducer,Td=t=>t.formReducer.instances,pA=l.createSelector([Td],t=>Object.values(t)),Fd=t=>e=>e.formReducer.instances[t],x=T(t=>t.uuid),Id=x.getInitialState({}),ui=l.createSlice({name:"formSubmissionAttachments",initialState:Id,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Id)),reducers:{initializeFormSubmissionAttachments:x.initialize,addFormSubmissionAttachment:x.addOne,addFormSubmissionAttachments:x.addMany,setFormSubmissionAttachment:x.setOne,setFormSubmissionAttachments:x.setMany,updateFormSubmissionAttachment:x.updateOne,updateFormSubmissionAttachments:x.updateMany,deleteFormSubmissionAttachment:x.deleteOne,deleteFormSubmissionAttachments:x.deleteMany}}),{initializeFormSubmissionAttachments:Rd,addFormSubmissionAttachment:AA,addFormSubmissionAttachments:mt,setFormSubmissionAttachment:yA,setFormSubmissionAttachments:fA,updateFormSubmissionAttachment:SA,updateFormSubmissionAttachments:Pd,deleteFormSubmissionAttachment:gA,deleteFormSubmissionAttachments:pt}=ui.actions,li=t=>t.formSubmissionAttachmentReducer.instances,Od=g(l.createSelector([li,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),_d=g(l.createSelector([li,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_submission===e)))),vd=ui.reducer,ee=T(t=>t.uuid),wd=ee.getInitialState({}),hi=l.createSlice({name:"formSubmissions",initialState:wd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wd)),reducers:{initializeFormSubmissions:ee.initialize,setFormSubmission:ee.setOne,setFormSubmissions:ee.setMany,addFormSubmission:ee.addOne,addFormSubmissions:ee.addMany,updateFormSubmission:ee.updateOne,updateFormSubmissions:ee.updateMany,deleteFormSubmission:ee.deleteOne,deleteFormSubmissions:ee.deleteMany}}),{initializeFormSubmissions:Ed,setFormSubmission:At,setFormSubmissions:bA,addFormSubmission:mi,addFormSubmissions:yt,updateFormSubmission:jd,updateFormSubmissions:TA,deleteFormSubmission:pi,deleteFormSubmissions:ft}=hi.actions,Ai=t=>t.formSubmissionReducer.instances,yi=l.createSelector([Ai],t=>Object.values(t)),fi=t=>e=>e.formSubmissionReducer.instances[t],qd=g(l.createSelector([Ai,ht,(t,e)=>e],(t,e,s)=>{const a=new Set;for(const n of Object.values(e))n.form===s&&a.add(n.uuid);return Object.values(t).filter(n=>a.has(n.form_revision))})),Md=g(l.createSelector([yi,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),Cd=g(l.createSelector([yi,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),zd=hi.reducer,te=T(t=>t.uuid),kd=te.getInitialState({}),Si=l.createSlice({name:"geoImages",initialState:kd,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,kd)})},reducers:{initializeGeoImages:te.initialize,setGeoImage:te.setOne,setGeoImages:te.setMany,addGeoImage:te.addOne,addGeoImages:te.addMany,updateGeoImage:te.updateOne,updateGeoImages:te.updateMany,deleteGeoImage:te.deleteOne,deleteGeoImages:te.deleteMany}}),{initializeGeoImages:Dd,setGeoImage:We,setGeoImages:Ud,addGeoImage:Vd,addGeoImages:Gd,updateGeoImage:$d,updateGeoImages:FA,deleteGeoImage:gi,deleteGeoImages:Ld}=Si.actions,Bd=t=>t.geoImageReducer.instances,Nd=l.createSelector([Bd],t=>Object.values(t)),bi=t=>e=>e.geoImageReducer.instances[t],IA=g(l.createSelector([Nd,(t,e)=>e],(t,e)=>S(t.filter(s=>s.project===e)))),Jd=Si.reducer,se=T(t=>t.uuid),Hd=se.getInitialState({}),Ti=l.createSlice({name:"geoJsonFeatures",initialState:Hd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Hd)),reducers:{initializeGeoJsonFeatures:se.initialize,addGeoJsonFeature:se.addOne,addGeoJsonFeatures:se.addMany,setGeoJsonFeature:se.setOne,setGeoJsonFeatures:se.setMany,updateGeoJsonFeature:se.updateOne,updateGeoJsonFeatures:se.updateMany,deleteGeoJsonFeature:se.deleteOne,deleteGeoJsonFeatures:se.deleteMany}}),{initializeGeoJsonFeatures:Wd,addGeoJsonFeature:Fi,addGeoJsonFeatures:Kd,updateGeoJsonFeature:Ke,updateGeoJsonFeatures:RA,deleteGeoJsonFeature:Ii,deleteGeoJsonFeatures:Yd,setGeoJsonFeature:PA,setGeoJsonFeatures:OA}=Ti.actions,Ri=t=>t.geoJsonFeatureReducer.instances,Xd=l.createSelector([Ri],t=>S(Object.values(t))),Qd=g(l.createSelector([Xd,(t,e)=>e],(t,e)=>S(t.filter(s=>s.geojson_layer===e)))),Pi=t=>e=>e.geoJsonFeatureReducer.instances[t],_A=g(l.createSelector([Ri,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),Zd=Ti.reducer,ie=T(t=>t.uuid),xd=ie.getInitialState({}),Oi=l.createSlice({name:"geoJsonLayers",initialState:xd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,xd)),reducers:{initializeGeoJsonLayers:ie.initialize,addGeoJsonLayer:ie.addOne,addGeoJsonLayers:ie.addMany,setGeoJsonLayer:ie.setOne,setGeoJsonLayers:ie.setMany,updateGeoJsonLayer:ie.updateOne,updateGeoJsonLayers:ie.updateMany,deleteGeoJsonLayer:ie.deleteOne,deleteGeoJsonLayers:ie.deleteMany}}),{initializeGeoJsonLayers:eo,addGeoJsonLayer:_i,addGeoJsonLayers:vA,updateGeoJsonLayer:Ye,updateGeoJsonLayers:wA,deleteGeoJsonLayer:vi,deleteGeoJsonLayers:EA,setGeoJsonLayer:jA,setGeoJsonLayers:qA}=Oi.actions,wi=t=>t.geoJsonLayerReducer.instances,to=l.createSelector([wi],t=>S(Object.values(t))),MA=g(l.createSelector([to,(t,e)=>e],(t,e)=>S(t.filter(s=>s.project===e)))),Ei=t=>e=>e.geoJsonLayerReducer.instances[t],CA=g(l.createSelector([wi,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n&&s.push(n)}return S(s)})),so=Oi.reducer,ae=T(t=>t.uuid),io=ae.getInitialState({}),ji=l.createSlice({name:"issueAssociations",initialState:io,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,io)),reducers:{initializeIssueAssociations:ae.initialize,addIssueAssociation:ae.addOne,addIssueAssociations:ae.addMany,setIssueAssociation:ae.setOne,setIssueAssociations:ae.setMany,updateIssueAssociation:ae.updateOne,updateIssueAssociations:ae.updateMany,deleteIssueAssociation:ae.deleteOne,deleteIssueAssociations:ae.deleteMany}}),{initializeIssueAssociations:ao,setIssueAssociations:zA,setIssueAssociation:kA,updateIssueAssociation:no,updateIssueAssociations:DA,addIssueAssociation:qi,addIssueAssociations:Mi,deleteIssueAssociation:Ci,deleteIssueAssociations:zi}=ji.actions,Xe=t=>t.issueAssociationReducer.instances,UA=l.createSelector([Xe],t=>Object.values(t)),co=t=>e=>e.issueAssociationReducer.instances[t],ro=g(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.associated_issue===e)))),oo=g(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),uo=g(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.asset===e)))),lo=ji.reducer,ne=T(t=>t.uuid),ho=ne.getInitialState({}),ki=l.createSlice({name:"issueAttachments",initialState:ho,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ho)),reducers:{initializeIssueAttachments:ne.initialize,addIssueAttachment:ne.addOne,addIssueAttachments:ne.addMany,setIssueAttachment:ne.setOne,setIssueAttachments:ne.setMany,updateIssueAttachment:ne.updateOne,updateIssueAttachments:ne.updateMany,deleteIssueAttachment:ne.deleteOne,deleteIssueAttachments:ne.deleteMany}}),{initializeIssueAttachments:Di,addIssueAttachment:VA,addIssueAttachments:Ui,setIssueAttachment:mo,setIssueAttachments:GA,updateIssueAttachment:$A,updateIssueAttachments:po,deleteIssueAttachment:Ao,deleteIssueAttachments:Vi}=ki.actions,yo=t=>t.issueAttachmentReducer.instances,fo=l.createSelector([yo],t=>Object.values(t)),So=g(l.createSelector([fo,(t,e)=>e],(t,e)=>S(t.filter(({issue:s})=>e===s)))),go=t=>e=>e.issueAttachmentReducer.instances[t],bo=ki.reducer,ce=T(t=>t.uuid),To=ce.getInitialState({}),Gi=l.createSlice({name:"issueCommentAttachments",initialState:To,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,To)),reducers:{initializeIssueCommentAttachments:ce.initialize,addIssueCommentAttachment:ce.addOne,addIssueCommentAttachments:ce.addMany,setIssueCommentAttachment:ce.setOne,setIssueCommentAttachments:ce.setMany,updateIssueCommentAttachment:ce.updateOne,updateIssueCommentAttachments:ce.updateMany,deleteIssueCommentAttachment:ce.deleteOne,deleteIssueCommentAttachments:ce.deleteMany}}),{initializeIssueCommentAttachments:$i,addIssueCommentAttachment:LA,addIssueCommentAttachments:Fo,setIssueCommentAttachment:Io,setIssueCommentAttachments:BA,updateIssueCommentAttachment:NA,updateIssueCommentAttachments:Ro,deleteIssueCommentAttachment:Po,deleteIssueCommentAttachments:Oo}=Gi.actions,_o=t=>t.issueCommentAttachmentReducer.instances,vo=l.createSelector([_o],t=>Object.values(t)),wo=t=>e=>e.issueCommentAttachmentReducer.instances[t],JA=g(l.createSelector([vo,(t,e)=>e],(t,e)=>S(t.filter(({issue_comment:s})=>e===s)))),Eo=Gi.reducer,Re=T(t=>t.uuid),jo=Re.getInitialState({}),Li=l.createSlice({name:"issueComments",initialState:jo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jo)),reducers:{addIssueComment:Re.addOne,addIssueComments:Re.addMany,setIssueComment:Re.setOne,setIssueComments:Re.setMany,deleteIssueComment:Re.deleteOne,deleteIssueComments:Re.deleteMany}}),{setIssueComments:qo,setIssueComment:Bi,addIssueComment:Ni,addIssueComments:HA,deleteIssueComment:Ji,deleteIssueComments:WA}=Li.actions,Mo=t=>t.issueCommentReducer.instances,Hi=t=>e=>e.issueCommentReducer.instances[t],KA=g(l.createSelector([Mo,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),Co=Li.reducer,Pe=T(t=>t.uuid),zo=Pe.getInitialState({}),Wi=l.createSlice({name:"issues",initialState:zo,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,zo)}),reducers:{initializeIssues:Pe.initialize,addIssue:Pe.addOne,addIssues:Pe.addMany,updateIssue:Pe.updateOne,deleteIssue:Pe.deleteOne,deleteIssues:Pe.deleteMany}}),{initializeIssues:ko,addIssue:Ki,addIssues:Do,updateIssue:St,deleteIssue:Yi,deleteIssues:Uo}=Wi.actions,Vo=t=>t.issueReducer.instances,Xi=t=>e=>e.issueReducer.instances[t],YA=g(l.createSelector([Vo,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectIssuesByIds: No issue exists with the id",a)}return S(s)})),Go=Wi.reducer,re=T(t=>t.uuid),$o=re.getInitialState({}),Qi=l.createSlice({name:"issueTypeAttachments",initialState:$o,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,$o)),reducers:{initializeIssueTypeAttachments:re.initialize,addIssueTypeAttachment:re.addOne,addIssueTypeAttachments:re.addMany,setIssueTypeAttachment:re.setOne,setIssueTypeAttachments:re.setMany,updateIssueTypeAttachment:re.updateOne,updateIssueTypeAttachments:re.updateMany,deleteIssueTypeAttachment:re.deleteOne,deleteIssueTypeAttachments:re.deleteMany}}),{initializeIssueTypeAttachments:Zi,addIssueTypeAttachment:XA,addIssueTypeAttachments:Lo,setIssueTypeAttachment:Bo,setIssueTypeAttachments:QA,updateIssueTypeAttachment:ZA,updateIssueTypeAttachments:No,deleteIssueTypeAttachment:Jo,deleteIssueTypeAttachments:Ho}=Qi.actions,Wo=t=>t.issueTypeAttachmentReducer.instances,Ko=l.createSelector([Wo],t=>Object.values(t)),Yo=t=>e=>e.issueTypeAttachmentReducer.instances[t],xA=g(l.createSelector([Ko,(t,e)=>e],(t,e)=>S(t.filter(({issue_type:s})=>e===s)))),Xo=Qi.reducer,de=T(t=>t.uuid),Qo=de.getInitialState({}),xi=l.createSlice({name:"issueTypeFieldsAttachments",initialState:Qo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qo)),reducers:{initializeIssueTypeFieldsAttachments:de.initialize,addIssueTypeFieldsAttachment:de.addOne,addIssueTypeFieldsAttachments:de.addMany,setIssueTypeFieldsAttachment:de.setOne,setIssueTypeFieldsAttachments:de.setMany,updateIssueTypeFieldsAttachment:de.updateOne,updateIssueTypeFieldsAttachments:de.updateMany,deleteIssueTypeFieldsAttachment:de.deleteOne,deleteIssueTypeFieldsAttachments:de.deleteMany}}),{initializeIssueTypeFieldsAttachments:Zo,addIssueTypeFieldsAttachment:ey,addIssueTypeFieldsAttachments:xo,setIssueTypeFieldsAttachment:ty,setIssueTypeFieldsAttachments:sy,updateIssueTypeFieldsAttachment:iy,updateIssueTypeFieldsAttachments:eu,deleteIssueTypeFieldsAttachment:ay,deleteIssueTypeFieldsAttachments:tu}=xi.actions,su=t=>t.issueTypeFieldsAttachmentReducer.instances,iu=l.createSelector([su],t=>Object.values(t)),ny=g(l.createSelector([iu,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),cy=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],au=xi.reducer,oe=T(t=>t.uuid),nu=oe.getInitialState({}),ea=l.createSlice({name:"issueTypeFieldValues",initialState:nu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,nu)),reducers:{initializeIssueTypeFieldValues:oe.initialize,addIssueTypeFieldValues:oe.addOne,addIssueTypeFieldValuesMany:oe.addMany,setIssueTypeFieldValues:oe.setOne,setIssueTypeFieldValuesMany:oe.setMany,updateIssueTypeFieldValues:oe.updateOne,updateIssueTypeFieldValuesMany:oe.updateMany,deleteIssueTypeFieldValues:oe.deleteOne,deleteIssueTypeFieldValuesMany:oe.deleteMany}}),{initializeIssueTypeFieldValues:cu,addIssueTypeFieldValues:ta,addIssueTypeFieldValuesMany:ry,setIssueTypeFieldValues:dy,setIssueTypeFieldValuesMany:oy,updateIssueTypeFieldValues:Qe,updateIssueTypeFieldValuesMany:uy,deleteIssueTypeFieldValues:sa,deleteIssueTypeFieldValuesMany:ly}=ea.actions,ru=t=>t.issueTypeFieldValuesReducer.instances,ia=l.createSelector([ru],t=>Object.values(t)),hy=g(l.createSelector([ia,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue===e)))),aa=t=>e=>e.issueTypeFieldValuesReducer.instances[t],du=ea.reducer,ue=T(t=>t.uuid),ou=ue.getInitialState({}),na=l.createSlice({name:"issueTypeFields",initialState:ou,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ou)),reducers:{initializeIssueTypeFields:ue.initialize,addIssueTypeFields:ue.addOne,addIssueTypeFieldsMany:ue.addMany,setIssueTypeFields:ue.setOne,setIssueTypeFieldsMany:ue.setMany,updateIssueTypeFields:ue.updateOne,updateIssueTypeFieldsMany:ue.updateMany,deleteIssueTypeFields:ue.deleteOne,deleteIssueTypeFieldsMany:ue.deleteMany}}),{initializeIssueTypeFields:uu,addIssueTypeFields:lu,addIssueTypeFieldsMany:my,setIssueTypeFields:py,setIssueTypeFieldsMany:Ay,updateIssueTypeFields:hu,updateIssueTypeFieldsMany:yy,deleteIssueTypeFields:mu,deleteIssueTypeFieldsMany:fy}=na.actions,pu=t=>t.issueTypeFieldsReducer.instances,gt=l.createSelector([pu],t=>Object.values(t)),Sy=g(l.createSelector([gt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue_type===e)))),gy=g(l.createSelector([gt,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,a)=>s.submitted_at>a.submitted_at?-1:1)[0])),by=g(l.createSelector([gt,ia,(t,e)=>e],(t,e,s)=>{const a=new Set(t.filter(n=>n.issue_type===s).map(n=>n.uuid));return S(e.filter(n=>a.has(n.fields_revision)))})),Ty=t=>e=>e.issueTypeFieldsReducer.instances[t],Au=na.reducer,le=T(t=>t.uuid),yu=le.getInitialState({}),ca=l.createSlice({name:"issueTypeFieldValuesAttachments",initialState:yu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,yu)),reducers:{initializeIssueTypeFieldValuesAttachments:le.initialize,addIssueTypeFieldValuesAttachment:le.addOne,addIssueTypeFieldValuesAttachments:le.addMany,setIssueTypeFieldValuesAttachment:le.setOne,setIssueTypeFieldValuesAttachments:le.setMany,updateIssueTypeFieldValuesAttachment:le.updateOne,updateIssueTypeFieldValuesAttachments:le.updateMany,deleteIssueTypeFieldValuesAttachment:le.deleteOne,deleteIssueTypeFieldValuesAttachments:le.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:fu,addIssueTypeFieldValuesAttachment:Fy,addIssueTypeFieldValuesAttachments:bt,setIssueTypeFieldValuesAttachment:Iy,setIssueTypeFieldValuesAttachments:Ry,updateIssueTypeFieldValuesAttachment:Py,updateIssueTypeFieldValuesAttachments:Su,deleteIssueTypeFieldValuesAttachment:Oy,deleteIssueTypeFieldValuesAttachments:Tt}=ca.actions,ra=t=>t.issueTypeFieldValuesAttachmentReducer.instances,gu=l.createSelector([ra],t=>Object.values(t)),_y=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],bu=g(l.createSelector([ra,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(a=>s.has(a.uuid)))})),Tu=g(l.createSelector([gu,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),Fu=ca.reducer,Me=T(t=>t.uuid),Iu=Me.getInitialState({}),da=l.createSlice({name:"issueTypes",initialState:Iu,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Iu)}),reducers:{initializeIssueTypes:Me.initialize,setIssueType:Me.setOne,addIssueType:Me.addOne,updateIssueType:Me.updateOne,removeIssueType:Me.deleteOne}}),{initializeIssueTypes:Ru,setIssueType:Ze,addIssueType:Pu,updateIssueType:Ou,removeIssueType:oa}=da.actions,_u=t=>t.issueTypeReducer.instances,vu=l.createSelector(_u,t=>Object.values(t)),ua=t=>e=>e.issueTypeReducer.instances[t],vy=t=>e=>{const s=[];for(const a of t){const n=e.issueTypeReducer.instances[a];n?s.push(n):console.warn("selectIssueTypesByIds: No issue type exists with the id",a)}return s},wy=g(l.createSelector([vu,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),la=g(l.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue_type===e)))),Ey=t=>e=>la(t)(e).length,wu=da.reducer,Oe=T(t=>t.uuid),Eu=Oe.getInitialState({}),ha=l.createSlice({name:"issueUpdates",initialState:Eu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Eu)),reducers:{initializeIssueUpdates:Oe.setMany,setIssueUpdate:Oe.setOne,addIssueUpdate:Oe.addOne,addIssueUpdates:Oe.addMany,deleteIssueUpdate:Oe.deleteOne,deleteIssueUpdates:Oe.deleteMany}}),{initializeIssueUpdates:ju,setIssueUpdate:jy,addIssueUpdate:qu,addIssueUpdates:Mu,deleteIssueUpdate:Cu,deleteIssueUpdates:zu}=ha.actions,ku=t=>t.issueUpdateReducer.instances,Du=g(l.createSelector([ku,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),Uu=ha.reducer,Ft=T(t=>t.uuid),Vu=Ft.getInitialState({}),ma=l.createSlice({name:"license",initialState:Vu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vu)),reducers:{initializeLicences:Ft.initialize,addLicenses:Ft.addMany,updateLicense:Ft.updateOne}}),{initializeLicences:Gu,addLicenses:qy,updateLicense:fe}=ma.actions,It=t=>t.licenseReducer.instances,My=t=>e=>e.licenseReducer.instances[t],$u=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),Cy=l.createSelector([It],t=>S(Object.values(t).filter(e=>e.is_active))),zy=l.createSelector([It],t=>Ee(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),Lu=ma.reducer,C=T(t=>t.id),Bu=C.getInitialState({currentUser:null}),pa=l.createSlice({name:"users",initialState:Bu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bu)),reducers:{initializeUsers:C.initialize,setUsers:C.setMany,setUser:C.setOne,addUsers:C.addMany,addUser:C.addOne,updateUsers:C.updateMany,updateUser:C.updateOne,deleteUser:C.deleteOne,deleteUsers:C.deleteMany,removeUser:C.deleteOne,setCurrentUser:(t,e)=>{t.currentUser=e.payload},setProfilePicture:(t,e)=>{if(!t.currentUser)return;t.currentUser.profile.file=e.payload.file??null,t.currentUser.profile.file_sha1=e.payload.file_sha1??null;const s=t.instances[t.currentUser.id];if(!s)throw new Error("Unable to find current user in users slice");s.profile.file=e.payload.file??null,s.profile.file_sha1=e.payload.file_sha1??null}}}),{initializeUsers:Nu,setUsers:ky,setUser:Dy,addUsers:Uy,addUser:Vy,updateUsers:Gy,updateUser:$y,deleteUser:Ly,deleteUsers:By,removeUser:Ju,setCurrentUser:Ny,setProfilePicture:Jy}=pa.actions,Hu=pa.reducer,Rt=t=>t.userReducer.currentUser,Pt=t=>t.userReducer.instances,Hy=t=>e=>e.userReducer.instances[t],Wy=g(l.createSelector([Pt,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectUsersByIds: No user exists with the uuid",a)}return S(s)})),Ot=T(t=>t.uuid),Wu=Ot.getInitialState({}),Aa=l.createSlice({name:"organizationAccess",initialState:Wu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wu)),reducers:{initializeOrganizationAccesses:Ot.initialize,updateOrganizationAccess:Ot.updateOne,deleteOrganizationAccess:Ot.deleteOne}}),{initializeOrganizationAccesses:Ku,updateOrganizationAccess:Yu,deleteOrganizationAccess:Xu}=Aa.actions,ya=t=>t.organizationAccessReducer.instances,Ky=t=>e=>e.organizationAccessReducer.instances[t],Yy=l.createSelector([Rt,ya],(t,e)=>Object.values(e).find(a=>a.user===(t==null?void 0:t.id))??null),Xy=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),Qu=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return Ee(e)},Zu=Aa.reducer,xe=T(t=>t.uuid),xu=xe.getInitialState({}),fa=l.createSlice({name:"projectAccess",initialState:xu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,xu)),reducers:{initializeProjectAccesses:xe.initialize,updateProjectAccess:xe.updateOne,deleteProjectAccess:xe.deleteOne,deleteProjectAccesses:xe.deleteMany}}),{initializeProjectAccesses:Sa,updateProjectAccess:el,deleteProjectAccess:tl,deleteProjectAccesses:sl}=fa.actions,ga=t=>t.projectAccessReducer.instances,il=l.createSelector(ga,t=>Object.values(t)),Qy=t=>e=>e.projectAccessReducer.instances[t],Zy=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),al=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return Ee(e)},nl=fa.reducer,he=T(t=>t.uuid),cl=he.getInitialState({}),ba=l.createSlice({name:"projects",initialState:cl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,cl)),reducers:{initializeProjects:he.initialize,setProjects:he.setMany,setProject:he.setOne,addProjects:he.addMany,addProject:he.addOne,updateProjects:he.updateMany,updateProject:he.updateOne,deleteProject:he.deleteOne,deleteProjects:he.deleteMany,acceptProjectInvite:(t,e)=>{if(e.payload in t.instances)t.instances[e.payload].invited=!1;else throw new Error("Accept project invite: user is not in this project")}}}),{initializeProjects:xy,setProjects:rl,setProject:ef,addProjects:tf,addProject:sf,updateProjects:af,updateProject:dl,deleteProject:ol,deleteProjects:nf,acceptProjectInvite:ul}=ba.actions,ll=ba.reducer,_t=t=>t.projectReducer.instances,cf=l.createSelector([_t],t=>S(Object.values(t))),rf=t=>e=>e.projectReducer.instances[t],hl=l.createSelector([ga],t=>Object.values(t).map(e=>e.user)),ml=l.createSelector([hl,Pt],(t,e)=>t.reduce((s,a)=>({...s,[a]:e[a]}),{})),df=l.createSelector([Rt,ml,al],(t,e,s)=>S(Object.values(e).sort((a,n)=>{if(a.id===(t==null?void 0:t.id))return-1;if(n.id===(t==null?void 0:t.id))return 1;const c=s[a.id],r=s[n.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?a.username.localeCompare(n.username):(c==null?void 0:c.access_level)===jt.ADMIN?-1:1}))),me=T(t=>t.uuid),pl=me.getInitialState({}),Ta=l.createSlice({name:"organizations",initialState:pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pl)),reducers:{initializeOrganizations:me.initialize,setOrganizations:me.setMany,setOrganization:me.setOne,addOrganizations:me.addMany,addOrganization:me.addOne,updateOrganizations:me.updateMany,updateOrganization:me.updateOne,deleteOrganization:me.deleteOne,deleteOrganizations:me.deleteMany}}),{initializeOrganizations:of,setOrganizations:Al,setOrganization:uf,addOrganizations:lf,addOrganization:hf,updateOrganizations:mf,updateOrganization:pf,deleteOrganization:Af,deleteOrganizations:yf}=Ta.actions,yl=t=>t.organizationReducer.instances,fl=l.createSelector([yl],t=>Object.values(t)),ff=t=>e=>e.organizationReducer.instances[t],Sf=l.createSelector([fl],t=>S(Object.values(t).filter(e=>e.has_access))),Sl=l.createSelector([ya],t=>Object.values(t).map(e=>e.user)),gf=g(l.createSelector([_t,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),bf=g(l.createSelector([It,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),gl=l.createSelector([Sl,Pt],(t,e)=>Ee(t.reduce((s,a)=>({...s,[a]:e[a]}),{}))),Tf=l.createSelector([Rt,gl,Qu],(t,e,s)=>S(Object.values(e).sort((a,n)=>{if(a.id===(t==null?void 0:t.id))return-1;if(n.id===(t==null?void 0:t.id))return 1;const c=s[a.id],r=s[n.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?a.username.localeCompare(n.username):(c==null?void 0:c.access_level)===qt.ADMIN?-1:1}))),bl=Ta.reducer,Tl=(t,e,s)=>{const a=t.uuid?t:{...t,uuid:Te.v4()};return{payload:a,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:a,BASE_URL:e,serviceName:s}}}}},Fl={deletedRequests:[],latestRetryTime:0},Fa=l.createSlice({name:"outbox",initialState:Fl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Fl)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...a}=t;return Tl(a,e,s)}},markForDeletion(t,e){t.deletedRequests.push(e.payload)},markAsDeleted(t,e){const s=t.deletedRequests.indexOf(e.payload);s!==-1&&t.deletedRequests.splice(s,1)},_setLatestRetryTime:(t,e)=>{t.latestRetryTime=e.payload}}}),Ff=t=>t.outboxReducer.deletedRequests,If=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Il,markForDeletion:Rf,markAsDeleted:Rl,_setLatestRetryTime:Pl}=Fa.actions,Ol=Fa.reducer,pe=T(t=>t.uuid),_l=pe.getInitialState({}),Ia=l.createSlice({name:"projectAttachments",initialState:_l,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,_l)),reducers:{initializeProjectAttachments:pe.initialize,addProjectAttachment:pe.addOne,addProjectAttachments:pe.addMany,setProjectAttachment:pe.setOne,setProjectAttachments:pe.setMany,updateProjectAttachment:pe.updateOne,updateProjectAttachments:pe.updateMany,deleteProjectAttachment:pe.deleteOne,deleteProjectAttachments:pe.deleteMany}}),{initializeProjectAttachments:vl,addProjectAttachment:Pf,addProjectAttachments:wl,setProjectAttachment:El,setProjectAttachments:jl,updateProjectAttachment:Of,updateProjectAttachments:ql,deleteProjectAttachment:Ml,deleteProjectAttachments:Ra}=Ia.actions,Cl=t=>t.projectAttachmentReducer.instances,zl=l.createSelector([Cl],t=>Object.values(t)),kl=t=>e=>e.projectAttachmentReducer.instances[t],Dl=g(l.createSelector([zl,(t,e)=>e],(t,e)=>S(t.filter(({project:s})=>e===s)))),Ul=Ia.reducer,Ae=T(t=>t.uuid),Vl=Ae.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),Pa=l.createSlice({name:"projectFiles",initialState:Vl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vl)),reducers:{initializeProjectFiles:Ae.initialize,setProjectFile:Ae.setOne,setProjectFiles:Ae.setMany,addProjectFile:Ae.addOne,addProjectFiles:Ae.addMany,updateProjectFile:Ae.updateOne,updateProjectFiles:Ae.updateMany,deleteProjectFile:Ae.deleteOne,deleteProjectFiles:Ae.deleteMany,setIsImportingProjectFile:(t,e)=>{t.isImportingProjectFile=e.payload},saveActiveProjectFileBounds:(t,e)=>{const s=t.activeProjectFileId;if(!s)throw new Error("Tried to save bounds for active project file, but no active project file was set.");if(!t.instances[s])throw new Error(`Tried to save bounds for active project file, but project file with ID ${s}
2
+ doesn't exist.`);t.instances[s].bounds=e.payload},setActiveProjectFileId:(t,e)=>{t.activeProjectFileId=e.payload},resetProjectFileObjectUrls:(t,...e)=>{for(const s in t.instances)delete t.instances[s].objectURL}}}),{initializeProjectFiles:Gl,setProjectFile:_f,setProjectFiles:vf,addProjectFile:wf,addProjectFiles:$l,updateProjectFile:Oa,updateProjectFiles:Ef,deleteProjectFile:Ll,deleteProjectFiles:Bl,setIsImportingProjectFile:Nl,setActiveProjectFileId:Jl,saveActiveProjectFileBounds:Hl,resetProjectFileObjectUrls:jf}=Pa.actions,Wl=t=>t.projectFileReducer.instances,Kl=l.createSelector([Wl],t=>S(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),qf=t=>e=>e.projectFileReducer.instances[t],Mf=t=>t.projectFileReducer.activeProjectFileId,Cf=t=>t.projectFileReducer.isImportingProjectFile,Yl=Pa.reducer,zf={isRehydrated:!1},_a=l.createSlice({name:"rehydrated",initialState:zf,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:kf}=_a.actions,Df=t=>t.rehydratedReducer.isRehydrated,Xl=_a.reducer,Ce=T(t=>t.uuid),Ql=Ce.getInitialState({}),va=l.createSlice({name:"teams",initialState:Ql,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ql)),reducers:{setTeam:Ce.setOne,initializeTeams:Ce.initialize,addTeam:Ce.addOne,updateTeam:Ce.updateOne,deleteTeam:Ce.deleteOne}}),{setTeam:ze,initializeTeams:Zl,addTeam:xl,updateTeam:wa,deleteTeam:Ea}=va.actions,ja=t=>t.teamReducer.instances,qa=l.createSelector([ja],t=>Object.values(t)),ke=t=>e=>e.teamReducer.instances[t],Uf=g(l.createSelector([ja,(t,e)=>e],(t,e)=>{const s=[];for(const a of e){const n=t[a];n?s.push(n):console.warn("selectTeamsByIds: No team exists with the id",a)}return S(s)})),Vf=g(l.createSelector([qa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),Gf=g(l.createSelector([qa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.members.includes(e))))),eh=va.reducer,$f={version:0},th=l.createSlice({name:"versioning",initialState:$f,reducers:{}}),sh=th.reducer;let ih;function Lf(t){ih=t}function et(){return ih}let ah;function Bf(t){ah=t}function Nf(){return ah}const nh={};class ch{constructor(e){f(this,"client");nh[this.constructor.name]=this,this.client=e}async enqueueRequest(e){return this.client.enqueueRequest(e,this.host,this.constructor.name)}dispatch(e){this.client.store.dispatch(e)}}const rh="versioning",dh=()=>lh.length-1,oh=t=>(t[rh]={version:dh()},t),uh=()=>oh({}),Jf=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Hf=t=>e=>{var s;return e===void 0&&(e={}),((s=e[rh])==null?void 0:s.version)===dh()?e:t(e)},lh=[oh,uh,uh,Jf],Wf=Object.fromEntries(lh.map((t,e)=>[e,Hf(t)])),Ma="versioning",hh={[Ma]:sh,fileReducer:sd,authReducer:Fr,categoryReducer:_r,assetReducer:Sc,assetAttachmentReducer:fn,assetStageCompletionReducer:Ic,assetStageReducer:wc,assetTypeReducer:gr,assetTypeAttachmentReducer:$c,issueReducer:Go,issueAttachmentReducer:bo,issueTypeReducer:wu,issueTypeAttachmentReducer:Xo,organizationReducer:bl,outboxReducer:Ol,projectReducer:ll,projectAttachmentReducer:Ul,projectAccessReducer:nl,organizationAccessReducer:Zu,projectFileReducer:Yl,rehydratedReducer:Xl,formReducer:bd,formRevisionReducer:fd,formRevisionAttachmentReducer:od,formSubmissionAttachmentReducer:vd,formSubmissionReducer:zd,userReducer:Hu,emailDomainsReducer:Qr,licenseReducer:Lu,documentsReducer:Jr,documentAttachmentReducer:Ur,teamReducer:eh,agentsReducer:dn,issueCommentReducer:Co,issueCommentAttachmentReducer:Eo,issueUpdateReducer:Uu,geoImageReducer:Jd,geoJsonFeatureReducer:Zd,geoJsonLayerReducer:so,issueAssociationReducer:lo,issueTypeFieldsReducer:Au,issueTypeFieldValuesReducer:du,issueTypeFieldsAttachmentReducer:au,issueTypeFieldValuesAttachmentReducer:Fu,assetTypeFieldsReducer:sr,assetTypeFieldValuesReducer:yr,assetTypeFieldsAttachmentReducer:Yc,assetTypeFieldValuesAttachmentReducer:or,assetProcedureReducer:mc,assetProcedureInstanceReducer:oc,assetProcedureFieldsReducer:Bn,assetProcedureFieldValuesReducer:ic,assetProcedureFieldsAttachmentReducer:kn,assetProcedureFieldValuesAttachmentReducer:Xn,assetProcedureAttachmentReducer:vn},mh=l.combineReducers(hh),ph="RESET",Kf=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?mh(void 0,e):mh(t,e);let Ca=null;function _e(){const t=et();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(Ca)return Ca;const e=t.getState().offline.outbox,s=Ue._fromOutbox(e);return Ca=s,s}const Yf=t=>{if(t)throw t;const e=et();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},Ah=(t,e,s)=>{const a=_e();return a?(a.addRequest(e),a.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},yh=(t,e,s)=>{const a=_e();if(!a)return console.warn("Outbox coordinator not set; cannot dequeue request yet."),[];const c=e.meta.offlineAction.payload.uuid;return a.remove(c),a.getQueue()};async function Xf(t,e){if(!e.payload)throw new Error("Received empty payload");return nS(e)}const Qf={...Ga,effect:Xf,discard:ka,returnPromises:!0,persistCallback:Yf,retry:rS,persistOptions:{storage:Rh},queue:{...Ga.queue,enqueue:Ah,dequeue:yh,peek:(...t)=>cS(...t)}},Zf=Ph(Wf,Ma),xf=l.compose(Ih.offline(Qf),Zf);function eS(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(n=>n in s)}if(e(t))return t;if(typeof t=="object"&&t!==null){const s=t;if(e(s.response))return s.response;if(s.response&&e(s.response.response))return s.response.response}}async function za(t,e){const s=nh[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const a=s instanceof P;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");a&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const c={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:o,headers:p,method:d,queryParams:u,attachmentHash:m,isExternalUrl:A,isAuthNeeded:y,isResponseBlob:b}={...c,...r.request},I=r.request;let R=I.url;const _=m?await e.files.fetchCache(m):void 0;if(m&&!_)throw new Error(`Cannot upload file ${m} because it's not cached.`);!A&&!R.startsWith("http")&&(!R.startsWith("/")&&!R.startsWith("blob:")&&(R="/"+R),R=t.meta.offline.effect.BASE_URL+R);const M=w=>{if(m){const ye=I.s3url;if(!ye)throw new Error(`No S3 URL for file ${m}`);if("warning"in ye)throw new Error(`S3 URL warning for file ${m}`);if(!_)throw new Error(`No file for file ${m}`);const st=ye.fields["x-amz-checksum-sha1"];if(!st)throw new Error(`No checksum for file ${m}`);return w.set("x-amz-checksum-sha1",st).field({...o,...ye.fields}).attach("file",_)}return w.send(o)},yg={[h.GET]:()=>b?we.get(R.toString()).responseType("blob"):we.get(R.toString()),[h.POST]:()=>{const w=we.post(R.toString());return M(w)},[h.PATCH]:()=>{const w=we.patch(R.toString());return M(w)},[h.PUT]:()=>{const w=we.put(R.toString());return M(w)},[h.DELETE]:()=>{const w=we.delete(R.toString());return M(w)}}[d];let ve=yg();if(y&&a){const w=s.auth.getAuthHeader();ve=ve.set("Authorization",w)}p&&(ve=ve.set(p));try{return await ve.query(u)}catch(w){const ye=eS(w),st=ye==null?void 0:ye.status;if(a&&st===401)return await s.auth.handleUnauthorized(ve,ye),ve.query(u);throw new q({response:ye,innerError:w,discard:Sh.includes(st)})}}class tS{constructor(e){f(this,"_all");f(this,"_previous");this._all=[e],this._previous=e,this.then=this.then.bind(this),this.compile=this.compile.bind(this)}then(e){return this._previous&&(this._previous.next=e),this._all.push(e),this._previous=e,{then:this.then,compile:this.compile}}compile(){return this._all}}class fh{constructor(){f(this,"next");this.next=null}then(e){return new tS(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!et())throw new Error("Client store not set");const a=Nf();if(!a)throw new Error("Client SDK not set");return za(e,a)}}}class sS extends fh{async run(e){return super.run(e)}}class iS extends fh{async run(e){return super.run(e)}}const aS=new sS().then(new iS).compile();function nS(t){var e;return(e=aS[0])==null?void 0:e.run(t)}const Sh=[400,409,403,404,405,500];function ka(t,e,s=0){var d;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
3
3
  Action:`,e,`
4
- Retries:`,s),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ERROR:",t,"(throwing immediately, which may lead to unexpected behavior)"),t;const a=et(),c=a.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function o(){a.dispatch(Rl(r));const u=_e();if(!u)throw new Error("Outbox coordinator not set");u.remove(e.payload.uuid);const p=e.meta.offline.rollback;throw p&&(console.warn("Rolling back request due to SDK error:",e),a.dispatch(p)),t}if(t instanceof q&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),o();if(c.includes(r))return console.debug("Discarding request due to deletion:",e),o();if(t instanceof q){const u=t.status||((d=t.response)==null?void 0:d.status);if(u||console.warn("Error has no status code:",t),u!==void 0&&Sh.includes(u)){console.warn("Discarding request due to error:",t,`
5
- Action:`,e);const p=_e();if(!p)throw new Error("Outbox coordinator not set");p.remove(e.payload.uuid),t.options.discard=!0,o()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=_e();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cS(t,e,s){var a;return(a=_e())==null?void 0:a.peek()}function rS(t,e){return et().dispatch(Pl(new Date().getTime())),Wa}const De="An unknown error occurred",dS=500,gh=["non_field_errors","detail"];function oS(t,e){let s;if(t!=null&&t.body)if(typeof t.body=="object"){const a=t.body;if(typeof a.error=="string")s=a.error;else if(typeof a.message=="string")s=a.message;else try{s=Object.entries(a).map(([n,c])=>typeof c=="string"?gh.includes(n)?c:`${n}: ${c}`:Array.isArray(c)?gh.includes(n)?c.join(`
4
+ Retries:`,s),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ERROR:",t,"(throwing immediately, which may lead to unexpected behavior)"),t;const a=et(),c=a.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function o(){a.dispatch(Rl(r));const u=_e();if(!u)throw new Error("Outbox coordinator not set");u.remove(e.payload.uuid);const m=e.meta.offline.rollback;throw m&&(console.warn("Rolling back request due to SDK error:",e),a.dispatch(m)),t}if(t instanceof q&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),o();if(c.includes(r))return console.debug("Discarding request due to deletion:",e),o();if(t instanceof q){const u=t.status||((d=t.response)==null?void 0:d.status);if(u||console.warn("Error has no status code:",t),u!==void 0&&Sh.includes(u)){console.warn("Discarding request due to error:",t,`
5
+ Action:`,e);const m=_e();if(!m)throw new Error("Outbox coordinator not set");m.remove(e.payload.uuid),t.options.discard=!0,o()}}console.debug("Registering a retry for request:",e.payload.uuid);const p=_e();if(!p)throw new Error("Outbox coordinator not set");return p.registerRetry(e.payload.uuid),!1}function cS(t,e,s){var a;return(a=_e())==null?void 0:a.peek()}function rS(t,e){return et().dispatch(Pl(new Date().getTime())),Wa}const De="An unknown error occurred",dS=500,gh=["non_field_errors","detail"];function oS(t,e){let s;if(t!=null&&t.body)if(typeof t.body=="object"){const a=t.body;if(typeof a.error=="string")s=a.error;else if(typeof a.message=="string")s=a.message;else try{s=Object.entries(a).map(([n,c])=>typeof c=="string"?gh.includes(n)?c:`${n}: ${c}`:Array.isArray(c)?gh.includes(n)?c.join(`
6
6
  `):c.map(r=>`${n}: ${r}`).join(`
7
7
  `):`${n}: ${JSON.stringify(c)}`).join(`
8
- `)}catch(n){console.error("Failed to extract error message from response body",n)}}else typeof t.body=="string"&&(s=t.body);else t!=null&&t.text?s=t.text:e instanceof Error&&(s=e.message);return!s||s.length>dS?De:s}class q extends Error{constructor(s){super(De);f(this,"status");f(this,"response");f(this,"message");f(this,"options");const{response:a,innerError:n}=s;this.message=s.message??oS(a,n)??De,this.status=(a==null?void 0:a.status)??0,this.response=a,s.discard=s.discard??!1,this.options=s}}class uS extends ch{constructor(e){super(e)}}class P extends ch{constructor(s,a){super(s);f(this,"auth");this.auth=a}}class lS extends P{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(a=>(this.dispatch(nn(a)),a))}async continueConversation(e,s,a){return this.enqueueRequest({description:"Prompt agent",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:a},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(n=>{this.dispatch(rn(n))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:h.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(cn(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:h.PUT,url:`/agents/responses/${e}/rate/`,payload:{rating:s},blockers:["rate"],blocks:["rate"]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get agent conversation history",method:h.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(an(s))}}class E extends P{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:a,assetTypeAttachmentReducer:n,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:o,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:u,assetTypeFieldValuesAttachmentReducer:p,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(a.instances),Object.values(n.instances),Object.values(c.instances),Object.values(r.instances),Object.values(o.instances),Object.values(m.instances),Object.values(d.instances),Object.values(u.instances),Object.values(p.instances),Object.values(A.instances),Object.values(y.instances)).filter(I=>I.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[a,n]of Object.entries(e))s[a]=this.enqueueRequest({url:n.url,description:"Upload file to S3",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:a,blockers:[`s3-${n.fields.key}`],blocks:[a],s3url:n});return s}async getFilePayload(e){const s=await je(e),a={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),a}}class be extends E{async _bulkAdd(e){var d;const{store:s}=this.client,a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,n=new Date().toISOString(),c=[],r=[],o={};for(const u of e){const{modelUuid:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in o||(o[y.sha1]=y);const b=this.buildOfflineAttachment({file:A,file_sha1:y.sha1,submitted_at:n,created_by:a,description:"",modelUuid:p});c.push(b),r.push(this.buildAttachmentPayload({uuid:b.uuid,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:y.extension,description:b.description,modelUuid:p}))}this.dispatch(this.addAttachments(c));const m=this.enqueueRequest({description:`Add ${this.name}`,method:h.POST,url:`${this.url}/bulk/`,payload:{submitted_at:n,attachments:r,files:Object.values(o)},blocks:c.map(u=>u.uuid),blockers:c.map(u=>u.file_sha1)});return m.then(({attachments:u,presigned_urls:p})=>{this.dispatch(this.updateAttachments(u)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(u=>u.uuid)))}),[c,m.then(({attachments:u})=>u)]}async _delete(e){const{store:s}=this.client,a=this.selectAttachment(e)(s.getState());if(!a)throw new Error(`Attempting to delete attachment with uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(a.uuid));const n=this.enqueueRequest({description:`Delete ${this.name}`,method:h.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return n.then(()=>{this.getNumberOfAttachmentsWithSha1(a.file_sha1)===0&&this.client.files.removeCache(a.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(a))}),n}}class hS extends be{constructor(){super(...arguments);f(this,"name","Asset Attachment");f(this,"url","/asset-attachments");f(this,"initializeAttachments",Lt);f(this,"addAttachments",Bt);f(this,"updateAttachments",ln);f(this,"removeAttachments",Nt);f(this,"removeAttachment",hn);f(this,"setAttachment",un);f(this,"selectAttachment",An)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.assetUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get asset attachments",method:h.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Lt(a))}}class mS extends be{constructor(){super(...arguments);f(this,"name","Asset Procedure Attachment");f(this,"url","/asset-procedure-attachments");f(this,"addAttachments",bn);f(this,"updateAttachments",Fn);f(this,"removeAttachments",Rn);f(this,"removeAttachment",In);f(this,"setAttachment",Tn);f(this,"selectAttachment",_n)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_procedure:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_procedure:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.assetProcedureUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get asset procedure attachments",method:h.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(gn(a))}}class pS extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),a=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:u,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,fields_revision:u,submitted_at:s,field_identifier:p});c.push(b);const I={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:u};r.push(I)}this.dispatch(jn(c));const o=this.enqueueRequest({description:"Add asset procedure fields attachments",method:h.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(qn(d.attachments))}).catch(()=>{this.dispatch(Mn(c.map(d=>d.uuid)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:h.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(En(s))}}class AS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Vn(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:h.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Gn(m))}).catch(m=>{throw this.dispatch($n(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:h.GET,url:"/asset-procedure-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Un(s))}}function tt(t,e){const s=[];let a=0;const n=t.length;for(;a<n;)s.push(t.slice(a,a+=e));return s}class yS extends E{async bulkAdd(e,s){var d;const a=new Date().toISOString(),n=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=tt(e,s??e.length),r=[],o=[];for(const u of c){const p={},A=[];for(const y of u){const{fieldValuesUuid:b,fieldIdentifier:I,file:R}=y,_=await this.getFilePayload(R);_.sha1 in p||(p[_.sha1]=_);const M=F({file:URL.createObjectURL(R),file_type:R.type,file_name:R.name,file_sha1:_.sha1,created_by:n,field_values:b,submitted_at:a,field_identifier:I});r.push(M);const Et={uuid:M.uuid,file_name:R.name,file_sha1:_.sha1,file_extension:_.extension,field_identifier:I,field_values:b};A.push(Et)}o.push({submitted_at:a,attachments:A,files:Object.values(p)})}this.dispatch(it(r));const m=o.map(u=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:h.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:u,blockers:u.attachments.map(p=>p.field_values),blocks:u.attachments.map(p=>p.uuid)}));return Promise.all(m).then(u=>{for(const A of u)this.processPresignedUrls(A.presigned_urls);const p=u.flatMap(A=>A.attachments);this.dispatch(Hn(p))}).catch(u=>{throw this.dispatch(at(r.map(p=>p.uuid))),u}),[r,m.map(u=>u.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,a=s.getState(),n=Kn(e)(a);this.dispatch(at(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:h.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(it(n)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:h.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Jn(s))}}class fS extends P{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,created_by:(r=a.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/",payload:O(n),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[n.uuid]});return this.dispatch(Zt(n)),c.then(o=>(this.dispatch(Ge(o)),o)).catch(()=>{this.dispatch(xt(n.uuid))}),[n,c]}bulkAdd(e,s){var m;const a=new Date().toISOString(),n=[],c=tt(e.payloads,s??e.payloads.length),r=[];for(const d of c){const u=[];for(const p of d){const A=F({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:a});n.push(A),u.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,published_at:p.published_at,values:A.values})}r.push({submitted_at:a,values:e.values,field_values:u})}this.dispatch(xn(n));const o=[];for(const d of r){const u=d.field_values.map(I=>I.asset),p=d.field_values.map(I=>I.fields_revision),A=d.field_values.map(I=>I.asset_procedure_instance),y=d.field_values.map(I=>I.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/bulk/",payload:d,blockers:[...u,...p,...A],blocks:y});o.push(b)}return Promise.all(o).then(d=>{this.dispatch(ec(d.flat()))}).catch(()=>{this.dispatch(tc(n.map(d=>d.uuid)))}),[n,o]}update(e){const{store:s}=this.client,a=s.getState(),n=ts(e.uuid)(a);if(!n)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const c={...n,...e};this.dispatch(Ge(c));const r=this.enqueueRequest({description:"Update asset procedure field values",method:h.PATCH,url:`/asset-procedure-field-values/${e.uuid}/`,payload:e,blockers:[c.fields_revision,c.asset,c.asset_procedure_instance],blocks:[c.uuid]});return r.then(o=>{this.dispatch(Ge(o))}).catch(()=>{this.dispatch(Ge(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=ts(e)(a);if(!n)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Yn(e)(a);this.dispatch(xt(e)),this.dispatch(at(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:h.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Zt(n)),this.dispatch(it(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:h.GET,url:"/asset-procedure-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Zn(s))}}class SS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(is(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:h.POST,url:"/asset-procedure-instances/",payload:O(c),blockers:[e.asset_procedure,e.asset_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch($e(m))}).catch(()=>{this.dispatch(as(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=rs(e.uuid)(s.getState());if(!a)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const n={...a,...e};this.dispatch($e(n));const c=this.enqueueRequest({description:"Update asset procedure instance",method:h.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[a.uuid],blocks:[a.uuid]});return c.then(r=>{this.dispatch($e(r))}).catch(()=>{this.dispatch($e(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=rs(e)(a);if(!n)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(as(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:h.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(is(n)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:h.GET,url:"/asset-procedure-instances/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(nc(s))}}class gS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(os(c));const r=this.enqueueRequest({description:"Create asset procedure",method:h.POST,url:"/asset-procedures/",payload:O(c),blockers:[],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Le(m))}).catch(()=>{this.dispatch(us(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=hs(e.uuid)(s.getState());if(!a)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const n={...a,...e};this.dispatch(Le(n));const c=this.enqueueRequest({description:"Update asset procedure",method:h.PATCH,url:`/asset-procedures/${e.uuid}/`,payload:e,blockers:[a.uuid],blocks:[a.uuid]});return c.then(r=>{this.dispatch(Le(r))}).catch(()=>{this.dispatch(Le(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=hs(e)(a);if(!n)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const c=dc(e)(a);return this.dispatch(us(e)),this.dispatch(rc(c.map(r=>r.uuid))),this.enqueueRequest({description:"Delete asset procedure",method:h.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(os(n)),this.dispatch(cc(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:h.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(lc(s))}}class bS extends P{add(e){var o;const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(ps(c));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/assets/",payload:O(c),blockers:[c.asset_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Be(m))}).catch(()=>{this.dispatch(ys(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=gs(e.uuid)(s.getState());if(!a)throw new Error(`No asset with uuid ${e.uuid} found in the store`);const n={...a,...e};if(!n.canvas_marker&&!n.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(Be(n));const c=this.enqueueRequest({description:"Edit asset",method:h.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(Be(r))}).catch(()=>{this.dispatch(Be(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=gs(e)(a);if(!n)throw new Error(`No asset with uuid ${e} found in the store`);const c=yn(e)(a),r=kd(e)(a),o=uo(e)(a);if(this.dispatch(ys(e)),c.length>0){const m=c.map(({uuid:d})=>d);this.dispatch(Nt(m))}if(r.length>0){const m=r.map(({uuid:d})=>d);this.dispatch(ft(m))}if(o.length>0){const m=o.map(({uuid:d})=>d);this.dispatch(Ci(m))}return this.enqueueRequest({description:"Delete asset",method:h.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(ps(n)),this.dispatch(Bt(c)),this.dispatch(yt(r)),this.dispatch(Mi(o)),m})}bulkAdd(e,s,a,n){const c=new Date().toISOString(),r=Te.v4(),o=tt(e,n).map(u=>{const p=u.map(A=>F(A));return{batchId:Te.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:a,assets:p}}}),m=[];let d=null;for(const u of o){const{batchId:p,payload:A}=u,y=A.assets.map(_=>_.uuid),b=[s];d&&b.push(d);const I=y;I.push(p);const R=this.enqueueRequest({description:"Batch create assets",method:h.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:I});d=u.batchId,m.push(R)}return Promise.all(m).then(u=>{const p=u.flat();this.dispatch(As(p))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:h.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ac(s))}}class TS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Ts(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:h.POST,url:"/asset-stage-completions/",payload:O(c),blockers:[e.asset,e.stage],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Tc(m))}).catch(()=>{this.dispatch(Is(c.uuid))}),[c,r]}delete(e){const{store:s}=this.client,a=Rc(e)(s.getState());if(!a)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(Is(e));const n=this.enqueueRequest({description:"Delete asset stage completion",method:h.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Ts(a))}),n}bulkAdd(e){var d;const{store:s}=this.client,a=new Date().toISOString(),n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=e.map(u=>F(u)),r=c.map(u=>({...u,created_by:n,submitted_at:a})),o=r.map(({uuid:u})=>u);this.dispatch(Fs(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:h.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:a,completions:c},blockers:[...e.map(u=>u.asset_procedure_instance),...e.map(u=>u.stage),...e.map(u=>u.asset)],blocks:o});return m.then(u=>{this.dispatch(Fc(u))}).catch(()=>{this.dispatch(Rs(o))}),[r,m]}bulkDelete(e){const{store:s}=this.client,a=Pc(e)(s.getState());this.dispatch(Rs(e));const n=this.enqueueRequest({description:"Deleting asset stage completions",method:h.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return n.catch(()=>{this.dispatch(Fs(a))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:h.GET,url:"/asset-stage-completions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(bc(s))}}class FS extends P{bulkAdd(e,s){var m;const a=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c=e.map(d=>F(d)),r=c.map(d=>({...d,asset_procedure:s,created_by:n,submitted_at:a}));this.dispatch(_s(r));const o=this.enqueueRequest({description:"Add asset stages",method:h.POST,url:"/asset-stages/bulk/",payload:{submitted_at:a,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({uuid:d})=>d)});return o.then(d=>{this.dispatch(nt(d))}).catch(()=>{this.dispatch(ws(r.map(({uuid:d})=>d)))}),[r,o]}async bulkUpdate(e,s){const n=this.client.store.getState(),c=Es(e.map(({uuid:r})=>r))(n);return this.dispatch(nt(e)),this.enqueueRequest({description:"Edit asset stages",method:h.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(nt(c)),r})}async bulkDelete(e){const{store:s}=this.client,a=Es(e)(s.getState());this.dispatch(ws(e));const n=this.enqueueRequest({description:"Delete asset stages",method:h.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return n.catch(()=>{this.dispatch(_s(a))}),n}update(e){const{store:s}=this.client,a=Ec(e.uuid)(s.getState());if(!a)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const n={...a,...e};this.dispatch(vs(n));const c=this.enqueueRequest({description:"Update asset stage",method:h.PATCH,url:`/asset-stages/${a.uuid}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[a.uuid],blocks:[a.uuid]});return c.then(r=>{this.dispatch(vs(r))}).catch(()=>{this.dispatch(vc(a))}),[n,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:h.GET,url:"/asset-stages/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(_c(s))}}class IS extends be{constructor(){super(...arguments);f(this,"name","Asset Type Attachment");f(this,"url","/asset-type-attachments");f(this,"addAttachments",qs);f(this,"updateAttachments",Cc);f(this,"removeAttachments",Ms);f(this,"removeAttachment",zc);f(this,"setAttachment",kc);f(this,"selectAttachment",Vc)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_type:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.assetTypeUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get asset type attachments",method:h.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(Mc(a))}}class RS extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),a=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:u,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,fields_revision:u,submitted_at:s,field_identifier:p});c.push(b);const I={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:u};r.push(I)}this.dispatch(Nc(c));const o=this.enqueueRequest({description:"Add asset type fields attachments",method:h.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Jc(d.attachments))}).catch(()=>{this.dispatch(Hc(c.map(d=>d.uuid)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:h.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Bc(s))}}class PS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Zc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:h.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(xc(m))}).catch(m=>{throw this.dispatch(er(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:h.GET,url:"/asset-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Qc(s))}}class OS extends E{async bulkAdd(e,s){var d;const a=new Date().toISOString(),n=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=tt(e,s??e.length),r=[],o=[];for(const u of c){const p={},A=[];for(const y of u){const{fieldValuesUuid:b,fieldIdentifier:I,file:R}=y,_=await this.getFilePayload(R);_.sha1 in p||(p[_.sha1]=_);const M=F({file:URL.createObjectURL(R),file_type:R.type,file_name:R.name,file_sha1:_.sha1,created_by:n,field_values:b,submitted_at:a,field_identifier:I});r.push(M);const Et={uuid:M.uuid,file_name:R.name,file_sha1:_.sha1,file_extension:_.extension,field_identifier:I,field_values:b};A.push(Et)}o.push({submitted_at:a,attachments:A,files:Object.values(p)})}this.dispatch(dt(r));const m=o.map(u=>this.enqueueRequest({description:"Add asset type field values attachments",method:h.POST,url:"/asset-type-field-values-attachments/bulk/",payload:u,blockers:u.attachments.map(p=>p.field_values),blocks:u.attachments.map(p=>p.uuid)}));return Promise.all(m).then(u=>{for(const A of u)this.processPresignedUrls(A.presigned_urls);const p=u.flatMap(A=>A.attachments);this.dispatch(nr(p))}).catch(u=>{throw this.dispatch(ot(r.map(p=>p.uuid))),u}),[r,m.map(u=>u.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,a=s.getState(),n=rr(e)(a);this.dispatch(ot(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:h.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(dt(n)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:h.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ar(s))}}class _S extends P{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,created_by:(r=a.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:h.POST,url:"/asset-type-field-values/",payload:O(n),blockers:[e.asset,e.fields_revision],blocks:[n.uuid]});return this.dispatch(Vs(n)),c.then(o=>(this.dispatch(Ne(o)),o)).catch(()=>{this.dispatch(Gs(n.uuid))}),[n,c]}bulkAdd(e,s){var m;const a=new Date().toISOString(),n=[],c=tt(e.payloads,s??e.payloads.length),r=[];for(const d of c){const u=[];for(const p of d){const A=F({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:a});n.push(A),u.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}r.push({submitted_at:a,values:e.values,field_values:u})}this.dispatch(hr(n));const o=[];for(const d of r){const u=d.field_values.map(b=>b.asset),p=d.field_values.map(b=>b.fields_revision),A=d.field_values.map(b=>b.uuid),y=this.enqueueRequest({description:"Bulk add asset type field values",method:h.POST,url:"/asset-type-field-values/bulk/",payload:d,blockers:[...u,...p],blocks:A});o.push(y)}return Promise.all(o).then(d=>{this.dispatch(mr(d.flat()))}).catch(()=>{this.dispatch(pr(n.map(d=>d.uuid)))}),[n,o]}update(e){const{store:s}=this.client,a=s.getState(),n=Ls(e.uuid)(a);if(!n)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const c={...n,...e};this.dispatch(Ne(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:h.PATCH,url:`/asset-type-field-values/${e.uuid}/`,payload:e,blockers:[c.uuid,c.fields_revision,c.asset],blocks:[c.uuid]});return r.then(o=>{this.dispatch(Ne(o))}).catch(()=>{this.dispatch(Ne(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=Ls(e)(a);if(!n)throw new Error(`Expected submission with uuid ${e} to exist`);const c=dr(e)(a);this.dispatch(Gs(e)),this.dispatch(ot(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset type field values",method:h.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Vs(n)),this.dispatch(dt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:h.GET,url:"/asset-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(lr(s))}}class vS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Ns(c));const r=this.enqueueRequest({description:"Create asset type",method:h.POST,url:"/asset-types/",payload:O(c),blockers:[],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Je(m))}).catch(()=>{this.dispatch(Js(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=Ws(e.uuid)(s.getState());if(!a)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const n={...a,...e};this.dispatch(Je(n));const c=this.enqueueRequest({description:"Update asset type",method:h.PATCH,url:`/asset-types/${e.uuid}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[a.uuid],blocks:[a.uuid]});return c.then(r=>{this.dispatch(Je(r))}).catch(()=>{this.dispatch(Je(a))}),[n,c]}async delete(e){const{store:s}=this.client,a=s.getState(),n=Ws(e)(a);if(!n)throw new Error(`Expected asset type with uuid ${e} to exist`);const c=Ss(e)(a),r=Gc(e)(a);return this.dispatch(Js(e)),this.dispatch(yc(c.map(o=>o.uuid))),this.dispatch(Ms(r.map(({uuid:o})=>o))),this.enqueueRequest({description:"Delete asset type",method:h.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(o=>{throw this.dispatch(Ns(n)),this.dispatch(As(c)),this.dispatch(qs(r)),o})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:h.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Sr(s))}}class wS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Ys(c));const r=this.enqueueRequest({description:"Create Category",method:h.POST,url:"/categories/",payload:O(c),blockers:[e.project],blocks:[c.uuid]});return[c,r]}update(e){const s=this.client.store.getState(),a=Qs(e.uuid)(s);if(!a)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const n={...a,...e};this.dispatch(Pr(n));const c=this.enqueueRequest({description:"Edit Category",method:h.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[n,c]}remove(e){const{store:s}=this.client,a=Qs(e)(s.getState());if(!a)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(Or(e));const n=this.enqueueRequest({description:"Delete Category",method:h.DELETE,url:`/categories/${a.uuid}/`,blockers:[a.uuid],blocks:[]});return n.catch(()=>{this.dispatch(Ys(a))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:h.GET,url:"/categories/",queryParams:{project:e},blocks:[],blockers:[]});this.dispatch(Rr(s))}}class ES extends be{constructor(){super(...arguments);f(this,"name","Document Attachment");f(this,"url","/document-attachments");f(this,"addAttachments",Er);f(this,"updateAttachments",qr);f(this,"removeAttachments",kr);f(this,"removeAttachment",Mr);f(this,"setAttachment",jr);f(this,"selectAttachment",Dr)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelUuid})}buildAttachmentPayload(s){return{...s,document:s.modelUuid}}async bulkAdd(s){var p;const{store:a}=this.client,n=(p=a.getState().userReducer.currentUser)==null?void 0:p.id,c=new Date().toISOString(),r=[],o=[],m={},d={};for(const A of s){const{documentUuid:y,file:b}=A,I=await this.getFilePayload(b);I.sha1 in m||(m[I.sha1]=I,d[I.sha1]=[]);const R=this.buildOfflineAttachment({file:b,file_sha1:I.sha1,submitted_at:c,created_by:n,description:"",modelUuid:y});r.push(R),o.push({uuid:R.uuid,file_name:R.file_name,file_sha1:R.file_sha1,file_extension:I.extension,description:R.description,document:y}),d[I.sha1].push(R.uuid)}this.dispatch(this.addAttachments(r));const u=this.enqueueRequest({description:"Attach files to document",method:h.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:o,files:Object.values(m)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return u.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const b=this.processPresignedUrls(y);for(const[I,R]of Object.entries(b))R.then(()=>{const _=d[I];for(const M of _)this.makeReadable(M)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,u.then(({attachments:A})=>A)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:h.PATCH,url:`/document-attachments/${s}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",s],blocks:["index-document-attachment"]})}async refreshStore(s,a){const n=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(wr(n));const c=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/organizations/${a}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class jS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch($r([c]));const r=this.enqueueRequest({description:"Create Document",method:h.POST,url:"/documents/",payload:O(c),queryParams:{parent_document:c.parent_document??void 0},blockers:c.parent_document?[c.parent_document]:[],blocks:[c.uuid]});return r.catch(()=>{this.dispatch(ei([c.uuid]))}),[c,r]}update(e){const{store:s}=this.client,a=s.getState().documentsReducer.documents[e.uuid];if(!a)throw new Error(`attempting to update a document with uuid ${e.uuid} that does not exist in store.documents`);const n={...a,...e};this.dispatch(ge([n]));const c=this.enqueueRequest({description:"Update Document",method:h.PATCH,url:`/documents/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.catch(()=>{ge([a])}),[n,c]}move(e,s,a){const{store:n}=this.client,c=qe(n.getState()),r=[],o=c[e];if(!o)throw new Error(`attempting to move a document with uuid ${e} that does not exist in store.documents`);if(r.push(o),o.parent_document&&r.push(c[o.parent_document]),s){const d=c[s];if(!d)throw new Error(`attempting to move a document to target with uuid ${s} that does not exist in store.documents`);r.push(d),d.parent_document&&r.push(c[d.parent_document])}this.dispatch(Lr({documentId:e,targetDocumentId:s,position:a}));const m=this.enqueueRequest({description:"Move Document",method:h.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:a},blockers:[e],blocks:[]});return m.then(d=>{this.dispatch(ge(d))}).catch(()=>{this.dispatch(ge(r))}),m}delete(e){const{store:s}=this.client,a=qe(s.getState()),n=Nr(e)(s.getState());if(!n)throw new Error(`attempting to delete a document with uuid ${e} that does not exist in store.documents`);const c=n.parent_document?a[n.parent_document]:void 0;this.dispatch(ei([e]));const r=this.enqueueRequest({description:"Delete Document",method:h.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(o=>{this.dispatch(ge(o))}).catch(()=>{this.dispatch(ge([n])),c&&this.dispatch(ge([c]))}),r}async refreshStore(e,s){const a=this.enqueueRequest({description:"Get project documents",method:h.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),n=this.enqueueRequest({description:"Get organization documents",method:h.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(Gr([...await a,...await n]))}}class qS extends P{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:h.POST,url:"/organization-email-domains/",payload:{email:s,organization:e},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(Kr(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:h.DELETE,url:`/organization-email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(Wr(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:h.GET,url:"/organization-email-domains/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Hr(s))}}class MS extends P{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:h.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:h.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const vt={},Da=new Set;let wt=0,Ua=0,Va=0;const kS=20;class CS extends P{constructor(){super(...arguments);f(this,"host");f(this,"_dbPromise",Oh.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const a=await this.fetchCache(s);if(!a)throw new Error(`File with sha1 ${s} not found in cache`);const n=await Ut(a,s),c=await this.enqueueRequest({description:"Get S3 URL",method:h.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await je(a),file_type:a.type,extension:a.name.split(".").pop(),size:a.size.toString()},blockers:[],blocks:[`s3-${n}`]});return"url"in c&&this.dispatch(ed({sha1:s,...c})),c}async addCache(s,a){if(Da.has(a))return;if(!s.type){const r=s.name.split("."),o=r[r.length-1];s=new File([s],s.name,{type:o})}if(!s.name||!s.size||!s.type)throw new Error("Cannot add files to cache that do not have a name, size and type.");const n=await this._dbPromise;!!await n.get("files",a)?(console.error("File already cached (this is unexpected at this point):",s.name,a),wt++):(await n.put("files",s,a),Ua++),Da.add(a),Va++,Va%kS===0&&console.debug(`File cache summary: ${wt} hits and ${Ua} misses, ${wt/(wt+Ua)*100}% hit rate over ${Va} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),Da.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const a=this.client.store.getState();return td(s)(a)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const a=await this.fetchCache(s);if(!a)throw new Error(`File with sha1 ${s} not found in cache`);const n=await Ut(a,s),c={file_name:a.name,file_sha1:s,file:n},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[c,Promise.resolve(void 0).then()];throw new Error(r.warning)}const o=r.url,m=this.enqueueRequest({url:o,description:"Upload file",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${n}`],blocks:[s],s3url:r});return[c,m]}async fetchFileFromUrl(s,a,n){const c=s.split("?")[0]??s,r=await this.fetchCache(a);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const u=await Qa(s),p=new File([u],n??a,{type:u.type});return await this.addCache(p,a),p}let o=vt[c],m=!0;o?m=!1:(o=new Promise(u=>{this.enqueueRequest({description:"Download file",method:h.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[a],blocks:[a]}).then(p=>{const A=new File([p],n??a,{type:p.type});u(A)})}),vt[c]=o);let d;try{d=await o}catch(u){throw m&&u instanceof q&&delete vt[c],u}if(m){const u=await je(d);if(u!==a){const y=`The hash of the file returned from the server (${u}) does not match the
8
+ `)}catch(n){console.error("Failed to extract error message from response body",n)}}else typeof t.body=="string"&&(s=t.body);else t!=null&&t.text?s=t.text:e instanceof Error&&(s=e.message);return!s||s.length>dS?De:s}class q extends Error{constructor(s){super(De);f(this,"status");f(this,"response");f(this,"message");f(this,"options");const{response:a,innerError:n}=s;this.message=s.message??oS(a,n)??De,this.status=(a==null?void 0:a.status)??0,this.response=a,s.discard=s.discard??!1,this.options=s}}class uS extends ch{constructor(e){super(e)}}class P extends ch{constructor(s,a){super(s);f(this,"auth");this.auth=a}}class lS extends P{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(a=>(this.dispatch(nn(a)),a))}async continueConversation(e,s,a){return this.enqueueRequest({description:"Prompt agent",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:a},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(n=>{this.dispatch(rn(n))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:h.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(cn(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:h.PUT,url:`/agents/responses/${e}/rate/`,payload:{rating:s},blockers:["rate"],blocks:["rate"]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get agent conversation history",method:h.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(an(s))}}class E extends P{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:a,assetTypeAttachmentReducer:n,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:o,formSubmissionAttachmentReducer:p,geoImageReducer:d,assetTypeFieldsAttachmentReducer:u,assetTypeFieldValuesAttachmentReducer:m,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(a.instances),Object.values(n.instances),Object.values(c.instances),Object.values(r.instances),Object.values(o.instances),Object.values(p.instances),Object.values(d.instances),Object.values(u.instances),Object.values(m.instances),Object.values(A.instances),Object.values(y.instances)).filter(I=>I.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[a,n]of Object.entries(e))s[a]=this.enqueueRequest({url:n.url,description:"Upload file to S3",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:a,blockers:[`s3-${n.fields.key}`],blocks:[a],s3url:n});return s}async getFilePayload(e){const s=await je(e),a={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),a}}class be extends E{async _bulkAdd(e){var d;const{store:s}=this.client,a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,n=new Date().toISOString(),c=[],r=[],o={};for(const u of e){const{modelUuid:m,file:A}=u,y=await this.getFilePayload(A);y.sha1 in o||(o[y.sha1]=y);const b=this.buildOfflineAttachment({file:A,file_sha1:y.sha1,submitted_at:n,created_by:a,description:"",modelUuid:m});c.push(b),r.push(this.buildAttachmentPayload({uuid:b.uuid,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:y.extension,description:b.description,modelUuid:m}))}this.dispatch(this.addAttachments(c));const p=this.enqueueRequest({description:`Add ${this.name}`,method:h.POST,url:`${this.url}/bulk/`,payload:{submitted_at:n,attachments:r,files:Object.values(o)},blocks:c.map(u=>u.uuid),blockers:c.map(u=>u.file_sha1)});return p.then(({attachments:u,presigned_urls:m})=>{this.dispatch(this.updateAttachments(u)),this.processPresignedUrls(m)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(u=>u.uuid)))}),[c,p.then(({attachments:u})=>u)]}async _delete(e){const{store:s}=this.client,a=this.selectAttachment(e)(s.getState());if(!a)throw new Error(`Attempting to delete attachment with uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(a.uuid));const n=this.enqueueRequest({description:`Delete ${this.name}`,method:h.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return n.then(()=>{this.getNumberOfAttachmentsWithSha1(a.file_sha1)===0&&this.client.files.removeCache(a.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(a))}),n}}class hS extends be{constructor(){super(...arguments);f(this,"name","Asset Attachment");f(this,"url","/asset-attachments");f(this,"initializeAttachments",Lt);f(this,"addAttachments",Bt);f(this,"updateAttachments",ln);f(this,"removeAttachments",Nt);f(this,"removeAttachment",hn);f(this,"setAttachment",un);f(this,"selectAttachment",An)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.assetUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get asset attachments",method:h.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Lt(a))}}class mS extends be{constructor(){super(...arguments);f(this,"name","Asset Procedure Attachment");f(this,"url","/asset-procedure-attachments");f(this,"addAttachments",bn);f(this,"updateAttachments",Fn);f(this,"removeAttachments",Rn);f(this,"removeAttachment",In);f(this,"setAttachment",Tn);f(this,"selectAttachment",_n)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_procedure:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_procedure:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.assetProcedureUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get asset procedure attachments",method:h.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(gn(a))}}class pS extends E{async bulkAdd(e){var p;const s=new Date().toISOString(),a=(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,n={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:u,fieldIdentifier:m,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,fields_revision:u,submitted_at:s,field_identifier:m});c.push(b);const I={uuid:b.uuid,file_name:A.name,field_identifier:m,file_extension:y.extension,file_sha1:y.sha1,fields_revision:u};r.push(I)}this.dispatch(jn(c));const o=this.enqueueRequest({description:"Add asset procedure fields attachments",method:h.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(qn(d.attachments))}).catch(()=>{this.dispatch(Mn(c.map(d=>d.uuid)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:h.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(En(s))}}class AS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Vn(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:h.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.uuid]});return r.then(p=>{this.dispatch(Gn(p))}).catch(p=>{throw this.dispatch($n(c.uuid)),p}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:h.GET,url:"/asset-procedure-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Un(s))}}function tt(t,e){const s=[];let a=0;const n=t.length;for(;a<n;)s.push(t.slice(a,a+=e));return s}class yS extends E{async bulkAdd(e,s){var d;const a=new Date().toISOString(),n=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=tt(e,s??e.length),r=[],o=[];for(const u of c){const m={},A=[];for(const y of u){const{fieldValuesUuid:b,fieldIdentifier:I,file:R}=y,_=await this.getFilePayload(R);_.sha1 in m||(m[_.sha1]=_);const M=F({file:URL.createObjectURL(R),file_type:R.type,file_name:R.name,file_sha1:_.sha1,created_by:n,field_values:b,submitted_at:a,field_identifier:I});r.push(M);const Et={uuid:M.uuid,file_name:R.name,file_sha1:_.sha1,file_extension:_.extension,field_identifier:I,field_values:b};A.push(Et)}o.push({submitted_at:a,attachments:A,files:Object.values(m)})}this.dispatch(it(r));const p=o.map(u=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:h.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:u,blockers:u.attachments.map(m=>m.field_values),blocks:u.attachments.map(m=>m.uuid)}));return Promise.all(p).then(u=>{for(const A of u)this.processPresignedUrls(A.presigned_urls);const m=u.flatMap(A=>A.attachments);this.dispatch(Hn(m))}).catch(u=>{throw this.dispatch(at(r.map(m=>m.uuid))),u}),[r,p.map(u=>u.then(({attachments:m})=>m))]}async bulkDelete(e){const{store:s}=this.client,a=s.getState(),n=Kn(e)(a);this.dispatch(at(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:h.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(it(n)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:h.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Jn(s))}}class fS extends P{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,created_by:(r=a.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/",payload:O(n),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[n.uuid]});return this.dispatch(Zt(n)),c.then(o=>(this.dispatch(Ge(o)),o)).catch(()=>{this.dispatch(xt(n.uuid))}),[n,c]}bulkAdd(e,s){var p;const a=new Date().toISOString(),n=[],c=tt(e.payloads,s??e.payloads.length),r=[];for(const d of c){const u=[];for(const m of d){const A=F({...m,values:m.values,created_by:(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,submitted_at:a});n.push(A),u.push({uuid:A.uuid,asset:m.asset,fields_revision:m.fields_revision,asset_procedure_instance:m.asset_procedure_instance,published_at:m.published_at,values:A.values})}r.push({submitted_at:a,values:e.values,field_values:u})}this.dispatch(xn(n));const o=[];for(const d of r){const u=d.field_values.map(I=>I.asset),m=d.field_values.map(I=>I.fields_revision),A=d.field_values.map(I=>I.asset_procedure_instance),y=d.field_values.map(I=>I.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/bulk/",payload:d,blockers:[...u,...m,...A],blocks:y});o.push(b)}return Promise.all(o).then(d=>{this.dispatch(ec(d.flat()))}).catch(()=>{this.dispatch(tc(n.map(d=>d.uuid)))}),[n,o]}update(e){const{store:s}=this.client,a=s.getState(),n=ts(e.uuid)(a);if(!n)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const c={...n,...e};this.dispatch(Ge(c));const r=this.enqueueRequest({description:"Update asset procedure field values",method:h.PATCH,url:`/asset-procedure-field-values/${e.uuid}/`,payload:e,blockers:[c.fields_revision,c.asset,c.asset_procedure_instance],blocks:[c.uuid]});return r.then(o=>{this.dispatch(Ge(o))}).catch(()=>{this.dispatch(Ge(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=ts(e)(a);if(!n)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Yn(e)(a);this.dispatch(xt(e)),this.dispatch(at(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:h.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Zt(n)),this.dispatch(it(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:h.GET,url:"/asset-procedure-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Zn(s))}}class SS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(is(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:h.POST,url:"/asset-procedure-instances/",payload:O(c),blockers:[e.asset_procedure,e.asset_type],blocks:[c.uuid]});return r.then(p=>{this.dispatch($e(p))}).catch(()=>{this.dispatch(as(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=rs(e.uuid)(s.getState());if(!a)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const n={...a,...e};this.dispatch($e(n));const c=this.enqueueRequest({description:"Update asset procedure instance",method:h.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[a.uuid],blocks:[a.uuid]});return c.then(r=>{this.dispatch($e(r))}).catch(()=>{this.dispatch($e(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=rs(e)(a);if(!n)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(as(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:h.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(is(n)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:h.GET,url:"/asset-procedure-instances/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(nc(s))}}class gS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(os(c));const r=this.enqueueRequest({description:"Create asset procedure",method:h.POST,url:"/asset-procedures/",payload:O(c),blockers:[],blocks:[c.uuid]});return r.then(p=>{this.dispatch(Le(p))}).catch(()=>{this.dispatch(us(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=hs(e.uuid)(s.getState());if(!a)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const n={...a,...e};this.dispatch(Le(n));const c=this.enqueueRequest({description:"Update asset procedure",method:h.PATCH,url:`/asset-procedures/${e.uuid}/`,payload:e,blockers:[a.uuid],blocks:[a.uuid]});return c.then(r=>{this.dispatch(Le(r))}).catch(()=>{this.dispatch(Le(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=hs(e)(a);if(!n)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const c=dc(e)(a);return this.dispatch(us(e)),this.dispatch(rc(c.map(r=>r.uuid))),this.enqueueRequest({description:"Delete asset procedure",method:h.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(os(n)),this.dispatch(cc(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:h.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(lc(s))}}class bS extends P{add(e){var o;const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(ps(c));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/assets/",payload:O(c),blockers:[c.asset_type],blocks:[c.uuid]});return r.then(p=>{this.dispatch(Be(p))}).catch(()=>{this.dispatch(ys(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=gs(e.uuid)(s.getState());if(!a)throw new Error(`No asset with uuid ${e.uuid} found in the store`);const n={...a,...e};if(!n.canvas_marker&&!n.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(Be(n));const c=this.enqueueRequest({description:"Edit asset",method:h.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(Be(r))}).catch(()=>{this.dispatch(Be(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=gs(e)(a);if(!n)throw new Error(`No asset with uuid ${e} found in the store`);const c=yn(e)(a),r=Cd(e)(a),o=uo(e)(a);if(this.dispatch(ys(e)),c.length>0){const p=c.map(({uuid:d})=>d);this.dispatch(Nt(p))}if(r.length>0){const p=r.map(({uuid:d})=>d);this.dispatch(ft(p))}if(o.length>0){const p=o.map(({uuid:d})=>d);this.dispatch(zi(p))}return this.enqueueRequest({description:"Delete asset",method:h.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(p=>{throw this.dispatch(ps(n)),this.dispatch(Bt(c)),this.dispatch(yt(r)),this.dispatch(Mi(o)),p})}bulkAdd(e,s,a,n){const c=new Date().toISOString(),r=Te.v4(),o=tt(e,n).map(u=>{const m=u.map(A=>F(A));return{batchId:Te.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:a,assets:m}}}),p=[];let d=null;for(const u of o){const{batchId:m,payload:A}=u,y=A.assets.map(_=>_.uuid),b=[s];d&&b.push(d);const I=y;I.push(m);const R=this.enqueueRequest({description:"Batch create assets",method:h.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:I});d=u.batchId,p.push(R)}return Promise.all(p).then(u=>{const m=u.flat();this.dispatch(As(m))}),p}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:h.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ac(s))}}class TS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Ts(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:h.POST,url:"/asset-stage-completions/",payload:O(c),blockers:[e.asset,e.stage],blocks:[c.uuid]});return r.then(p=>{this.dispatch(Tc(p))}).catch(()=>{this.dispatch(Is(c.uuid))}),[c,r]}delete(e){const{store:s}=this.client,a=Rc(e)(s.getState());if(!a)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(Is(e));const n=this.enqueueRequest({description:"Delete asset stage completion",method:h.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Ts(a))}),n}bulkAdd(e){var d;const{store:s}=this.client,a=new Date().toISOString(),n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=e.map(u=>F(u)),r=c.map(u=>({...u,created_by:n,submitted_at:a})),o=r.map(({uuid:u})=>u);this.dispatch(Fs(r));const p=this.enqueueRequest({description:"Bulk create asset stage completions",method:h.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:a,completions:c},blockers:[...e.map(u=>u.asset_procedure_instance),...e.map(u=>u.stage),...e.map(u=>u.asset)],blocks:o});return p.then(u=>{this.dispatch(Fc(u))}).catch(()=>{this.dispatch(Rs(o))}),[r,p]}bulkDelete(e){const{store:s}=this.client,a=Pc(e)(s.getState());this.dispatch(Rs(e));const n=this.enqueueRequest({description:"Deleting asset stage completions",method:h.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return n.catch(()=>{this.dispatch(Fs(a))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:h.GET,url:"/asset-stage-completions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(bc(s))}}class FS extends P{bulkAdd(e,s){var p;const a=new Date().toISOString(),n=(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,c=e.map(d=>F(d)),r=c.map(d=>({...d,asset_procedure:s,created_by:n,submitted_at:a}));this.dispatch(_s(r));const o=this.enqueueRequest({description:"Add asset stages",method:h.POST,url:"/asset-stages/bulk/",payload:{submitted_at:a,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({uuid:d})=>d)});return o.then(d=>{this.dispatch(nt(d))}).catch(()=>{this.dispatch(ws(r.map(({uuid:d})=>d)))}),[r,o]}async bulkUpdate(e,s){const n=this.client.store.getState(),c=Es(e.map(({uuid:r})=>r))(n);return this.dispatch(nt(e)),this.enqueueRequest({description:"Edit asset stages",method:h.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(nt(c)),r})}async bulkDelete(e){const{store:s}=this.client,a=Es(e)(s.getState());this.dispatch(ws(e));const n=this.enqueueRequest({description:"Delete asset stages",method:h.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return n.catch(()=>{this.dispatch(_s(a))}),n}update(e){const{store:s}=this.client,a=Ec(e.uuid)(s.getState());if(!a)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const n={...a,...e};this.dispatch(vs(n));const c=this.enqueueRequest({description:"Update asset stage",method:h.PATCH,url:`/asset-stages/${a.uuid}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[a.uuid],blocks:[a.uuid]});return c.then(r=>{this.dispatch(vs(r))}).catch(()=>{this.dispatch(vc(a))}),[n,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:h.GET,url:"/asset-stages/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(_c(s))}}class IS extends be{constructor(){super(...arguments);f(this,"name","Asset Type Attachment");f(this,"url","/asset-type-attachments");f(this,"addAttachments",qs);f(this,"updateAttachments",zc);f(this,"removeAttachments",Ms);f(this,"removeAttachment",kc);f(this,"setAttachment",Cc);f(this,"selectAttachment",Vc)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_type:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.assetTypeUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get asset type attachments",method:h.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(Mc(a))}}class RS extends E{async bulkAdd(e){var p;const s=new Date().toISOString(),a=(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,n={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:u,fieldIdentifier:m,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,fields_revision:u,submitted_at:s,field_identifier:m});c.push(b);const I={uuid:b.uuid,file_name:A.name,field_identifier:m,file_extension:y.extension,file_sha1:y.sha1,fields_revision:u};r.push(I)}this.dispatch(Nc(c));const o=this.enqueueRequest({description:"Add asset type fields attachments",method:h.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Jc(d.attachments))}).catch(()=>{this.dispatch(Hc(c.map(d=>d.uuid)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:h.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Bc(s))}}class PS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Zc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:h.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.uuid]});return r.then(p=>{this.dispatch(xc(p))}).catch(p=>{throw this.dispatch(er(c.uuid)),p}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:h.GET,url:"/asset-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Qc(s))}}class OS extends E{async bulkAdd(e,s){var d;const a=new Date().toISOString(),n=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=tt(e,s??e.length),r=[],o=[];for(const u of c){const m={},A=[];for(const y of u){const{fieldValuesUuid:b,fieldIdentifier:I,file:R}=y,_=await this.getFilePayload(R);_.sha1 in m||(m[_.sha1]=_);const M=F({file:URL.createObjectURL(R),file_type:R.type,file_name:R.name,file_sha1:_.sha1,created_by:n,field_values:b,submitted_at:a,field_identifier:I});r.push(M);const Et={uuid:M.uuid,file_name:R.name,file_sha1:_.sha1,file_extension:_.extension,field_identifier:I,field_values:b};A.push(Et)}o.push({submitted_at:a,attachments:A,files:Object.values(m)})}this.dispatch(dt(r));const p=o.map(u=>this.enqueueRequest({description:"Add asset type field values attachments",method:h.POST,url:"/asset-type-field-values-attachments/bulk/",payload:u,blockers:u.attachments.map(m=>m.field_values),blocks:u.attachments.map(m=>m.uuid)}));return Promise.all(p).then(u=>{for(const A of u)this.processPresignedUrls(A.presigned_urls);const m=u.flatMap(A=>A.attachments);this.dispatch(nr(m))}).catch(u=>{throw this.dispatch(ot(r.map(m=>m.uuid))),u}),[r,p.map(u=>u.then(({attachments:m})=>m))]}async bulkDelete(e){const{store:s}=this.client,a=s.getState(),n=rr(e)(a);this.dispatch(ot(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:h.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(dt(n)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:h.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ar(s))}}class _S extends P{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,created_by:(r=a.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:h.POST,url:"/asset-type-field-values/",payload:O(n),blockers:[e.asset,e.fields_revision],blocks:[n.uuid]});return this.dispatch(Vs(n)),c.then(o=>(this.dispatch(Ne(o)),o)).catch(()=>{this.dispatch(Gs(n.uuid))}),[n,c]}bulkAdd(e,s){var p;const a=new Date().toISOString(),n=[],c=tt(e.payloads,s??e.payloads.length),r=[];for(const d of c){const u=[];for(const m of d){const A=F({...m,values:m.values,created_by:(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,submitted_at:a});n.push(A),u.push({uuid:A.uuid,asset:m.asset,fields_revision:m.fields_revision,published_at:m.published_at,values:A.values})}r.push({submitted_at:a,values:e.values,field_values:u})}this.dispatch(hr(n));const o=[];for(const d of r){const u=d.field_values.map(b=>b.asset),m=d.field_values.map(b=>b.fields_revision),A=d.field_values.map(b=>b.uuid),y=this.enqueueRequest({description:"Bulk add asset type field values",method:h.POST,url:"/asset-type-field-values/bulk/",payload:d,blockers:[...u,...m],blocks:A});o.push(y)}return Promise.all(o).then(d=>{this.dispatch(mr(d.flat()))}).catch(()=>{this.dispatch(pr(n.map(d=>d.uuid)))}),[n,o]}update(e){const{store:s}=this.client,a=s.getState(),n=Ls(e.uuid)(a);if(!n)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const c={...n,...e};this.dispatch(Ne(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:h.PATCH,url:`/asset-type-field-values/${e.uuid}/`,payload:e,blockers:[c.uuid,c.fields_revision,c.asset],blocks:[c.uuid]});return r.then(o=>{this.dispatch(Ne(o))}).catch(()=>{this.dispatch(Ne(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=Ls(e)(a);if(!n)throw new Error(`Expected submission with uuid ${e} to exist`);const c=dr(e)(a);this.dispatch(Gs(e)),this.dispatch(ot(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset type field values",method:h.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Vs(n)),this.dispatch(dt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:h.GET,url:"/asset-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(lr(s))}}class vS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Ns(c));const r=this.enqueueRequest({description:"Create asset type",method:h.POST,url:"/asset-types/",payload:O(c),blockers:[],blocks:[c.uuid]});return r.then(p=>{this.dispatch(Je(p))}).catch(()=>{this.dispatch(Js(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=Ws(e.uuid)(s.getState());if(!a)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const n={...a,...e};this.dispatch(Je(n));const c=this.enqueueRequest({description:"Update asset type",method:h.PATCH,url:`/asset-types/${e.uuid}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[a.uuid],blocks:[a.uuid]});return c.then(r=>{this.dispatch(Je(r))}).catch(()=>{this.dispatch(Je(a))}),[n,c]}async delete(e){const{store:s}=this.client,a=s.getState(),n=Ws(e)(a);if(!n)throw new Error(`Expected asset type with uuid ${e} to exist`);const c=Ss(e)(a),r=Gc(e)(a);return this.dispatch(Js(e)),this.dispatch(yc(c.map(o=>o.uuid))),this.dispatch(Ms(r.map(({uuid:o})=>o))),this.enqueueRequest({description:"Delete asset type",method:h.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(o=>{throw this.dispatch(Ns(n)),this.dispatch(As(c)),this.dispatch(qs(r)),o})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:h.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Sr(s))}}class wS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Ys(c));const r=this.enqueueRequest({description:"Create Category",method:h.POST,url:"/categories/",payload:O(c),blockers:[e.project],blocks:[c.uuid]});return[c,r]}update(e){const s=this.client.store.getState(),a=Qs(e.uuid)(s);if(!a)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const n={...a,...e};this.dispatch(Pr(n));const c=this.enqueueRequest({description:"Edit Category",method:h.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[n,c]}remove(e){const{store:s}=this.client,a=Qs(e)(s.getState());if(!a)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(Or(e));const n=this.enqueueRequest({description:"Delete Category",method:h.DELETE,url:`/categories/${a.uuid}/`,blockers:[a.uuid],blocks:[]});return n.catch(()=>{this.dispatch(Ys(a))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:h.GET,url:"/categories/",queryParams:{project:e},blocks:[],blockers:[]});this.dispatch(Rr(s))}}class ES extends be{constructor(){super(...arguments);f(this,"name","Document Attachment");f(this,"url","/document-attachments");f(this,"addAttachments",Er);f(this,"updateAttachments",qr);f(this,"removeAttachments",Cr);f(this,"removeAttachment",Mr);f(this,"setAttachment",jr);f(this,"selectAttachment",Dr)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelUuid})}buildAttachmentPayload(s){return{...s,document:s.modelUuid}}async bulkAdd(s){var m;const{store:a}=this.client,n=(m=a.getState().userReducer.currentUser)==null?void 0:m.id,c=new Date().toISOString(),r=[],o=[],p={},d={};for(const A of s){const{documentUuid:y,file:b}=A,I=await this.getFilePayload(b);I.sha1 in p||(p[I.sha1]=I,d[I.sha1]=[]);const R=this.buildOfflineAttachment({file:b,file_sha1:I.sha1,submitted_at:c,created_by:n,description:"",modelUuid:y});r.push(R),o.push({uuid:R.uuid,file_name:R.file_name,file_sha1:R.file_sha1,file_extension:I.extension,description:R.description,document:y}),d[I.sha1].push(R.uuid)}this.dispatch(this.addAttachments(r));const u=this.enqueueRequest({description:"Attach files to document",method:h.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:o,files:Object.values(p)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return u.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const b=this.processPresignedUrls(y);for(const[I,R]of Object.entries(b))R.then(()=>{const _=d[I];for(const M of _)this.makeReadable(M)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,u.then(({attachments:A})=>A)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:h.PATCH,url:`/document-attachments/${s}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",s],blocks:["index-document-attachment"]})}async refreshStore(s,a){const n=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(wr(n));const c=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/organizations/${a}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class jS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch($r([c]));const r=this.enqueueRequest({description:"Create Document",method:h.POST,url:"/documents/",payload:O(c),queryParams:{parent_document:c.parent_document??void 0},blockers:c.parent_document?[c.parent_document]:[],blocks:[c.uuid]});return r.catch(()=>{this.dispatch(ei([c.uuid]))}),[c,r]}update(e){const{store:s}=this.client,a=s.getState().documentsReducer.documents[e.uuid];if(!a)throw new Error(`attempting to update a document with uuid ${e.uuid} that does not exist in store.documents`);const n={...a,...e};this.dispatch(ge([n]));const c=this.enqueueRequest({description:"Update Document",method:h.PATCH,url:`/documents/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.catch(()=>{ge([a])}),[n,c]}move(e,s,a){const{store:n}=this.client,c=qe(n.getState()),r=[],o=c[e];if(!o)throw new Error(`attempting to move a document with uuid ${e} that does not exist in store.documents`);if(r.push(o),o.parent_document&&r.push(c[o.parent_document]),s){const d=c[s];if(!d)throw new Error(`attempting to move a document to target with uuid ${s} that does not exist in store.documents`);r.push(d),d.parent_document&&r.push(c[d.parent_document])}this.dispatch(Lr({documentId:e,targetDocumentId:s,position:a}));const p=this.enqueueRequest({description:"Move Document",method:h.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:a},blockers:[e],blocks:[]});return p.then(d=>{this.dispatch(ge(d))}).catch(()=>{this.dispatch(ge(r))}),p}delete(e){const{store:s}=this.client,a=qe(s.getState()),n=Nr(e)(s.getState());if(!n)throw new Error(`attempting to delete a document with uuid ${e} that does not exist in store.documents`);const c=n.parent_document?a[n.parent_document]:void 0;this.dispatch(ei([e]));const r=this.enqueueRequest({description:"Delete Document",method:h.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(o=>{this.dispatch(ge(o))}).catch(()=>{this.dispatch(ge([n])),c&&this.dispatch(ge([c]))}),r}async refreshStore(e,s){const a=this.enqueueRequest({description:"Get project documents",method:h.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),n=this.enqueueRequest({description:"Get organization documents",method:h.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(Gr([...await a,...await n]))}}class qS extends P{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:h.POST,url:"/organization-email-domains/",payload:{email:s,organization:e},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(Kr(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:h.DELETE,url:`/organization-email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(Wr(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:h.GET,url:"/organization-email-domains/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Hr(s))}}class MS extends P{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:h.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:h.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const vt={},Da=new Set;let wt=0,Ua=0,Va=0;const CS=20;class zS extends P{constructor(){super(...arguments);f(this,"host");f(this,"_dbPromise",Oh.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const a=await this.fetchCache(s);if(!a)throw new Error(`File with sha1 ${s} not found in cache`);const n=await Ut(a,s),c=await this.enqueueRequest({description:"Get S3 URL",method:h.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await je(a),file_type:a.type,extension:a.name.split(".").pop(),size:a.size.toString()},blockers:[],blocks:[`s3-${n}`]});return"url"in c&&this.dispatch(ed({sha1:s,...c})),c}async addCache(s,a){if(Da.has(a))return;if(!s.type){const r=s.name.split("."),o=r[r.length-1];s=new File([s],s.name,{type:o})}if(!s.name||!s.size||!s.type)throw new Error("Cannot add files to cache that do not have a name, size and type.");const n=await this._dbPromise;!!await n.get("files",a)?(console.error("File already cached (this is unexpected at this point):",s.name,a),wt++):(await n.put("files",s,a),Ua++),Da.add(a),Va++,Va%CS===0&&console.debug(`File cache summary: ${wt} hits and ${Ua} misses, ${wt/(wt+Ua)*100}% hit rate over ${Va} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),Da.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const a=this.client.store.getState();return td(s)(a)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const a=await this.fetchCache(s);if(!a)throw new Error(`File with sha1 ${s} not found in cache`);const n=await Ut(a,s),c={file_name:a.name,file_sha1:s,file:n},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[c,Promise.resolve(void 0).then()];throw new Error(r.warning)}const o=r.url,p=this.enqueueRequest({url:o,description:"Upload file",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${n}`],blocks:[s],s3url:r});return[c,p]}async fetchFileFromUrl(s,a,n){const c=s.split("?")[0]??s,r=await this.fetchCache(a);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const u=await Qa(s),m=new File([u],n??a,{type:u.type});return await this.addCache(m,a),m}let o=vt[c],p=!0;o?p=!1:(o=new Promise(u=>{this.enqueueRequest({description:"Download file",method:h.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[a],blocks:[a]}).then(m=>{const A=new File([m],n??a,{type:m.type});u(A)})}),vt[c]=o);let d;try{d=await o}catch(u){throw p&&u instanceof q&&delete vt[c],u}if(p){const u=await je(d);if(u!==a){const y=`The hash of the file returned from the server (${u}) does not match the
9
9
  expected hash (${a}). This can happen if you're using a local development server and the
10
10
  isExternalUrl flag in the request details is set to true, because instead of requesting the local
11
11
  REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
12
12
  (with an uuid attached) being returned. Alternatively, you may be running with
13
13
  import.meta.env.PROD, which will result in some file requests being treated as
14
- external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(y)}const p=d.type.split("/")[1];if(!p)throw new Error("File has no extension");const A=n??u+"."+p;if(d=Xa(d,A),!d.name)throw new Error("Failed to set file's name");await this.addCache(d,u),vt[c]=new Promise(y=>{y(d)})}return d}}class zS extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),a=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n={},c=[],r=[];for(const d of e){const{revisionUuid:u,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,form_revision:u,submitted_at:s,field_identifier:p});c.push(b);const I={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,form_revision:u};r.push(I)}this.dispatch(nd(c));const o=this.enqueueRequest({description:"Attach files to form revision",method:h.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.form_revision),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(cd(d.attachments))}).catch(()=>{this.dispatch(rd(c.map(d=>d.uuid)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:h.GET,url:"/form-revision-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(ad(s))}}class DS extends E{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=F({...e,created_by:n,submitted_at:new Date().toISOString()});this.dispatch(ni(c));const r=this.enqueueRequest({description:"Create form revision",method:h.POST,url:"/form-revisions/",payload:O(c),blockers:[e.form],blocks:[c.uuid]});return r.then(m=>{this.dispatch(ld(m))}).catch(()=>{this.dispatch(ci(c.uuid))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:h.GET,url:"/form-revisions/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(hd(s))}}class US extends E{add(e,s){var d;const{store:a}=this.client,n=new Date().toISOString(),c=(d=a.getState().userReducer.currentUser)==null?void 0:d.id,r=F({...e,submitted_at:n,created_by:c}),o=F({...s,form:r.uuid,submitted_at:n,created_by:c});this.dispatch(di(r)),this.dispatch(ni(o));const m=this.enqueueRequest({description:"Create form",method:h.POST,url:"/forms/",payload:{...O(r),initial_revision:{uuid:o.uuid,submitted_at:o.submitted_at,title:o.title,description:o.description,fields:o.fields}},blockers:[],blocks:[r.uuid,o.uuid]});return m.catch(u=>{throw this.dispatch(oi(r.uuid)),this.dispatch(ci(o.uuid)),u}),[r,o,m]}async delete(e){const{store:s}=this.client,a=s.getState(),n=Fd(e)(a);if(!n)throw new Error("Expected form to exist");const c=qd(e)(a);c.length>0&&this.dispatch(ft(c.map(({uuid:o})=>o)));const r=yd(e)(a);r.length>0&&this.dispatch(pd(r.map(({uuid:o})=>o))),this.dispatch(oi(e));try{return await this.enqueueRequest({description:"Delete form",method:h.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(di(n)),r.length>0&&this.dispatch(md(r)),c.length>0&&this.dispatch(yt(c)),o}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:h.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(gd(s))}}class VS extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),a=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n={},c=[],r=[];for(const d of e){const{submissionUuid:u,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,form_submission:u,submitted_at:s,field_identifier:p});c.push(b);const I={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,form_submission:u};r.push(I)}this.dispatch(mt(c));const o=this.enqueueRequest({description:"Attach files to form submission",method:h.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.form_submission),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Pd(d.attachments))}).catch(d=>{throw this.dispatch(pt(c.map(u=>u.uuid))),d}),[c,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,a=s.getState(),n=Od(e)(a);this.dispatch(pt(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:h.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(mt(n)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:h.GET,url:"/form-submission-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Rd(s))}}class GS extends E{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,created_by:(r=a.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:h.POST,url:"/form-submissions/",payload:O(n),blockers:["add-form-entry",e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[n.uuid]});return this.dispatch(mi(n)),c.then(o=>(this.dispatch(At(o)),o)).catch(()=>{this.dispatch(pi(n.uuid))}),[n,c]}update(e){const{store:s}=this.client,a=s.getState(),n=fi(e.uuid)(a);if(!n)throw new Error(`Expected submission with uuid ${e.uuid} to exist`);const c={...n,...e};this.dispatch(jd(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:h.PATCH,url:`/form-submissions/${c.uuid}/`,payload:e,blockers:[c.uuid],blocks:[c.uuid]});return r.then(o=>{this.dispatch(At(o))}).catch(()=>{this.dispatch(At(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=fi(e)(a);if(!n)throw new Error(`Expected submission with uuid ${e} to exist`);const c=_d(e)(a);this.dispatch(pi(e)),this.dispatch(pt(c.map(r=>r.uuid)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:h.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(mi(n)),this.dispatch(mt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:h.GET,url:"/form-submissions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ed(s))}}class $S extends E{async add(e){var p;const{store:s}=this.client,{file:a,...n}=e,c=new Date().toISOString(),r=(p=s.getState().userReducer.currentUser)==null?void 0:p.id,o=n.project,m=await this.getFilePayload(a),d=F({...n,file_name:a.name,file_sha1:m.sha1,file:URL.createObjectURL(a),submitted_at:c,created_by:r});this.dispatch(Vd(d));const u=this.enqueueRequest({description:"Add geo image",method:h.POST,url:"/geo-images/",payload:{uuid:d.uuid,submitted_at:c,title:d.title,description:d.description,geo_marker:d.geo_marker,canvas_marker:d.canvas_marker,sha1:d.file_sha1,project:d.project,file_name:d.file_name,direction:d.direction,original_date:d.original_date,file:m},blocks:[o],blockers:[o]});return u.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(We(A.geo_image))}).catch(()=>{this.dispatch(gi(d.uuid))}),[d,u.then(A=>A.geo_image)]}async bulkAdd(e,s){var p;const{store:a}=this.client,n=new Date().toISOString(),c=(p=a.getState().userReducer.currentUser)==null?void 0:p.id,r=[],o=[],m=[],d={};for(const A of e){const{file:y,...b}=A,I=await this.getFilePayload(y);I.sha1 in d||(d[I.sha1]=I);const R=F({...b,file_name:y.name,file_sha1:I.sha1,file:URL.createObjectURL(y),submitted_at:n,created_by:c,project:s});r.push(R),o.push(R.uuid),m.push({uuid:R.uuid,sha1:R.file_sha1,file_name:R.file_name,title:R.title,description:R.description,geo_marker:R.geo_marker,canvas_marker:R.canvas_marker,direction:R.direction,original_date:R.original_date})}this.dispatch(Gd(r));const u=this.enqueueRequest({description:"Bulk add geo images",method:h.POST,url:"/geo-images/bulk/",payload:{submitted_at:n,project:s,geo_images:m,files:Object.values(d)},blocks:[s],blockers:o});return u.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(Ud(A.geo_images))}).catch(()=>{this.dispatch(Ld(o))}),[r,u.then(A=>A.geo_images)]}update(e){const{store:s}=this.client,a=s.getState(),n=bi(e.uuid)(a);if(!n)throw new Error(`Map image with uuid ${e.uuid} does not exist in the store`);const c={...n,...e};this.dispatch($d(c));const r=this.enqueueRequest({description:"Update geo image",method:h.PATCH,url:`/geo-images/${e.uuid}/`,payload:e,blocks:[e.uuid],blockers:[e.uuid]});return r.then(o=>{this.dispatch(We(o))}).catch(()=>{this.dispatch(We(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=bi(e)(a);if(!n)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(gi(e));const c=this.enqueueRequest({description:"Delete geo image",method:h.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(We(n))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:h.GET,url:"/geo-images/",queryParams:{project:e},blocks:[e],blockers:[]});this.dispatch(Dd(s))}}class LS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Fi(c));const r=this.enqueueRequest({description:"Create GeoJSON feature",method:h.POST,url:"/geojson-features/",payload:O(c),blockers:[c.geojson_layer],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Ke(m))}).catch(()=>{this.dispatch(Ii(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=Pi(e.uuid)(s.getState());if(!a)throw new Error(`No GeoJSON feature with uuid ${e.uuid} found in the store`);const n={...a,...e};this.dispatch(Ke(n));const c=this.enqueueRequest({description:"Edit GeoJSON feature",method:h.PATCH,url:`/geojson-features/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(Ke(r))}).catch(()=>{this.dispatch(Ke(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=Pi(e)(a);if(!n)throw new Error(`No GeoJSON feature with uuid ${e} found in the store`);return this.dispatch(Ii(e)),this.enqueueRequest({description:"Delete GeoJSON feature",method:h.DELETE,url:`/geojson-features/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Fi(n)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get GeoJSON features",method:h.GET,url:"/geojson-features/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Wd(s))}}class BS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(_i(c));const r=this.enqueueRequest({description:"Create GeoJSON layer",method:h.POST,url:"/geojson-layers/",payload:O(c),blockers:[c.project],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Ye(m))}).catch(()=>{this.dispatch(vi(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=Ei(e.uuid)(s.getState());if(!a)throw new Error(`No GeoJSON layer with uuid ${e.uuid} found in the store`);const n={...a,...e};this.dispatch(Ye(n));const c=this.enqueueRequest({description:"Edit GeoJSON layer",method:h.PATCH,url:`/geojson-layers/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(Ye(r))}).catch(()=>{this.dispatch(Ye(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=Ei(e)(a);if(!n)throw new Error(`No GeoJSON layer with uuid ${e} found in the store`);const c=Qd(e)(a);if(this.dispatch(vi(e)),c.length>0){const r=c.map(({uuid:o})=>o);this.dispatch(Yd(r))}return this.enqueueRequest({description:"Delete GeoJSON layer",method:h.DELETE,url:`/geojson-layers/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(_i(n)),this.dispatch(Kd(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get GeoJSON layers",method:h.GET,url:"/geojson-layers/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(eo(s))}}class NS extends P{add(e){var o;const{store:s}=this.client,a=new Date().toISOString(),n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=F({...e,submitted_at:a,created_by:n});this.dispatch(qi(c));const r=this.enqueueRequest({description:"Add issue association",method:h.POST,url:"/issue-associations/",payload:O(c),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.uuid]});return r.then(m=>{this.dispatch(no(m))}).catch(()=>{this.dispatch(ki(c.uuid))}),[c,r]}async delete(e){const{store:s}=this.client,a=co(e)(s.getState());if(!a)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(ki(e));const n=this.enqueueRequest({description:"Delete issue association",method:h.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(qi(a))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:h.GET,url:"/issue-associations/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ao(s))}}class JS extends be{constructor(){super(...arguments);f(this,"name","Issue Attachment");f(this,"url","/issue-attachments");f(this,"initializeAttachments",Di);f(this,"addAttachments",Ui);f(this,"updateAttachments",po);f(this,"removeAttachments",Vi);f(this,"removeAttachment",Ao);f(this,"setAttachment",mo);f(this,"selectAttachment",go)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.issueUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get issue attachments",method:h.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Di(a))}}class HS extends be{constructor(){super(...arguments);f(this,"name","Issue Comment Attachment");f(this,"url","/issue-comment-attachments");f(this,"initializeAttachments",$i);f(this,"addAttachments",Fo);f(this,"updateAttachments",Ro);f(this,"removeAttachments",Oo);f(this,"removeAttachment",Po);f(this,"setAttachment",Io);f(this,"selectAttachment",wo)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_comment:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue_comment:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.issueCommentUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get issue comment attachments",method:h.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch($i(a))}}class WS extends P{add(e){var c;const{store:s}=this.client,a=F({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Ni(a));const n=this.enqueueRequest({description:"Add issue comment",method:h.POST,url:"/issue-comments/",payload:O(a),blockers:[e.issue],blocks:[a.uuid]});return n.catch(()=>{this.dispatch(Ji(a.uuid))}),[a,n]}update(e){const{store:s}=this.client,a=Hi(e.uuid)(s.getState());if(!a)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const n={...a,...e};this.dispatch(Bi(n));const c=this.enqueueRequest({description:"Edit issue comment",method:h.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.catch(()=>{this.dispatch(Bi(a))}),[n,c]}remove(e){const{store:s}=this.client,a=Hi(e)(s.getState());if(!a)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(Ji(e));const n=this.enqueueRequest({description:"Delete comment",method:h.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Ni(a))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:h.GET,url:"/issue-comments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(qo(s))}}class KS extends P{add(e){var m;const{store:s}=this.client,a=s.getState(),n=new Date().toISOString(),c=(m=a.userReducer.currentUser)==null?void 0:m.id,r=F({...e,submitted_at:n,created_by:c});this.dispatch(Ki(r));const o=this.enqueueRequest({description:"Create issue",method:h.POST,url:"/issues/",payload:O(r),blockers:["add-issue",r.project,r.issue_type,...r.category?[r.category]:[]],blocks:[r.uuid]});return o.then(d=>{this.dispatch(St(d))}).catch(d=>{throw this.dispatch(Yi(r.uuid)),d}),[r,o]}update(e){var m;const s=this.client.store.getState(),a=Xi(e.uuid)(s);if(!a)throw new Error(`Attempting to update an issue with uuid ${e.uuid} that doesn't exist in the store`);const n={...a,...e};this.dispatch(St(n));const c={};for(const d of[v.TITLE,v.DESCRIPTION,v.STATUS,v.CATEGORY,v.PRIORITY,v.ASSIGNED_TO,v.DUE_DATE])if(d in e&&e[d]!==a[d])switch(d){case v.PRIORITY:case v.STATUS:{const u=e[d];c[d]=u!==void 0?Number(u):null;break}case v.DUE_DATE:case v.DESCRIPTION:case v.TITLE:c[d]=e[d]??null;break;case v.CATEGORY:{let u=null;const p=e[d];if(p&&(u=s.categoryReducer.instances[p]??null,!u))throw new Error(`Trying to update issue category to ${p} which does not exist in store`);c[d]=u?{name:u.name,color:u.color,uuid:u.uuid}:null;break}case v.ASSIGNED_TO:{let u=null;const p=e[d];if(p&&(u=s.userReducer.instances[p]??null,!u))throw new Error(`Trying to update issue assigned_to to ${p} which does not exist in store`);c[d]=u?{full_name:u.username,id:u.id}:null;break}}const r=F({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:a.uuid,changes:c});this.dispatch(qu(r));const o=this.enqueueRequest({description:"Edit issue",method:h.PATCH,url:`/issues/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return o.catch(()=>{this.dispatch(St(a)),this.dispatch(ku(r.uuid))}),[n,o]}async remove(e){const{store:s}=this.client,a=s.getState(),n=Xi(e)(a);if(!n)throw new Error(`No issue with uuid ${e} found in the store`);const c=So(e)(a),r=Du(e)(a),o=Md(e)(a),m={};for(const u of ro(e)(a))m[u.uuid]=u;for(const u of oo(e)(a))m[u.uuid]=u;const d=Object.values(m);this.dispatch(Yi(e)),c.length>0&&this.dispatch(Vi(c.map(({uuid:u})=>u))),r.length>0&&this.dispatch(Cu(r.map(({uuid:u})=>u))),o.length>0&&this.dispatch(ft(o.map(({uuid:u})=>u))),d.length>0&&this.dispatch(Ci(d.map(({uuid:u})=>u)));try{return await this.enqueueRequest({description:"Delete issue",method:h.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(u){throw this.dispatch(Ki(n)),this.dispatch(Ui(c)),this.dispatch(Mu(r)),this.dispatch(yt(o)),this.dispatch(Mi(d)),u}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:h.GET,url:"/issues/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(zo(s))}}class YS extends be{constructor(){super(...arguments);f(this,"name","Issue Type Attachment");f(this,"url","/issue-type-attachments");f(this,"initializeAttachments",Zi);f(this,"addAttachments",Lo);f(this,"updateAttachments",No);f(this,"removeAttachments",Ho);f(this,"removeAttachment",Jo);f(this,"setAttachment",Bo);f(this,"selectAttachment",Yo)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_type:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue_type:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.issueTypeUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get issue type attachments",method:h.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(Zi(a))}}class XS extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),a=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:u,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,fields_revision:u,submitted_at:s,field_identifier:p});c.push(b);const I={uuid:b.uuid,file_name:A.name,file_extension:y.extension,field_identifier:p,file_sha1:y.sha1,fields_revision:u};r.push(I)}this.dispatch(xo(c));const o=this.enqueueRequest({description:"Add issue type fields attachments",method:h.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(eu(d.attachments))}).catch(()=>{this.dispatch(tu(c.map(d=>d.uuid)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:h.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Zo(s))}}class QS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(lu(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:h.POST,url:"/issue-type-fields/",payload:O(c),blockers:[c.issue_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(hu(m))}).catch(m=>{throw this.dispatch(mu(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:h.GET,url:"/issue-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(uu(s))}}class ZS extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),a=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n={},c=[],r=[];for(const d of e){const{fieldValuesUuid:u,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,field_values:u,submitted_at:s,field_identifier:p});c.push(b);const I={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,field_values:u};r.push(I)}this.dispatch(bt(c));const o=this.enqueueRequest({description:"Add issue type field values attachments",method:h.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.field_values),blocks:c.map(d=>d.uuid)});return o.then(({presigned_urls:d,attachments:u})=>{this.processPresignedUrls(d),this.dispatch(Su(u))}).catch(d=>{throw this.dispatch(Tt(c.map(u=>u.uuid))),d}),[c,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,a=s.getState(),n=bu(e)(a);this.dispatch(Tt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:h.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(bt(n)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values attachments",method:h.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(fu(s))}}class xS extends P{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,created_by:(r=a.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:h.POST,url:"/issue-type-field-values/",payload:O(n),blockers:[e.issue,e.fields_revision],blocks:[n.uuid]});return this.dispatch(ta(n)),c.then(o=>(this.dispatch(Qe(o)),o)).catch(()=>{this.dispatch(sa(n.uuid))}),[n,c]}update(e){const{store:s}=this.client,a=s.getState(),n=aa(e.uuid)(a);if(!n)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const c={...n,...e};this.dispatch(Qe(c));const r=this.enqueueRequest({description:"Update issue type field values",method:h.PATCH,url:`/issue-type-field-values/${e.uuid}/`,payload:e,blockers:[c.uuid,c.fields_revision,c.issue],blocks:[c.uuid]});return r.then(o=>{this.dispatch(Qe(o))}).catch(()=>{this.dispatch(Qe(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=aa(e)(a);if(!n)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Tu(e)(a);this.dispatch(sa(e)),this.dispatch(Tt(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete issue type field values",method:h.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ta(n)),this.dispatch(bt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:h.GET,url:"/issue-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(cu(s))}}class eg extends P{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,submitted_at:new Date().toISOString(),created_by:(r=a.userReducer.currentUser)==null?void 0:r.id});this.dispatch(Pu(n));const c=this.enqueueRequest({method:h.POST,url:"/issue-types/",payload:O(n),blockers:[],blocks:[n.uuid]});return c.then(o=>{this.dispatch(Ze(o))}).catch(()=>{this.dispatch(oa(n.uuid))}),[n,c]}update(e){const{store:s}=this.client,a=s.getState(),n=ua(e.uuid)(a);if(!n)throw new Error(`IssueType with uuid ${e.uuid} does not exist in the store.`);const c={...n,...e};this.dispatch(Ou(c));const r=this.enqueueRequest({method:h.PATCH,url:`/issue-types/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return r.then(o=>{this.dispatch(Ze(o))}).catch(()=>{this.dispatch(Ze(n))}),[c,r]}delete(e){const{store:s}=this.client,a=s.getState(),n=ua(e)(a);if(!n)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const c=la(e)(a);this.dispatch(oa(e)),this.dispatch(Uo(c.map(o=>o.uuid)));const r=this.enqueueRequest({method:h.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(Ze(n)),this.dispatch(Do(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:h.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Ru(s))}}class tg extends P{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:h.GET,url:"/issue-updates/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ju(s))}}const sg=1800;function ig(t){if(!t.access)throw new Error("Missing access token");if(!t.refresh)throw new Error("Missing refresh token");return{accessToken:t.access,refreshToken:t.refresh}}class ag extends uS{constructor(){super(...arguments);f(this,"_getRenewedTokens",async s=>{const a=this.enqueueRequest({description:"Get renewed tokens",method:h.POST,url:this.refreshTokensUrl,payload:{refresh:s},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let n;try{n=await a}catch(c){console.error("Could not renew tokens; clearing auth",c),this.clearAuth();return}if(!n.access)throw new Error("Missing access token");return{accessToken:n.access,refreshToken:n.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Tr(!1)),this.clearTokens(),this.dispatch({type:_h.RESET_STATE}),this.dispatch({type:ph})}async renewTokens(){const s=this.getRefreshToken();if(!s)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const a=await this._getRenewedTokens(s);if(!a)return;console.log("Got renewed tokens"),this.setTokens(a)}catch(a){throw console.error("Could not renew tokens; clearing auth",a),this.clearAuth(),a}}tokenIsExpiringSoon(){const s=this.getAccessToken();if(!s)return!1;const a=Date.now()/1e3;let n;try{n=vh(s).exp??a}catch{n=a}return n-a<sg}getAuthHeader(){return`Bearer ${this.getAccessToken()}`}async prepareAuth(){if(this.tokenIsExpiringSoon()){console.debug(this.constructor.name,"preparing auth");try{await this.renewTokens()}catch(s){return s instanceof q&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??De).toString()))}}}async handleUnauthorized(s,a){const n=this.client.store.getState();if(s.url.endsWith("/token/refresh/"))throw n.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new q({message:"You have been signed out due to inactivity.",response:a,discard:!0});if(n.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new q({message:"Incorrect username or password.",response:a,discard:!0})}async initAuth(s){const a=Te.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:a,description:"Get token pair",method:h.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(n=>{this.setTokens(ig(n))})}}class ng extends P{async getLicense(e){const s=await this.enqueueRequest({description:"Get license",method:h.GET,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(fe(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:h.DELETE,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(fe(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:h.PATCH,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(fe(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:h.DELETE,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(fe(s)),s}async attachLicenseToProject(e,s){const a=await this.enqueueRequest({description:"Attach license",method:h.PATCH,url:`/billing/${e.uuid}/project/`,isAuthNeeded:!0,payload:{project:s.uuid},blockers:[e.organization_owner,s.uuid],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(fe(a)),a}async detachLicenseFromProject(e){const s=await this.enqueueRequest({description:"Detach license",method:h.DELETE,url:`/billing/${e.uuid}/project/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(fe(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:h.GET,url:`/billing/${e.uuid}/transaction/`,isAuthNeeded:!0,blockers:[e.uuid],blocks:[e.uuid]})}async refreshStore(e,s){const a={},n=await this.enqueueRequest({description:"Get licenses",method:h.GET,url:`/organizations/${s}/licenses/`,isAuthNeeded:!0,blockers:[s],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of n)a[r.uuid]=r;const c=await this.enqueueRequest({description:"Get licenses",method:h.GET,url:`/projects/${e}/licenses/`,isAuthNeeded:!0,blockers:[e],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of c)a[r.uuid]=r;this.dispatch(Gu(Object.values(a)))}}class cg extends P{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:h.PATCH,url:`/organization-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return s.then(()=>{this.dispatch(Yu(e))}),s}async remove(e){return this.dispatch(Xu(e.uuid)),this.dispatch(Ju(e.user)),this.enqueueRequest({description:"Remove organization access",method:h.DELETE,url:`/organization-accesses/${e.uuid}/`,blockers:[e.uuid],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:h.GET,url:"/organization-accesses/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Ku(s))}}class rg extends P{create(e){return this.enqueueRequest({description:"Create organization",method:h.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:h.PATCH,url:`/organizations/${e.uuid}/`,payload:e,blockers:[`add-org-${e.name}`,e.uuid],blocks:[e.uuid]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:h.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const a={},n=await this.enqueueRequest({description:"Get organizations",method:h.GET,url:`/projects/${e}/organizations/`,blockers:[],blocks:[]});for(const r of n)a[r.uuid]=r;const c=await this.enqueueRequest({description:"Get organization",method:h.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});a[c.uuid]=c,this.dispatch(Al(Object.values(a)))}}class dg extends P{async update(e){return this.dispatch(el(e)),this.enqueueRequest({description:"Edit project access",method:h.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid,"change-access-level"],blocks:[e.uuid]})}async remove(e){return this.dispatch(tl(e)),this.enqueueRequest({description:"Delete project access",method:h.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:h.GET,url:"/project-accesses/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Sa(s))}}class og extends be{constructor(){super(...arguments);f(this,"name","Project Attachment");f(this,"url","/project-attachments");f(this,"addAttachments",wl);f(this,"updateAttachments",ql);f(this,"removeAttachments",Ra);f(this,"removeAttachment",Ml);f(this,"setAttachment",El);f(this,"selectAttachment",zl)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,project:s.modelUuid})}buildAttachmentPayload(s){return{...s,project:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.projectUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get project attachments",method:h.GET,url:`${this.url}/`,queryParams:{project:s},blockers:[],blocks:[]});this.dispatch(vl(a))}}class ug extends P{async saveExisting(e){if(!e.uuid)throw new Error("You can only use this method to save existing project files. The one provided has no uuid.");const s={...e};delete s.file;const a=this.enqueueRequest({method:h.PATCH,url:`/projects/files/${e.uuid}/`,payload:s,blockers:[e.uuid],blocks:[e.uuid]});return a.then(n=>{this.dispatch(Oa(n))}),a}saveActive(){const{store:e}=this.client,s=e.getState(),a=s.projectFileReducer.activeProjectFileId;if(!a)throw new Error("No active project file");const n=s.projectFileReducer.instances[a];if(!n)throw new Error("No active project file");if(!n.bounds&&!n.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let c;if(typeof n.file=="string"&&!n.file.startsWith("blob:")){const m={...n};delete m.file,c={method:h.PATCH,url:`/projects/files/${a}/`,payload:m,blockers:[a],blocks:[a]}}else c=new Promise((m,d)=>{this.client.files.uploadFileToS3(n.file_sha1).then(([u])=>{m({method:h.POST,url:`/projects/${n.project}/files/`,payload:{...n,...u},blockers:[a],blocks:[a]})}).catch(d)});const o=Promise.resolve(c).then(m=>this.enqueueRequest(m));return o.then(m=>{this.dispatch(Oa(m))}),this.dispatch(Hl),this.dispatch(Jl(null)),this.dispatch(Nl(!1)),[n,o]}delete(e){return this.dispatch(Ll(e)),this.enqueueRequest({method:h.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:h.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(Gl(s))}}class lg extends P{async add(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return await this.enqueueRequest({description:"Create project",method:h.POST,url:"/projects/",payload:{name:e.name,bounds:e.bounds,organization_owner:e.organization_owner},blockers:[],blocks:[]})}async update(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return this.dispatch(dl(e)),await this.enqueueRequest({description:"Update project",method:h.PATCH,url:`/projects/${e.uuid}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.uuid],blocks:[e.uuid]})}async delete(e){const{store:s}=this.client,a=s.getState(),n=_t(a),c=n[e];if(!c)throw new Error("Expected project to exist");const r=Kl(a).filter(u=>u.project===e);this.dispatch(Bl(r.map(({uuid:u})=>u)));const o=Dl(c.uuid)(a);this.dispatch(Ra(o.map(({uuid:u})=>u)));const m=il(a);this.dispatch(sl(m.map(({uuid:u})=>u))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(ol(c.uuid));const d=$u(c.uuid)(a);d&&this.dispatch(fe({...d,project:null}));try{await this.enqueueRequest({description:"Delete project",method:h.DELETE,url:`/projects/${e}/`,blockers:[e],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(u){throw this.dispatch(rl(Object.values(n))),this.dispatch(Sa(Object.values(m))),this.dispatch($l(r)),this.dispatch(jl(o)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),d&&this.dispatch(fe({...d,project:c.uuid})),u}}invite(e,s){const a=Te.v4();return this.enqueueRequest({description:"Invite user to project",method:h.POST,url:`/projects/${e}/invite/${s}/`,payload:{uuid:a},blockers:[],blocks:[a]})}joinProject(e,s,a){return this.enqueueRequest({description:"Join project",method:h.GET,url:`/projects/${e}/join-project/${s}/${a}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:h.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e],blocks:[e]}).then(()=>{this.dispatch(ul(e))})}}class hg extends P{add(e){const s=F({...e,submitted_at:new Date().toISOString()});this.dispatch(xl(s));const a=this.enqueueRequest({description:"Create team",method:h.POST,url:"/teams/",payload:s,blockers:[],blocks:[s.uuid]});return a.then(n=>{this.dispatch(Ce(n))}).catch(()=>{this.dispatch(Ea(s.uuid))}),[s,a]}update(e){const{store:s}=this.client,a=ze(e.uuid)(s.getState());if(!a)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const n={...a,...e};this.dispatch(wa(n));const c=this.enqueueRequest({description:"Update team",method:h.PATCH,url:`/teams/${e.uuid}/`,payload:O(e),blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(Ce(r))}).catch(()=>{this.dispatch(Ce(a))}),[n,c]}async delete(e){const{store:s}=this.client,a=s.getState(),n=ze(e)(a);if(!n)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(Ea(e));try{return await this.enqueueRequest({description:"Delete team",method:h.DELETE,url:`/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(Ce(n)),c}}async setMembers(e,s){const{store:a}=this.client,n=ze(e)(a.getState());if(!n)throw new Error(`Expected team with uuid ${e} to exist`);if(s.length!==new Set(s).size)throw new Error("Duplicate members found in the list");this.dispatch(wa({...n,members:s}));const c=this.enqueueRequest({description:"Set team members",method:h.PUT,url:`/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(Ce(n))}),c}async addMembers(e,s){const{store:a}=this.client,n=ze(e)(a.getState());if(!n)throw new Error(`Expected team with uuid ${e} to exist`);const c=[...n.members,...s];return this.setMembers(e,c)}async removeMembers(e,s){const{store:a}=this.client,n=ze(e)(a.getState());if(!n)throw new Error(`Expected team with uuid ${e} to exist`);const c=n.members.filter(r=>!s.includes(r));return this.setMembers(e,c)}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:h.GET,url:"/teams/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Zl(s))}}class mg extends P{async refreshStore(e,s){const a={},n=await this.enqueueRequest({description:"Fetch organization users",method:h.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of n)a[r.id]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:h.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)a[r.id]=r;this.dispatch(Nu(Object.values(a)))}}class pg{constructor(e){f(this,"store");this.store=e}async enqueueRequest(e,s,a){return this._enqueueRequest(e,s,a).then(n=>{if(n instanceof q)throw n;return n})}_enqueueRequest(e,s,a){const n=new Ka,c={...e,BASE_URL:s,serviceName:a};if(e.immediate){const r={...c,uuid:e.uuid??Te.v4()},o={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:a}}}};Ca(o,this).then(m=>{n.resolve(m.body)}).catch(m=>{za(m,o),m instanceof Error?n.reject(m):n.reject(new Error((m??De).toString()))})}else{const r=this.store.dispatch(Il(c)),o=d=>{if(d)n.resolve(d.body);else{const u=new q({message:"Could not get a response from the server.",response:d,discard:!0});n.reject(u)}},m=d=>{d instanceof q?d.options.discard=!0:(console.error("Received an unexpected error while processing a request:",d,`
15
- Converting error to APIError and discarding.`),d=new q({message:"An error occurred while processing the request.",innerError:d,discard:!0})),n.reject(d)};r.then(o,m)}return n}}class Ue{constructor(){f(this,"graph");f(this,"requestAttemptCounter");this.graph=new wh.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Ue;for(let a=0;a<e.length;a++){const n=e[a];if(!n){console.error("Outbox item was undefined");continue}s.sneakRequest(n);for(let c=0;c<a;c++){const r=e[c];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==n.payload.uuid&&r.payload.blocks.some(o=>n.payload.blockers.includes(o))&&Ue._addDependency(n.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){Ue._addDependency(e,s,this.graph)}static _addDependency(e,s,a){if(e===s)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!a.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${s})`);if(!a.hasNode(s))throw new Error(`Tried to add dependency to non-existent node: ${s} (from node: ${e})`);a.addDependency(e,s)}addRequest(e){if(this.graph.addNode(e.payload.uuid,e),!(e.payload.blockers.length===0||this.graph.size()===1))for(const s of this.graph.overallOrder()){if(s===e.payload.uuid)continue;const a=this.graph.getNodeData(s);e.payload.blockers.some(n=>a.payload.blocks.includes(n))&&this._addDependency(e.payload.uuid,s)}}insertRequest(e){this.graph.addNode(e.payload.uuid,e);for(const s of this.graph.overallOrder()){if(s===e.payload.uuid)continue;this.graph.getNodeData(s).payload.blockers.some(n=>e.payload.blocks.includes(n))&&this._addDependency(s,e.payload.uuid)}}sneakRequest(e){this.graph.addNode(e.payload.uuid,e)}_getNextNode(){const e=this.graph.overallOrder(!0);let s=1/0,a;for(const n of e){const c=this.requestAttemptCounter[n]||0;c<s&&(s=c,a=n)}return a}peek(){const e=this._getNextNode();if(e)return this.graph.getNodeData(e)}remove(e){this.graph.removeNode(e),delete this.requestAttemptCounter[e]}pop(){const e=this.peek();return e&&this.graph.removeNode(e.payload.uuid),e}getQueue(){const e=this.graph.overallOrder().map(a=>this.graph.getNodeData(a)),s=this._getNextNode();if(s){const a=this.graph.getNodeData(s),n=e.findIndex(c=>c.payload.uuid===a.payload.uuid);n!==-1&&(e.splice(n,1),e.unshift(a))}return e}getReady(){let e=this.graph.overallOrder(!0).map(s=>this.graph.getNodeData(s));return e=e.sort((s,a)=>s.meta.offline.effect.timestamp.localeCompare(a.meta.offline.effect.timestamp)),e=e.sort((s,a)=>{const n=this.requestAttemptCounter[s.payload.uuid]||0,c=this.requestAttemptCounter[a.payload.uuid]||0;return n-c}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const Ag=(t,e)=>{const s=new e(t);return Bf(s),Lf(t),s};var bh=(t=>(t[t.USER_REGISTRATION=0]="USER_REGISTRATION",t[t.APPLICATION_INVITE=2]="APPLICATION_INVITE",t[t.PROJECT_INVITE=4]="PROJECT_INVITE",t[t.ORGANIZATION_INVITE=6]="ORGANIZATION_INVITE",t[t.ADD_EMAIL_DOMAIN=8]="ADD_EMAIL_DOMAIN",t[t.RESET_PASSWORD=10]="RESET_PASSWORD",t))(bh||{});i.APIError=q,i.AgentService=lS,i.AssetAttachmentService=hS,i.AssetProcedureAttachmentService=mS,i.AssetProcedureFieldValuesAttachmentService=yS,i.AssetProcedureFieldValuesService=fS,i.AssetProcedureFieldsAttachmentService=pS,i.AssetProcedureFieldsService=AS,i.AssetProcedureInstanceService=SS,i.AssetProcedureService=gS,i.AssetService=bS,i.AssetStageCompletionService=TS,i.AssetStageService=FS,i.AssetTypeAttachmentService=IS,i.AssetTypeFieldValuesAttachmentService=OS,i.AssetTypeFieldValuesService=_S,i.AssetTypeFieldsAttachmentService=RS,i.AssetTypeFieldsService=PS,i.AssetTypeService=vS,i.AttachmentModel=Ba,i.BaseApiService=P,i.BaseSDK=pg,i.COMMON_AUTO_FIELDS=xa,i.CategoryService=wS,i.DEFAULT_ISSUE_PRIORITY=jh,i.DEFAULT_ISSUE_STATUS=Eh,i.DeferredPromise=Ka,i.DocumentAttachmentService=ES,i.DocumentService=jS,i.EMPTY_ARRAY=$a,i.EMPTY_OBJECT=La,i.EmailDomainsService=qS,i.EmailVerificationService=MS,i.FileService=CS,i.FormRevisionAttachmentService=zS,i.FormRevisionService=DS,i.FormService=US,i.FormSubmissionAttachmentService=VS,i.FormSubmissionService=GS,i.GeoImageService=$S,i.GeoJsonFeatureService=LS,i.GeoJsonLayerService=BS,i.HttpMethod=h,i.IssueAssociationService=NS,i.IssueAttachmentService=JS,i.IssueCommentAttachmentService=HS,i.IssueCommentService=WS,i.IssuePriority=Mt,i.IssueService=KS,i.IssueStatus=kt,i.IssueTypeAttachmentService=YS,i.IssueTypeFieldValuesAttachmentService=ZS,i.IssueTypeFieldValuesService=xS,i.IssueTypeFieldsAttachmentService=XS,i.IssueTypeFieldsService=QS,i.IssueTypeService=eg,i.IssueUpdateChange=v,i.IssueUpdateService=tg,i.JWTService=ag,i.LicenseLevel=Ja,i.LicenseService=ng,i.LicenseStatus=Ha,i.OUTBOX_RETRY_DELAY=Wa,i.OrganizationAccessLevel=qt,i.OrganizationAccessService=cg,i.OrganizationService=rg,i.OutboxCoordinator=Ue,i.PaddleCheckoutEvent=Na,i.ProjectAccessLevel=jt,i.ProjectAccessService=dg,i.ProjectAttachmentService=og,i.ProjectFileService=ug,i.ProjectService=lg,i.TeamService=hg,i.UNKNOWN_ERROR_MESSAGE=De,i.UserService=mg,i.VERSION_REDUCER_KEY=Ma,i.VerificationCodeType=bh,i._setLatestRetryTime=Pl,i.acceptProjectInvite=ul,i.addAsset=ps,i.addAssetAttachment=im,i.addAssetAttachments=Bt,i.addAssetProcedure=os,i.addAssetProcedureAttachment=cm,i.addAssetProcedureAttachments=bn,i.addAssetProcedureFieldValues=Zt,i.addAssetProcedureFieldValuesAttachment=Pm,i.addAssetProcedureFieldValuesAttachments=it,i.addAssetProcedureFieldValuesMany=xn,i.addAssetProcedureFields=Vn,i.addAssetProcedureFieldsAttachment=um,i.addAssetProcedureFieldsAttachments=jn,i.addAssetProcedureFieldsMany=fm,i.addAssetProcedureInstance=is,i.addAssetProcedureInstances=cc,i.addAssetProcedures=Gm,i.addAssetStage=ep,i.addAssetStageCompletion=Ts,i.addAssetStageCompletions=Fs,i.addAssetStages=_s,i.addAssetType=Ns,i.addAssetTypeAttachment=ap,i.addAssetTypeAttachments=qs,i.addAssetTypeFieldValues=Vs,i.addAssetTypeFieldValuesAttachment=Fp,i.addAssetTypeFieldValuesAttachments=dt,i.addAssetTypeFieldValuesMany=hr,i.addAssetTypeFields=Zc,i.addAssetTypeFieldsAttachment=rp,i.addAssetTypeFieldsAttachments=Nc,i.addAssetTypeFieldsMany=pp,i.addAssetTypes=kp,i.addAssets=As,i.addCategory=Ys,i.addConversation=nn,i.addDocumentAttachment=Hp,i.addDocumentAttachments=Er,i.addDocuments=$r,i.addEmailDomain=Wr,i.addForm=di,i.addFormRevision=ni,i.addFormRevisionAttachment=sA,i.addFormRevisionAttachments=nd,i.addFormRevisions=md,i.addFormSubmission=mi,i.addFormSubmissionAttachment=AA,i.addFormSubmissionAttachments=mt,i.addFormSubmissions=yt,i.addForms=hA,i.addGeoImage=Vd,i.addGeoImages=Gd,i.addGeoJsonFeature=Fi,i.addGeoJsonFeatures=Kd,i.addGeoJsonLayer=_i,i.addGeoJsonLayers=vA,i.addIssue=Ki,i.addIssueAssociation=qi,i.addIssueAssociations=Mi,i.addIssueAttachment=VA,i.addIssueAttachments=Ui,i.addIssueComment=Ni,i.addIssueCommentAttachment=LA,i.addIssueCommentAttachments=Fo,i.addIssueComments=HA,i.addIssueType=Pu,i.addIssueTypeAttachment=XA,i.addIssueTypeAttachments=Lo,i.addIssueTypeFieldValues=ta,i.addIssueTypeFieldValuesAttachment=Fy,i.addIssueTypeFieldValuesAttachments=bt,i.addIssueTypeFieldValuesMany=ry,i.addIssueTypeFields=lu,i.addIssueTypeFieldsAttachment=ey,i.addIssueTypeFieldsAttachments=xo,i.addIssueTypeFieldsMany=my,i.addIssueUpdate=qu,i.addIssueUpdates=Mu,i.addIssues=Do,i.addLicenses=qy,i.addOrganization=hf,i.addOrganizations=lf,i.addProject=sf,i.addProjectAttachment=Pf,i.addProjectAttachments=wl,i.addProjectFile=wf,i.addProjectFiles=$l,i.addProjects=tf,i.addTeam=xl,i.addUser=Vy,i.addUsers=Uy,i.agentsReducer=dn,i.agentsSlice=Vt,i.areArraysEqual=Dh,i.assetAttachmentReducer=fn,i.assetAttachmentSlice=$t,i.assetProcedureAttachmentReducer=vn,i.assetProcedureAttachmentSlice=Jt,i.assetProcedureFieldValuesAttachmentReducer=Xn,i.assetProcedureFieldValuesAttachmentSlice=Yt,i.assetProcedureFieldValuesReducer=ic,i.assetProcedureFieldValuesSlice=Qt,i.assetProcedureFieldsAttachmentReducer=zn,i.assetProcedureFieldsAttachmentSlice=Ht,i.assetProcedureFieldsReducer=Bn,i.assetProcedureFieldsSlice=Wt,i.assetProcedureInstanceReducer=oc,i.assetProcedureInstanceSlice=ss,i.assetProcedureReducer=mc,i.assetProcedureSlice=ds,i.assetReducer=Sc,i.assetSlice=ms,i.assetStageCompletionReducer=Ic,i.assetStageCompletionSlice=bs,i.assetStageReducer=wc,i.assetStageSlice=Os,i.assetTypeAttachmentReducer=$c,i.assetTypeAttachmentSlice=js,i.assetTypeFieldValuesAttachmentReducer=or,i.assetTypeFieldValuesAttachmentSlice=zs,i.assetTypeFieldValuesReducer=yr,i.assetTypeFieldValuesSlice=Us,i.assetTypeFieldsAttachmentReducer=Yc,i.assetTypeFieldsAttachmentSlice=ks,i.assetTypeFieldsReducer=sr,i.assetTypeFieldsSlice=Cs,i.assetTypeReducer=gr,i.assetTypeSlice=Bs,i.authReducer=Fr,i.authSlice=ut,i.blobToBase64=Hh,i.categoryReducer=_r,i.categorySlice=Ks,i.clearTokens=Gp,i.constructUploadedFilePayloads=Jh,i.coordinatesAreEqual=Ch,i.createModelAdapter=T,i.createMultiPointGeometry=kh,i.createOfflineAction=Tl,i.createPayload=O,i.createPointGeometry=Mh,i.createSelectionAdapter=qh,i.deleteAsset=ys,i.deleteAssetAttachment=hn,i.deleteAssetAttachments=Nt,i.deleteAssetProcedure=us,i.deleteAssetProcedureAttachment=In,i.deleteAssetProcedureAttachments=Rn,i.deleteAssetProcedureFieldValues=xt,i.deleteAssetProcedureFieldValuesAttachment=wm,i.deleteAssetProcedureFieldValuesAttachments=at,i.deleteAssetProcedureFieldValuesMany=tc,i.deleteAssetProcedureFields=$n,i.deleteAssetProcedureFieldsAttachment=pm,i.deleteAssetProcedureFieldsAttachments=Mn,i.deleteAssetProcedureFieldsMany=Tm,i.deleteAssetProcedureInstance=as,i.deleteAssetProcedureInstances=rc,i.deleteAssetProcedures=Lm,i.deleteAssetStage=tp,i.deleteAssetStageCompletion=Is,i.deleteAssetStageCompletions=Rs,i.deleteAssetStages=ws,i.deleteAssetType=Js,i.deleteAssetTypeAttachment=zc,i.deleteAssetTypeAttachments=Ms,i.deleteAssetTypeFieldValues=Gs,i.deleteAssetTypeFieldValuesAttachment=Op,i.deleteAssetTypeFieldValuesAttachments=ot,i.deleteAssetTypeFieldValuesMany=pr,i.deleteAssetTypeFields=er,i.deleteAssetTypeFieldsAttachment=lp,i.deleteAssetTypeFieldsAttachments=Hc,i.deleteAssetTypeFieldsMany=Sp,i.deleteAssetTypes=zp,i.deleteAssets=yc,i.deleteCategory=Or,i.deleteDocumentAttachment=Mr,i.deleteDocumentAttachments=kr,i.deleteEmailDomain=Kr,i.deleteForm=oi,i.deleteFormRevision=ci,i.deleteFormRevisionAttachment=cA,i.deleteFormRevisionAttachments=rd,i.deleteFormRevisions=pd,i.deleteFormSubmission=pi,i.deleteFormSubmissionAttachment=gA,i.deleteFormSubmissionAttachments=pt,i.deleteFormSubmissions=ft,i.deleteGeoImage=gi,i.deleteGeoImages=Ld,i.deleteGeoJsonFeature=Ii,i.deleteGeoJsonFeatures=Yd,i.deleteGeoJsonLayer=vi,i.deleteGeoJsonLayers=EA,i.deleteIssue=Yi,i.deleteIssueAssociation=ki,i.deleteIssueAssociations=Ci,i.deleteIssueAttachment=Ao,i.deleteIssueAttachments=Vi,i.deleteIssueComment=Ji,i.deleteIssueCommentAttachment=Po,i.deleteIssueCommentAttachments=Oo,i.deleteIssueComments=WA,i.deleteIssueTypeAttachment=Jo,i.deleteIssueTypeAttachments=Ho,i.deleteIssueTypeFieldValues=sa,i.deleteIssueTypeFieldValuesAttachment=Oy,i.deleteIssueTypeFieldValuesAttachments=Tt,i.deleteIssueTypeFieldValuesMany=ly,i.deleteIssueTypeFields=mu,i.deleteIssueTypeFieldsAttachment=ay,i.deleteIssueTypeFieldsAttachments=tu,i.deleteIssueTypeFieldsMany=fy,i.deleteIssueUpdate=ku,i.deleteIssueUpdates=Cu,i.deleteIssues=Uo,i.deleteOrganization=Af,i.deleteOrganizationAccess=Xu,i.deleteOrganizations=yf,i.deleteProject=ol,i.deleteProjectAccess=tl,i.deleteProjectAccesses=sl,i.deleteProjectAttachment=Ml,i.deleteProjectAttachments=Ra,i.deleteProjectFile=Ll,i.deleteProjectFiles=Bl,i.deleteProjects=nf,i.deleteTeam=Ea,i.deleteUser=Ly,i.deleteUsers=By,i.dequeue=yh,i.discard=za,i.documentAttachmentReducer=Ur,i.documentAttachmentSlice=Zs,i.documentSlice=xs,i.documentsReducer=Jr,i.downloadFile=Wh,i.downloadInMemoryFile=Nh,i.emailDomainsReducer=Qr,i.emailDomainsSlice=ti,i.emailRegex=em,i.enqueue=Ah,i.enqueueRequest=Il,i.fallbackToEmptyArray=S,i.fallbackToEmptyObject=Ee,i.fileReducer=sd,i.fileSlice=si,i.fileToBlob=Qa,i.formReducer=bd,i.formRevisionAttachmentReducer=od,i.formRevisionAttachmentSlice=ii,i.formRevisionReducer=fd,i.formRevisionsSlice=ai,i.formSlice=ri,i.formSubmissionAttachmentReducer=vd,i.formSubmissionAttachmentSlice=ui,i.formSubmissionReducer=Cd,i.formSubmissionSlice=hi,i.geoImageReducer=Jd,i.geoImageSlice=Si,i.geoJsonFeatureReducer=Zd,i.geoJsonFeatureSlice=Ti,i.geoJsonLayerReducer=so,i.geoJsonLayerSlice=Oi,i.getFileIdentifier=Bh,i.getFileS3Key=Ut,i.getLocalDateString=Ya,i.getLocalRelativeDateString=$h,i.getOutboxCoordinator=_e,i.getRenamedFile=Xa,i.hashFile=je,i.initSDK=Ag,i.initializeAssetAttachments=Lt,i.initializeAssetProcedureAttachments=gn,i.initializeAssetProcedureFieldValues=Zn,i.initializeAssetProcedureFieldValuesAttachments=Jn,i.initializeAssetProcedureFields=Un,i.initializeAssetProcedureFieldsAttachments=En,i.initializeAssetProcedureInstances=nc,i.initializeAssetProcedures=lc,i.initializeAssetStageCompletions=bc,i.initializeAssetStages=_c,i.initializeAssetTypeAttachments=Mc,i.initializeAssetTypeFieldValues=lr,i.initializeAssetTypeFieldValuesAttachments=ar,i.initializeAssetTypeFields=Qc,i.initializeAssetTypeFieldsAttachments=Bc,i.initializeAssetTypes=Sr,i.initializeAssets=Ac,i.initializeCategories=Rr,i.initializeConversations=an,i.initializeDocumentAttachments=wr,i.initializeEmailDomains=Hr,i.initializeFormRevisionAttachments=ad,i.initializeFormRevisions=hd,i.initializeFormSubmissionAttachments=Rd,i.initializeFormSubmissions=Ed,i.initializeForms=gd,i.initializeGeoImages=Dd,i.initializeGeoJsonFeatures=Wd,i.initializeGeoJsonLayers=eo,i.initializeIssueAssociations=ao,i.initializeIssueAttachments=Di,i.initializeIssueCommentAttachments=$i,i.initializeIssueTypeAttachments=Zi,i.initializeIssueTypeFieldValues=cu,i.initializeIssueTypeFieldValuesAttachments=fu,i.initializeIssueTypeFields=uu,i.initializeIssueTypeFieldsAttachments=Zo,i.initializeIssueTypes=Ru,i.initializeIssueUpdates=ju,i.initializeIssues=zo,i.initializeLicences=Gu,i.initializeOrganizationAccesses=Ku,i.initializeOrganizations=of,i.initializeProjectAccesses=Sa,i.initializeProjectAttachments=vl,i.initializeProjectFiles=Gl,i.initializeProjects=xy,i.initializeTeams=Zl,i.initializeUsers=Nu,i.isToday=Gh,i.issueAssociationReducer=lo,i.issueAssociationSlice=ji,i.issueAttachmentReducer=bo,i.issueAttachmentSlice=zi,i.issueCommentAttachmentReducer=Eo,i.issueCommentAttachmentSlice=Gi,i.issueCommentReducer=ko,i.issueCommentSlice=Li,i.issueReducer=Go,i.issueSlice=Wi,i.issueTypeAttachmentReducer=Xo,i.issueTypeAttachmentSlice=Qi,i.issueTypeFieldValuesAttachmentReducer=Fu,i.issueTypeFieldValuesAttachmentSlice=ca,i.issueTypeFieldValuesReducer=du,i.issueTypeFieldValuesSlice=ea,i.issueTypeFieldsAttachmentReducer=au,i.issueTypeFieldsAttachmentSlice=xi,i.issueTypeFieldsReducer=Au,i.issueTypeFieldsSlice=na,i.issueTypeReducer=wu,i.issueTypeSlice=da,i.issueUpdateReducer=Uu,i.issueUpdateSlice=ha,i.licenseReducer=Lu,i.licenseSlice=ma,i.logOnlyOnce=Kh,i.markAsDeleted=Rl,i.markForDeletion=Rf,i.memoize=zt,i.moveDocument=Lr,i.offline=F,i.onlyUniqueHashes=xh,i.onlyUniqueOfflineIds=tn,i.organizationAccessReducer=Zu,i.organizationAccessSlice=Aa,i.organizationReducer=bl,i.organizationSlice=Ta,i.outboxReducer=Ol,i.outboxSlice=Fa,i.overmapEnhancer=xf,i.overmapReducers=hh,i.overmapRootReducer=Kf,i.performRequest=Ca,i.projectAccessReducer=nl,i.projectAccessSlice=fa,i.projectAttachmentReducer=Ul,i.projectAttachmentSlice=Ia,i.projectFileReducer=Yl,i.projectFileSlice=Pa,i.projectReducer=ll,i.projectSlice=ba,i.rehydratedReducer=Xl,i.rehydratedSlice=_a,i.removeDocuments=ei,i.removeIssueType=oa,i.removeUser=Ju,i.resetProjectFileObjectUrls=jf,i.resetStore=ph,i.restructureCreateSelectorWithArgs=g,i.saveActiveProjectFileBounds=Hl,i.selectAccessToken=$p,i.selectActiveOrganizationAccess=Yy,i.selectActiveProjectFileId=Mf,i.selectActiveStatusLicenses=ky,i.selectAllDocumentAttachments=zr,i.selectAllProjectAttachments=Cl,i.selectAncestorIdsOfDocument=Qp,i.selectAssetAttachmentById=An,i.selectAssetAttachmentMapping=mn,i.selectAssetAttachments=pn,i.selectAssetById=gs,i.selectAssetProcedureAttachmentById=_n,i.selectAssetProcedureAttachmentMapping=Pn,i.selectAssetProcedureAttachments=On,i.selectAssetProcedureById=hs,i.selectAssetProcedureFieldValues=es,i.selectAssetProcedureFieldValuesAttachmentById=Em,i.selectAssetProcedureFieldValuesAttachments=Wn,i.selectAssetProcedureFieldValuesAttachmentsByIds=Kn,i.selectAssetProcedureFieldValuesAttachmentsMapping=Xt,i.selectAssetProcedureFieldValuesById=ts,i.selectAssetProcedureFieldValuesMapping=sc,i.selectAssetProcedureFieldValuesOfAsset=Mm,i.selectAssetProcedureFields=Kt,i.selectAssetProcedureFieldsAttachmentById=ym,i.selectAssetProcedureFieldsAttachments=Cn,i.selectAssetProcedureFieldsAttachmentsMapping=kn,i.selectAssetProcedureFieldsById=Rm,i.selectAssetProcedureFieldsMapping=Ln,i.selectAssetProcedureFieldsOfAssetProcedure=Fm,i.selectAssetProcedureInstanceById=rs,i.selectAssetProcedureInstances=cs,i.selectAssetProcedureInstancesByIds=Vm,i.selectAssetProcedureInstancesMapping=ns,i.selectAssetProcedureInstancesOfAssetProcedure=dc,i.selectAssetProcedureInstancesOfAssetType=Um,i.selectAssetProcedures=hc,i.selectAssetProceduresByIds=Hm,i.selectAssetProceduresMapping=ls,i.selectAssetProceduresOfOrganization=Jm,i.selectAssetStageById=Ec,i.selectAssetStageCompletionById=Rc,i.selectAssetStageCompletionMapping=Ps,i.selectAssetStageCompletions=Zm,i.selectAssetStageCompletionsByIds=Pc,i.selectAssetStages=jc,i.selectAssetStagesByIds=Es,i.selectAssetStagesMappingOfAssetProcedure=sp,i.selectAssetStagesOfAssetProcedure=ip,i.selectAssetTypeAttachmentById=Vc,i.selectAssetTypeAttachmentMapping=Dc,i.selectAssetTypeAttachments=Uc,i.selectAssetTypeById=Ws,i.selectAssetTypeFieldValues=$s,i.selectAssetTypeFieldValuesAttachmentById=_p,i.selectAssetTypeFieldValuesAttachments=cr,i.selectAssetTypeFieldValuesAttachmentsByIds=rr,i.selectAssetTypeFieldValuesAttachmentsMapping=Ds,i.selectAssetTypeFieldValuesById=Ls,i.selectAssetTypeFieldValuesMapping=Ar,i.selectAssetTypeFieldValuesOfAsset=Ep,i.selectAssetTypeFields=rt,i.selectAssetTypeFieldsAttachmentById=mp,i.selectAssetTypeFieldsAttachments=Kc,i.selectAssetTypeFieldsAttachmentsMapping=Wc,i.selectAssetTypeFieldsById=Tp,i.selectAssetTypeFieldsMapping=tr,i.selectAssetTypeFieldsOfAssetType=gp,i.selectAssetTypeValuesOfAssetType=jp,i.selectAssetTypes=Dp,i.selectAssetTypesByIds=Up,i.selectAssetTypesMapping=Hs,i.selectAssets=fc,i.selectAssetsByIds=Xm,i.selectAssetsMapping=fs,i.selectAssetsOfAssetType=Ss,i.selectAttachmentsOfAsset=yn,i.selectAttachmentsOfAssetProcedure=om,i.selectAttachmentsOfAssetProcedureFieldValues=Yn,i.selectAttachmentsOfAssetProcedureFields=Am,i.selectAttachmentsOfAssetType=Gc,i.selectAttachmentsOfAssetTypeFieldValues=dr,i.selectAttachmentsOfAssetTypeFields=hp,i.selectAttachmentsOfDocument=Yp,i.selectAttachmentsOfFormRevision=rA,i.selectAttachmentsOfFormSubmission=_d,i.selectAttachmentsOfIssue=So,i.selectAttachmentsOfIssueComment=JA,i.selectAttachmentsOfIssueType=xA,i.selectAttachmentsOfIssueTypeFieldValues=Tu,i.selectAttachmentsOfIssueTypeFields=ny,i.selectAttachmentsOfProject=Dl,i.selectCategories=Bp,i.selectCategoriesByIds=Np,i.selectCategoryById=Qs,i.selectCategoryMapping=Xs,i.selectCommentsOfIssue=KA,i.selectConversation=sm,i.selectConversationMapping=Gt,i.selectConversations=tm,i.selectCurrentUser=Rt,i.selectDeletedRequests=Ff,i.selectDocumentAttachmentById=Dr,i.selectDocumentAttachmentMapping=Cr,i.selectDocumentById=Nr,i.selectDocuments=Br,i.selectDocumentsByIds=Xp,i.selectDocumentsMapping=qe,i.selectEmailDomains=Xr,i.selectEmailDomainsAsMapping=Yr,i.selectEmailDomainsOfOrganization=eA,i.selectFieldValuesOfAssetProcedureInstance=km,i.selectFormById=Fd,i.selectFormMapping=Td,i.selectFormRevisionAttachmentsMapping=dd,i.selectFormRevisionById=oA,i.selectFormRevisionMapping=ht,i.selectFormRevisions=Ad,i.selectFormRevisionsOfForm=yd,i.selectFormSubmissionAttachemntsByIds=Od,i.selectFormSubmissionAttachmentsMapping=li,i.selectFormSubmissionById=fi,i.selectFormSubmissions=yi,i.selectFormSubmissionsMapping=Ai,i.selectFormSubmissionsOfAsset=kd,i.selectFormSubmissionsOfForm=qd,i.selectFormSubmissionsOfIssue=Md,i.selectForms=pA,i.selectGeoImageById=bi,i.selectGeoImageMapping=Bd,i.selectGeoImages=Nd,i.selectGeoImagesOfProject=IA,i.selectGeoJsonFeatureById=Pi,i.selectGeoJsonFeatures=Xd,i.selectGeoJsonFeaturesByIds=_A,i.selectGeoJsonFeaturesMapping=Ri,i.selectGeoJsonFeaturesOfLayer=Qd,i.selectGeoJsonLayerById=Ei,i.selectGeoJsonLayers=to,i.selectGeoJsonLayersByIds=kA,i.selectGeoJsonLayersMapping=wi,i.selectGeoJsonLayersOfProject=MA,i.selectIsImportingProjectFile=kf,i.selectIsLoggedIn=Lp,i.selectIssueAssociationById=co,i.selectIssueAssociationMapping=Xe,i.selectIssueAssociations=UA,i.selectIssueAssociationsOfAsset=uo,i.selectIssueAssociationsOfIssue=oo,i.selectIssueAssociationsToIssue=ro,i.selectIssueAttachmentById=go,i.selectIssueAttachmentMapping=yo,i.selectIssueAttachments=fo,i.selectIssueById=Xi,i.selectIssueCommentAttachmentById=wo,i.selectIssueCommentAttachmentMapping=_o,i.selectIssueCommentAttachments=vo,i.selectIssueCommentById=Hi,i.selectIssueCommentMapping=Mo,i.selectIssueCountOfCategory=Jp,i.selectIssueMapping=Vo,i.selectIssueTypeAttachmentById=Yo,i.selectIssueTypeAttachmentMapping=Wo,i.selectIssueTypeAttachments=Ko,i.selectIssueTypeById=ua,i.selectIssueTypeFieldValues=ia,i.selectIssueTypeFieldValuesAttachmentById=_y,i.selectIssueTypeFieldValuesAttachments=gu,i.selectIssueTypeFieldValuesAttachmentsByIds=bu,i.selectIssueTypeFieldValuesAttachmentsMapping=ra,i.selectIssueTypeFieldValuesById=aa,i.selectIssueTypeFieldValuesMapping=ru,i.selectIssueTypeFieldValuesOfIssue=hy,i.selectIssueTypeFields=gt,i.selectIssueTypeFieldsAttachmentById=cy,i.selectIssueTypeFieldsAttachments=iu,i.selectIssueTypeFieldsAttachmentsMapping=su,i.selectIssueTypeFieldsById=Ty,i.selectIssueTypeFieldsMapping=pu,i.selectIssueTypeFieldsOfIssueType=Sy,i.selectIssueTypeMapping=_u,i.selectIssueTypeValuesOfIssueType=by,i.selectIssueTypes=vu,i.selectIssueTypesByIds=vy,i.selectIssueTypesOfOrganization=wy,i.selectIssueUpdateMapping=zu,i.selectIssueUpdatesOfIssue=Du,i.selectIssuesByIds=YA,i.selectIssuesOfIssueType=la,i.selectIssuesOfIssueTypeCount=Ey,i.selectLatestAssetProcedureFieldsOfAssetProcedure=Im,i.selectLatestAssetTypeFieldsOfAssetType=bp,i.selectLatestFormRevisionOfForm=uA,i.selectLatestIssueTypeFieldsOfIssueType=gy,i.selectLatestRetryTime=If,i.selectLicense=My,i.selectLicenseForProject=$u,i.selectLicenses=It,i.selectLicensesForProjectsMapping=Cy,i.selectLicensesOfOrganization=bf,i.selectNumberOfAssetsOfAssetType=Qm,i.selectOrganizationAccessById=Ky,i.selectOrganizationAccessForUser=Xy,i.selectOrganizationAccessUserMapping=Qu,i.selectOrganizationAccesses=ya,i.selectOrganizationById=ff,i.selectOrganizationUsersAsMapping=gl,i.selectOrganizationUsersIds=Sl,i.selectOrganizations=fl,i.selectOrganizationsMapping=yl,i.selectOrganizationsWithAccess=Sf,i.selectProjectAccessById=Qy,i.selectProjectAccessForUser=Zy,i.selectProjectAccessMapping=ga,i.selectProjectAccessUserMapping=al,i.selectProjectAccesses=il,i.selectProjectAttachmentById=zl,i.selectProjectAttachmentMapping=kl,i.selectProjectById=rf,i.selectProjectFileById=qf,i.selectProjectFileMapping=Wl,i.selectProjectFiles=Kl,i.selectProjectMapping=_t,i.selectProjectUsersAsMapping=ml,i.selectProjectUsersIds=hl,i.selectProjects=cf,i.selectProjectsOfOrganization=gf,i.selectRehydrated=Df,i.selectRootDocuments=Zp,i.selectSortedOrganizationUsers=Tf,i.selectSortedProjectUsers=df,i.selectStageMapping=ct,i.selectTeamById=ze,i.selectTeams=qa,i.selectTeamsByIds=Uf,i.selectTeamsMapping=ja,i.selectTeamsOfOrganization=Vf,i.selectTeamsOfUser=Gf,i.selectUploadUrl=td,i.selectUserById=Hy,i.selectUsersByIds=Wy,i.selectUsersMapping=Pt,i.setActiveProjectFileId=Jl,i.setAsset=Km,i.setAssetAttachment=un,i.setAssetAttachments=am,i.setAssetProcedure=Bm,i.setAssetProcedureAttachment=Tn,i.setAssetProcedureAttachments=rm,i.setAssetProcedureFieldValues=jm,i.setAssetProcedureFieldValuesAttachment=Om,i.setAssetProcedureFieldValuesAttachments=_m,i.setAssetProcedureFieldValuesMany=qm,i.setAssetProcedureFields=Sm,i.setAssetProcedureFieldsAttachment=lm,i.setAssetProcedureFieldsAttachments=hm,i.setAssetProcedureFieldsMany=gm,i.setAssetProcedureInstance=zm,i.setAssetProcedureInstances=Dm,i.setAssetProcedures=Nm,i.setAssetStage=vc,i.setAssetStages=xm,i.setAssetType=qp,i.setAssetTypeAttachment=kc,i.setAssetTypeAttachments=np,i.setAssetTypeFieldValues=vp,i.setAssetTypeFieldValuesAttachment=Ip,i.setAssetTypeFieldValuesAttachments=Rp,i.setAssetTypeFieldValuesMany=wp,i.setAssetTypeFields=Ap,i.setAssetTypeFieldsAttachment=dp,i.setAssetTypeFieldsAttachments=op,i.setAssetTypeFieldsMany=yp,i.setAssetTypes=Mp,i.setAssets=Ym,i.setConversation=cn,i.setCurrentUser=Ny,i.setDocumentAttachment=jr,i.setDocumentAttachments=Wp,i.setDocuments=Gr,i.setForm=lA,i.setFormRevision=ld,i.setFormRevisionAttachment=iA,i.setFormRevisionAttachments=aA,i.setFormSubmission=At,i.setFormSubmissionAttachment=yA,i.setFormSubmissionAttachments=fA,i.setFormSubmissions=bA,i.setGeoImage=We,i.setGeoImages=Ud,i.setGeoJsonFeature=PA,i.setGeoJsonFeatures=OA,i.setGeoJsonLayer=jA,i.setGeoJsonLayers=qA,i.setIsImportingProjectFile=Nl,i.setIssueAssociation=zA,i.setIssueAssociations=CA,i.setIssueAttachment=mo,i.setIssueAttachments=GA,i.setIssueComment=Bi,i.setIssueCommentAttachment=Io,i.setIssueCommentAttachments=BA,i.setIssueComments=qo,i.setIssueType=Ze,i.setIssueTypeAttachment=Bo,i.setIssueTypeAttachments=QA,i.setIssueTypeFieldValues=dy,i.setIssueTypeFieldValuesAttachment=Iy,i.setIssueTypeFieldValuesAttachments=Ry,i.setIssueTypeFieldValuesMany=oy,i.setIssueTypeFields=py,i.setIssueTypeFieldsAttachment=ty,i.setIssueTypeFieldsAttachments=sy,i.setIssueTypeFieldsMany=Ay,i.setIssueUpdate=jy,i.setLoggedIn=Tr,i.setOrganization=uf,i.setOrganizations=Al,i.setProfilePicture=Jy,i.setProject=ef,i.setProjectAttachment=El,i.setProjectAttachments=jl,i.setProjectFile=_f,i.setProjectFiles=vf,i.setProjects=rl,i.setRehydrated=zf,i.setTeam=Ce,i.setTokens=Vp,i.setUploadUrl=ed,i.setUser=Dy,i.setUsers=zy,i.shallowEqual=zh,i.slugify=Qh,i.spacesToDashesLower=Xh,i.teamReducer=eh,i.teamSlice=va,i.toFileNameSafeString=Yh,i.toOfflineIdRecord=en,i.truncate=Zh,i.updateAsset=Be,i.updateAssetAttachment=nm,i.updateAssetAttachments=ln,i.updateAssetProcedure=Le,i.updateAssetProcedureAttachment=dm,i.updateAssetProcedureAttachments=Fn,i.updateAssetProcedureFieldValues=Ge,i.updateAssetProcedureFieldValuesAttachment=vm,i.updateAssetProcedureFieldValuesAttachments=Hn,i.updateAssetProcedureFieldValuesMany=ec,i.updateAssetProcedureFields=Gn,i.updateAssetProcedureFieldsAttachment=mm,i.updateAssetProcedureFieldsAttachments=qn,i.updateAssetProcedureFieldsMany=bm,i.updateAssetProcedureInstance=$e,i.updateAssetProcedureInstances=Cm,i.updateAssetProcedures=$m,i.updateAssetStage=vs,i.updateAssetStageCompletion=Tc,i.updateAssetStageCompletions=Fc,i.updateAssetStages=nt,i.updateAssetType=Je,i.updateAssetTypeAttachment=cp,i.updateAssetTypeAttachments=Cc,i.updateAssetTypeFieldValues=Ne,i.updateAssetTypeFieldValuesAttachment=Pp,i.updateAssetTypeFieldValuesAttachments=nr,i.updateAssetTypeFieldValuesMany=mr,i.updateAssetTypeFields=xc,i.updateAssetTypeFieldsAttachment=up,i.updateAssetTypeFieldsAttachments=Jc,i.updateAssetTypeFieldsMany=fp,i.updateAssetTypes=Cp,i.updateAssets=Wm,i.updateCategory=Pr,i.updateConversation=rn,i.updateDocumentAttachment=Kp,i.updateDocumentAttachments=qr,i.updateDocuments=ge,i.updateForm=mA,i.updateFormRevisionAttachment=nA,i.updateFormRevisionAttachments=cd,i.updateFormSubmission=jd,i.updateFormSubmissionAttachment=SA,i.updateFormSubmissionAttachments=Pd,i.updateFormSubmissions=TA,i.updateGeoImage=$d,i.updateGeoImages=FA,i.updateGeoJsonFeature=Ke,i.updateGeoJsonFeatures=RA,i.updateGeoJsonLayer=Ye,i.updateGeoJsonLayers=wA,i.updateIssue=St,i.updateIssueAssociation=no,i.updateIssueAssociations=DA,i.updateIssueAttachment=$A,i.updateIssueAttachments=po,i.updateIssueCommentAttachment=NA,i.updateIssueCommentAttachments=Ro,i.updateIssueType=Ou,i.updateIssueTypeAttachment=ZA,i.updateIssueTypeAttachments=No,i.updateIssueTypeFieldValues=Qe,i.updateIssueTypeFieldValuesAttachment=Py,i.updateIssueTypeFieldValuesAttachments=Su,i.updateIssueTypeFieldValuesMany=uy,i.updateIssueTypeFields=hu,i.updateIssueTypeFieldsAttachment=iy,i.updateIssueTypeFieldsAttachments=eu,i.updateIssueTypeFieldsMany=yy,i.updateLicense=fe,i.updateOrganization=pf,i.updateOrganizationAccess=Yu,i.updateOrganizations=mf,i.updateProject=dl,i.updateProjectAccess=el,i.updateProjectAttachment=Of,i.updateProjectAttachments=ql,i.updateProjectFile=Oa,i.updateProjectFiles=Ef,i.updateProjects=af,i.updateTeam=wa,i.updateUser=$y,i.updateUsers=Gy,i.userReducer=Hu,i.userSlice=pa,i.versioningReducer=sh,i.versioningSlice=th,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
14
+ external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(y)}const m=d.type.split("/")[1];if(!m)throw new Error("File has no extension");const A=n??u+"."+m;if(d=Xa(d,A),!d.name)throw new Error("Failed to set file's name");await this.addCache(d,u),vt[c]=new Promise(y=>{y(d)})}return d}}class kS extends E{async bulkAdd(e){var p;const s=new Date().toISOString(),a=(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,n={},c=[],r=[];for(const d of e){const{revisionUuid:u,fieldIdentifier:m,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,form_revision:u,submitted_at:s,field_identifier:m});c.push(b);const I={uuid:b.uuid,file_name:A.name,field_identifier:m,file_extension:y.extension,file_sha1:y.sha1,form_revision:u};r.push(I)}this.dispatch(nd(c));const o=this.enqueueRequest({description:"Attach files to form revision",method:h.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.form_revision),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(cd(d.attachments))}).catch(()=>{this.dispatch(rd(c.map(d=>d.uuid)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:h.GET,url:"/form-revision-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(ad(s))}}class DS extends E{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=F({...e,created_by:n,submitted_at:new Date().toISOString()});this.dispatch(ni(c));const r=this.enqueueRequest({description:"Create form revision",method:h.POST,url:"/form-revisions/",payload:O(c),blockers:[e.form],blocks:[c.uuid]});return r.then(p=>{this.dispatch(ld(p))}).catch(()=>{this.dispatch(ci(c.uuid))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:h.GET,url:"/form-revisions/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(hd(s))}}class US extends E{add(e,s){var d;const{store:a}=this.client,n=new Date().toISOString(),c=(d=a.getState().userReducer.currentUser)==null?void 0:d.id,r=F({...e,submitted_at:n,created_by:c}),o=F({...s,form:r.uuid,submitted_at:n,created_by:c});this.dispatch(di(r)),this.dispatch(ni(o));const p=this.enqueueRequest({description:"Create form",method:h.POST,url:"/forms/",payload:{...O(r),initial_revision:{uuid:o.uuid,submitted_at:o.submitted_at,title:o.title,description:o.description,fields:o.fields}},blockers:[],blocks:[r.uuid,o.uuid]});return p.catch(u=>{throw this.dispatch(oi(r.uuid)),this.dispatch(ci(o.uuid)),u}),[r,o,p]}async delete(e){const{store:s}=this.client,a=s.getState(),n=Fd(e)(a);if(!n)throw new Error("Expected form to exist");const c=qd(e)(a);c.length>0&&this.dispatch(ft(c.map(({uuid:o})=>o)));const r=yd(e)(a);r.length>0&&this.dispatch(pd(r.map(({uuid:o})=>o))),this.dispatch(oi(e));try{return await this.enqueueRequest({description:"Delete form",method:h.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(di(n)),r.length>0&&this.dispatch(md(r)),c.length>0&&this.dispatch(yt(c)),o}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:h.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(gd(s))}}class VS extends E{async bulkAdd(e){var p;const s=new Date().toISOString(),a=(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,n={},c=[],r=[];for(const d of e){const{submissionUuid:u,fieldIdentifier:m,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,form_submission:u,submitted_at:s,field_identifier:m});c.push(b);const I={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:m,form_submission:u};r.push(I)}this.dispatch(mt(c));const o=this.enqueueRequest({description:"Attach files to form submission",method:h.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.form_submission),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Pd(d.attachments))}).catch(d=>{throw this.dispatch(pt(c.map(u=>u.uuid))),d}),[c,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,a=s.getState(),n=Od(e)(a);this.dispatch(pt(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:h.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(mt(n)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:h.GET,url:"/form-submission-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Rd(s))}}class GS extends E{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,created_by:(r=a.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:h.POST,url:"/form-submissions/",payload:O(n),blockers:["add-form-entry",e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[n.uuid]});return this.dispatch(mi(n)),c.then(o=>(this.dispatch(At(o)),o)).catch(()=>{this.dispatch(pi(n.uuid))}),[n,c]}update(e){const{store:s}=this.client,a=s.getState(),n=fi(e.uuid)(a);if(!n)throw new Error(`Expected submission with uuid ${e.uuid} to exist`);const c={...n,...e};this.dispatch(jd(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:h.PATCH,url:`/form-submissions/${c.uuid}/`,payload:e,blockers:[c.uuid],blocks:[c.uuid]});return r.then(o=>{this.dispatch(At(o))}).catch(()=>{this.dispatch(At(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=fi(e)(a);if(!n)throw new Error(`Expected submission with uuid ${e} to exist`);const c=_d(e)(a);this.dispatch(pi(e)),this.dispatch(pt(c.map(r=>r.uuid)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:h.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(mi(n)),this.dispatch(mt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:h.GET,url:"/form-submissions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ed(s))}}class $S extends E{async add(e){var m;const{store:s}=this.client,{file:a,...n}=e,c=new Date().toISOString(),r=(m=s.getState().userReducer.currentUser)==null?void 0:m.id,o=n.project,p=await this.getFilePayload(a),d=F({...n,file_name:a.name,file_sha1:p.sha1,file:URL.createObjectURL(a),submitted_at:c,created_by:r});this.dispatch(Vd(d));const u=this.enqueueRequest({description:"Add geo image",method:h.POST,url:"/geo-images/",payload:{uuid:d.uuid,submitted_at:c,title:d.title,description:d.description,geo_marker:d.geo_marker,canvas_marker:d.canvas_marker,sha1:d.file_sha1,project:d.project,file_name:d.file_name,direction:d.direction,original_date:d.original_date,file:p},blocks:[o],blockers:[o]});return u.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(We(A.geo_image))}).catch(()=>{this.dispatch(gi(d.uuid))}),[d,u.then(A=>A.geo_image)]}async bulkAdd(e,s){var m;const{store:a}=this.client,n=new Date().toISOString(),c=(m=a.getState().userReducer.currentUser)==null?void 0:m.id,r=[],o=[],p=[],d={};for(const A of e){const{file:y,...b}=A,I=await this.getFilePayload(y);I.sha1 in d||(d[I.sha1]=I);const R=F({...b,file_name:y.name,file_sha1:I.sha1,file:URL.createObjectURL(y),submitted_at:n,created_by:c,project:s});r.push(R),o.push(R.uuid),p.push({uuid:R.uuid,sha1:R.file_sha1,file_name:R.file_name,title:R.title,description:R.description,geo_marker:R.geo_marker,canvas_marker:R.canvas_marker,direction:R.direction,original_date:R.original_date})}this.dispatch(Gd(r));const u=this.enqueueRequest({description:"Bulk add geo images",method:h.POST,url:"/geo-images/bulk/",payload:{submitted_at:n,project:s,geo_images:p,files:Object.values(d)},blocks:[s],blockers:o});return u.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(Ud(A.geo_images))}).catch(()=>{this.dispatch(Ld(o))}),[r,u.then(A=>A.geo_images)]}update(e){const{store:s}=this.client,a=s.getState(),n=bi(e.uuid)(a);if(!n)throw new Error(`Map image with uuid ${e.uuid} does not exist in the store`);const c={...n,...e};this.dispatch($d(c));const r=this.enqueueRequest({description:"Update geo image",method:h.PATCH,url:`/geo-images/${e.uuid}/`,payload:e,blocks:[e.uuid],blockers:[e.uuid]});return r.then(o=>{this.dispatch(We(o))}).catch(()=>{this.dispatch(We(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=bi(e)(a);if(!n)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(gi(e));const c=this.enqueueRequest({description:"Delete geo image",method:h.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(We(n))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:h.GET,url:"/geo-images/",queryParams:{project:e},blocks:[e],blockers:[]});this.dispatch(Dd(s))}}class LS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(Fi(c));const r=this.enqueueRequest({description:"Create GeoJSON feature",method:h.POST,url:"/geojson-features/",payload:O(c),blockers:[c.geojson_layer],blocks:[c.uuid]});return r.then(p=>{this.dispatch(Ke(p))}).catch(()=>{this.dispatch(Ii(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=Pi(e.uuid)(s.getState());if(!a)throw new Error(`No GeoJSON feature with uuid ${e.uuid} found in the store`);const n={...a,...e};this.dispatch(Ke(n));const c=this.enqueueRequest({description:"Edit GeoJSON feature",method:h.PATCH,url:`/geojson-features/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(Ke(r))}).catch(()=>{this.dispatch(Ke(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=Pi(e)(a);if(!n)throw new Error(`No GeoJSON feature with uuid ${e} found in the store`);return this.dispatch(Ii(e)),this.enqueueRequest({description:"Delete GeoJSON feature",method:h.DELETE,url:`/geojson-features/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Fi(n)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get GeoJSON features",method:h.GET,url:"/geojson-features/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Wd(s))}}class BS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(_i(c));const r=this.enqueueRequest({description:"Create GeoJSON layer",method:h.POST,url:"/geojson-layers/",payload:O(c),blockers:[c.project],blocks:[c.uuid]});return r.then(p=>{this.dispatch(Ye(p))}).catch(()=>{this.dispatch(vi(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,a=Ei(e.uuid)(s.getState());if(!a)throw new Error(`No GeoJSON layer with uuid ${e.uuid} found in the store`);const n={...a,...e};this.dispatch(Ye(n));const c=this.enqueueRequest({description:"Edit GeoJSON layer",method:h.PATCH,url:`/geojson-layers/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(Ye(r))}).catch(()=>{this.dispatch(Ye(a))}),[n,c]}async remove(e){const{store:s}=this.client,a=s.getState(),n=Ei(e)(a);if(!n)throw new Error(`No GeoJSON layer with uuid ${e} found in the store`);const c=Qd(e)(a);if(this.dispatch(vi(e)),c.length>0){const r=c.map(({uuid:o})=>o);this.dispatch(Yd(r))}return this.enqueueRequest({description:"Delete GeoJSON layer",method:h.DELETE,url:`/geojson-layers/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(_i(n)),this.dispatch(Kd(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get GeoJSON layers",method:h.GET,url:"/geojson-layers/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(eo(s))}}class NS extends P{add(e){var o;const{store:s}=this.client,a=new Date().toISOString(),n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=F({...e,submitted_at:a,created_by:n});this.dispatch(qi(c));const r=this.enqueueRequest({description:"Add issue association",method:h.POST,url:"/issue-associations/",payload:O(c),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.uuid]});return r.then(p=>{this.dispatch(no(p))}).catch(()=>{this.dispatch(Ci(c.uuid))}),[c,r]}async delete(e){const{store:s}=this.client,a=co(e)(s.getState());if(!a)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(Ci(e));const n=this.enqueueRequest({description:"Delete issue association",method:h.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(qi(a))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:h.GET,url:"/issue-associations/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ao(s))}}class JS extends be{constructor(){super(...arguments);f(this,"name","Issue Attachment");f(this,"url","/issue-attachments");f(this,"initializeAttachments",Di);f(this,"addAttachments",Ui);f(this,"updateAttachments",po);f(this,"removeAttachments",Vi);f(this,"removeAttachment",Ao);f(this,"setAttachment",mo);f(this,"selectAttachment",go)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.issueUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get issue attachments",method:h.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Di(a))}}class HS extends be{constructor(){super(...arguments);f(this,"name","Issue Comment Attachment");f(this,"url","/issue-comment-attachments");f(this,"initializeAttachments",$i);f(this,"addAttachments",Fo);f(this,"updateAttachments",Ro);f(this,"removeAttachments",Oo);f(this,"removeAttachment",Po);f(this,"setAttachment",Io);f(this,"selectAttachment",wo)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_comment:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue_comment:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.issueCommentUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get issue comment attachments",method:h.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch($i(a))}}class WS extends P{add(e){var c;const{store:s}=this.client,a=F({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Ni(a));const n=this.enqueueRequest({description:"Add issue comment",method:h.POST,url:"/issue-comments/",payload:O(a),blockers:[e.issue],blocks:[a.uuid]});return n.catch(()=>{this.dispatch(Ji(a.uuid))}),[a,n]}update(e){const{store:s}=this.client,a=Hi(e.uuid)(s.getState());if(!a)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const n={...a,...e};this.dispatch(Bi(n));const c=this.enqueueRequest({description:"Edit issue comment",method:h.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.catch(()=>{this.dispatch(Bi(a))}),[n,c]}remove(e){const{store:s}=this.client,a=Hi(e)(s.getState());if(!a)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(Ji(e));const n=this.enqueueRequest({description:"Delete comment",method:h.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Ni(a))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:h.GET,url:"/issue-comments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(qo(s))}}class KS extends P{add(e){var p;const{store:s}=this.client,a=s.getState(),n=new Date().toISOString(),c=(p=a.userReducer.currentUser)==null?void 0:p.id,r=F({...e,submitted_at:n,created_by:c});this.dispatch(Ki(r));const o=this.enqueueRequest({description:"Create issue",method:h.POST,url:"/issues/",payload:O(r),blockers:["add-issue",r.project,r.issue_type,...r.category?[r.category]:[]],blocks:[r.uuid]});return o.then(d=>{this.dispatch(St(d))}).catch(d=>{throw this.dispatch(Yi(r.uuid)),d}),[r,o]}update(e){var p;const s=this.client.store.getState(),a=Xi(e.uuid)(s);if(!a)throw new Error(`Attempting to update an issue with uuid ${e.uuid} that doesn't exist in the store`);const n={...a,...e};this.dispatch(St(n));const c={};for(const d of[v.TITLE,v.DESCRIPTION,v.STATUS,v.CATEGORY,v.PRIORITY,v.ASSIGNED_TO,v.DUE_DATE])if(d in e&&e[d]!==a[d])switch(d){case v.PRIORITY:case v.STATUS:{const u=e[d];c[d]=u!==void 0?Number(u):null;break}case v.DUE_DATE:case v.DESCRIPTION:case v.TITLE:c[d]=e[d]??null;break;case v.CATEGORY:{let u=null;const m=e[d];if(m&&(u=s.categoryReducer.instances[m]??null,!u))throw new Error(`Trying to update issue category to ${m} which does not exist in store`);c[d]=u?{name:u.name,color:u.color,uuid:u.uuid}:null;break}case v.ASSIGNED_TO:{let u=null;const m=e[d];if(m&&(u=s.userReducer.instances[m]??null,!u))throw new Error(`Trying to update issue assigned_to to ${m} which does not exist in store`);c[d]=u?{full_name:u.username,id:u.id}:null;break}}const r=F({created_by:(p=s.userReducer.currentUser)==null?void 0:p.id,submitted_at:new Date().toISOString(),issue:a.uuid,changes:c});this.dispatch(qu(r));const o=this.enqueueRequest({description:"Edit issue",method:h.PATCH,url:`/issues/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return o.catch(()=>{this.dispatch(St(a)),this.dispatch(Cu(r.uuid))}),[n,o]}async remove(e){const{store:s}=this.client,a=s.getState(),n=Xi(e)(a);if(!n)throw new Error(`No issue with uuid ${e} found in the store`);const c=So(e)(a),r=Du(e)(a),o=Md(e)(a),p={};for(const u of ro(e)(a))p[u.uuid]=u;for(const u of oo(e)(a))p[u.uuid]=u;const d=Object.values(p);this.dispatch(Yi(e)),c.length>0&&this.dispatch(Vi(c.map(({uuid:u})=>u))),r.length>0&&this.dispatch(zu(r.map(({uuid:u})=>u))),o.length>0&&this.dispatch(ft(o.map(({uuid:u})=>u))),d.length>0&&this.dispatch(zi(d.map(({uuid:u})=>u)));try{return await this.enqueueRequest({description:"Delete issue",method:h.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(u){throw this.dispatch(Ki(n)),this.dispatch(Ui(c)),this.dispatch(Mu(r)),this.dispatch(yt(o)),this.dispatch(Mi(d)),u}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:h.GET,url:"/issues/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ko(s))}}class YS extends be{constructor(){super(...arguments);f(this,"name","Issue Type Attachment");f(this,"url","/issue-type-attachments");f(this,"initializeAttachments",Zi);f(this,"addAttachments",Lo);f(this,"updateAttachments",No);f(this,"removeAttachments",Ho);f(this,"removeAttachment",Jo);f(this,"setAttachment",Bo);f(this,"selectAttachment",Yo)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_type:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue_type:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.issueTypeUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get issue type attachments",method:h.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(Zi(a))}}class XS extends E{async bulkAdd(e){var p;const s=new Date().toISOString(),a=(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,n={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:u,fieldIdentifier:m,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,fields_revision:u,submitted_at:s,field_identifier:m});c.push(b);const I={uuid:b.uuid,file_name:A.name,file_extension:y.extension,field_identifier:m,file_sha1:y.sha1,fields_revision:u};r.push(I)}this.dispatch(xo(c));const o=this.enqueueRequest({description:"Add issue type fields attachments",method:h.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(eu(d.attachments))}).catch(()=>{this.dispatch(tu(c.map(d=>d.uuid)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:h.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Zo(s))}}class QS extends P{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=new Date().toISOString(),c=F({...e,created_by:a,submitted_at:n});this.dispatch(lu(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:h.POST,url:"/issue-type-fields/",payload:O(c),blockers:[c.issue_type],blocks:[c.uuid]});return r.then(p=>{this.dispatch(hu(p))}).catch(p=>{throw this.dispatch(mu(c.uuid)),p}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:h.GET,url:"/issue-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(uu(s))}}class ZS extends E{async bulkAdd(e){var p;const s=new Date().toISOString(),a=(p=this.client.store.getState().userReducer.currentUser)==null?void 0:p.id,n={},c=[],r=[];for(const d of e){const{fieldValuesUuid:u,fieldIdentifier:m,file:A}=d,y=await this.getFilePayload(A);y.sha1 in n||(n[y.sha1]=y);const b=F({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:a,field_values:u,submitted_at:s,field_identifier:m});c.push(b);const I={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:m,field_values:u};r.push(I)}this.dispatch(bt(c));const o=this.enqueueRequest({description:"Add issue type field values attachments",method:h.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(n)},blockers:c.map(d=>d.field_values),blocks:c.map(d=>d.uuid)});return o.then(({presigned_urls:d,attachments:u})=>{this.processPresignedUrls(d),this.dispatch(Su(u))}).catch(d=>{throw this.dispatch(Tt(c.map(u=>u.uuid))),d}),[c,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,a=s.getState(),n=bu(e)(a);this.dispatch(Tt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:h.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(bt(n)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values attachments",method:h.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(fu(s))}}class xS extends P{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,created_by:(r=a.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:h.POST,url:"/issue-type-field-values/",payload:O(n),blockers:[e.issue,e.fields_revision],blocks:[n.uuid]});return this.dispatch(ta(n)),c.then(o=>(this.dispatch(Qe(o)),o)).catch(()=>{this.dispatch(sa(n.uuid))}),[n,c]}update(e){const{store:s}=this.client,a=s.getState(),n=aa(e.uuid)(a);if(!n)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const c={...n,...e};this.dispatch(Qe(c));const r=this.enqueueRequest({description:"Update issue type field values",method:h.PATCH,url:`/issue-type-field-values/${e.uuid}/`,payload:e,blockers:[c.uuid,c.fields_revision,c.issue],blocks:[c.uuid]});return r.then(o=>{this.dispatch(Qe(o))}).catch(()=>{this.dispatch(Qe(n))}),[c,r]}async delete(e){const{store:s}=this.client,a=s.getState(),n=aa(e)(a);if(!n)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Tu(e)(a);this.dispatch(sa(e)),this.dispatch(Tt(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete issue type field values",method:h.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ta(n)),this.dispatch(bt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:h.GET,url:"/issue-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(cu(s))}}class eg extends P{add(e){var r;const{store:s}=this.client,a=s.getState(),n=F({...e,submitted_at:new Date().toISOString(),created_by:(r=a.userReducer.currentUser)==null?void 0:r.id});this.dispatch(Pu(n));const c=this.enqueueRequest({method:h.POST,url:"/issue-types/",payload:O(n),blockers:[],blocks:[n.uuid]});return c.then(o=>{this.dispatch(Ze(o))}).catch(()=>{this.dispatch(oa(n.uuid))}),[n,c]}update(e){const{store:s}=this.client,a=s.getState(),n=ua(e.uuid)(a);if(!n)throw new Error(`IssueType with uuid ${e.uuid} does not exist in the store.`);const c={...n,...e};this.dispatch(Ou(c));const r=this.enqueueRequest({method:h.PATCH,url:`/issue-types/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return r.then(o=>{this.dispatch(Ze(o))}).catch(()=>{this.dispatch(Ze(n))}),[c,r]}delete(e){const{store:s}=this.client,a=s.getState(),n=ua(e)(a);if(!n)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const c=la(e)(a);this.dispatch(oa(e)),this.dispatch(Uo(c.map(o=>o.uuid)));const r=this.enqueueRequest({method:h.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(Ze(n)),this.dispatch(Do(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:h.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Ru(s))}}class tg extends P{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:h.GET,url:"/issue-updates/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ju(s))}}const sg=1800;function ig(t){if(!t.access)throw new Error("Missing access token");if(!t.refresh)throw new Error("Missing refresh token");return{accessToken:t.access,refreshToken:t.refresh}}class ag extends uS{constructor(){super(...arguments);f(this,"_getRenewedTokens",async s=>{const a=this.enqueueRequest({description:"Get renewed tokens",method:h.POST,url:this.refreshTokensUrl,payload:{refresh:s},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let n;try{n=await a}catch(c){console.error("Could not renew tokens; clearing auth",c),this.clearAuth();return}if(!n.access)throw new Error("Missing access token");return{accessToken:n.access,refreshToken:n.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Tr(!1)),this.clearTokens(),this.dispatch({type:_h.RESET_STATE}),this.dispatch({type:ph})}async renewTokens(){const s=this.getRefreshToken();if(!s)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const a=await this._getRenewedTokens(s);if(!a)return;console.log("Got renewed tokens"),this.setTokens(a)}catch(a){throw console.error("Could not renew tokens; clearing auth",a),this.clearAuth(),a}}tokenIsExpiringSoon(){const s=this.getAccessToken();if(!s)return!1;const a=Date.now()/1e3;let n;try{n=vh(s).exp??a}catch{n=a}return n-a<sg}getAuthHeader(){return`Bearer ${this.getAccessToken()}`}async prepareAuth(){if(this.tokenIsExpiringSoon()){console.debug(this.constructor.name,"preparing auth");try{await this.renewTokens()}catch(s){return s instanceof q&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??De).toString()))}}}async handleUnauthorized(s,a){const n=this.client.store.getState();if(s.url.endsWith("/token/refresh/"))throw n.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new q({message:"You have been signed out due to inactivity.",response:a,discard:!0});if(n.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new q({message:"Incorrect username or password.",response:a,discard:!0})}async initAuth(s){const a=Te.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:a,description:"Get token pair",method:h.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(n=>{this.setTokens(ig(n))})}}class ng extends P{async getLicense(e){const s=await this.enqueueRequest({description:"Get license",method:h.GET,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(fe(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:h.DELETE,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(fe(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:h.PATCH,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(fe(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:h.DELETE,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(fe(s)),s}async attachLicenseToProject(e,s){const a=await this.enqueueRequest({description:"Attach license",method:h.PATCH,url:`/billing/${e.uuid}/project/`,isAuthNeeded:!0,payload:{project:s.uuid},blockers:[e.organization_owner,s.uuid],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(fe(a)),a}async detachLicenseFromProject(e){const s=await this.enqueueRequest({description:"Detach license",method:h.DELETE,url:`/billing/${e.uuid}/project/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(fe(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:h.GET,url:`/billing/${e.uuid}/transaction/`,isAuthNeeded:!0,blockers:[e.uuid],blocks:[e.uuid]})}async refreshStore(e,s){const a={},n=await this.enqueueRequest({description:"Get licenses",method:h.GET,url:`/organizations/${s}/licenses/`,isAuthNeeded:!0,blockers:[s],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of n)a[r.uuid]=r;const c=await this.enqueueRequest({description:"Get licenses",method:h.GET,url:`/projects/${e}/licenses/`,isAuthNeeded:!0,blockers:[e],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of c)a[r.uuid]=r;this.dispatch(Gu(Object.values(a)))}}class cg extends P{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:h.PATCH,url:`/organization-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return s.then(()=>{this.dispatch(Yu(e))}),s}async remove(e){return this.dispatch(Xu(e.uuid)),this.dispatch(Ju(e.user)),this.enqueueRequest({description:"Remove organization access",method:h.DELETE,url:`/organization-accesses/${e.uuid}/`,blockers:[e.uuid],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:h.GET,url:"/organization-accesses/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Ku(s))}}class rg extends P{create(e){return this.enqueueRequest({description:"Create organization",method:h.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:h.PATCH,url:`/organizations/${e.uuid}/`,payload:e,blockers:[`add-org-${e.name}`,e.uuid],blocks:[e.uuid]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:h.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const a={},n=await this.enqueueRequest({description:"Get organizations",method:h.GET,url:`/projects/${e}/organizations/`,blockers:[],blocks:[]});for(const r of n)a[r.uuid]=r;const c=await this.enqueueRequest({description:"Get organization",method:h.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});a[c.uuid]=c,this.dispatch(Al(Object.values(a)))}}class dg extends P{async update(e){return this.dispatch(el(e)),this.enqueueRequest({description:"Edit project access",method:h.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid,"change-access-level"],blocks:[e.uuid]})}async remove(e){return this.dispatch(tl(e)),this.enqueueRequest({description:"Delete project access",method:h.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:h.GET,url:"/project-accesses/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Sa(s))}}class og extends be{constructor(){super(...arguments);f(this,"name","Project Attachment");f(this,"url","/project-attachments");f(this,"addAttachments",wl);f(this,"updateAttachments",ql);f(this,"removeAttachments",Ra);f(this,"removeAttachment",Ml);f(this,"setAttachment",El);f(this,"selectAttachment",kl)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,project:s.modelUuid})}buildAttachmentPayload(s){return{...s,project:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(a=>({modelUuid:a.projectUuid,file:a.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const a=await this.enqueueRequest({description:"Get project attachments",method:h.GET,url:`${this.url}/`,queryParams:{project:s},blockers:[],blocks:[]});this.dispatch(vl(a))}}class ug extends P{async saveExisting(e){if(!e.uuid)throw new Error("You can only use this method to save existing project files. The one provided has no uuid.");const s={...e};delete s.file;const a=this.enqueueRequest({method:h.PATCH,url:`/projects/files/${e.uuid}/`,payload:s,blockers:[e.uuid],blocks:[e.uuid]});return a.then(n=>{this.dispatch(Oa(n))}),a}saveActive(){const{store:e}=this.client,s=e.getState(),a=s.projectFileReducer.activeProjectFileId;if(!a)throw new Error("No active project file");const n=s.projectFileReducer.instances[a];if(!n)throw new Error("No active project file");if(!n.bounds&&!n.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let c;if(typeof n.file=="string"&&!n.file.startsWith("blob:")){const p={...n};delete p.file,c={method:h.PATCH,url:`/projects/files/${a}/`,payload:p,blockers:[a],blocks:[a]}}else c=new Promise((p,d)=>{this.client.files.uploadFileToS3(n.file_sha1).then(([u])=>{p({method:h.POST,url:`/projects/${n.project}/files/`,payload:{...n,...u},blockers:[a],blocks:[a]})}).catch(d)});const o=Promise.resolve(c).then(p=>this.enqueueRequest(p));return o.then(p=>{this.dispatch(Oa(p))}),this.dispatch(Hl),this.dispatch(Jl(null)),this.dispatch(Nl(!1)),[n,o]}delete(e){return this.dispatch(Ll(e)),this.enqueueRequest({method:h.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:h.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(Gl(s))}}class lg extends P{async add(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return await this.enqueueRequest({description:"Create project",method:h.POST,url:"/projects/",payload:{name:e.name,bounds:e.bounds,organization_owner:e.organization_owner},blockers:[],blocks:[]})}async update(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return this.dispatch(dl(e)),await this.enqueueRequest({description:"Update project",method:h.PATCH,url:`/projects/${e.uuid}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.uuid],blocks:[e.uuid]})}async delete(e){const{store:s}=this.client,a=s.getState(),n=_t(a),c=n[e];if(!c)throw new Error("Expected project to exist");const r=Kl(a).filter(u=>u.project===e);this.dispatch(Bl(r.map(({uuid:u})=>u)));const o=Dl(c.uuid)(a);this.dispatch(Ra(o.map(({uuid:u})=>u)));const p=il(a);this.dispatch(sl(p.map(({uuid:u})=>u))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(ol(c.uuid));const d=$u(c.uuid)(a);d&&this.dispatch(fe({...d,project:null}));try{await this.enqueueRequest({description:"Delete project",method:h.DELETE,url:`/projects/${e}/`,blockers:[e],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(u){throw this.dispatch(rl(Object.values(n))),this.dispatch(Sa(Object.values(p))),this.dispatch($l(r)),this.dispatch(jl(o)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),d&&this.dispatch(fe({...d,project:c.uuid})),u}}invite(e,s){const a=Te.v4();return this.enqueueRequest({description:"Invite user to project",method:h.POST,url:`/projects/${e}/invite/${s}/`,payload:{uuid:a},blockers:[],blocks:[a]})}joinProject(e,s,a){return this.enqueueRequest({description:"Join project",method:h.GET,url:`/projects/${e}/join-project/${s}/${a}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:h.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e],blocks:[e]}).then(()=>{this.dispatch(ul(e))})}}class hg extends P{add(e){const s=F({...e,submitted_at:new Date().toISOString()});this.dispatch(xl(s));const a=this.enqueueRequest({description:"Create team",method:h.POST,url:"/teams/",payload:s,blockers:[],blocks:[s.uuid]});return a.then(n=>{this.dispatch(ze(n))}).catch(()=>{this.dispatch(Ea(s.uuid))}),[s,a]}update(e){const{store:s}=this.client,a=ke(e.uuid)(s.getState());if(!a)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const n={...a,...e};this.dispatch(wa(n));const c=this.enqueueRequest({description:"Update team",method:h.PATCH,url:`/teams/${e.uuid}/`,payload:O(e),blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(ze(r))}).catch(()=>{this.dispatch(ze(a))}),[n,c]}async delete(e){const{store:s}=this.client,a=s.getState(),n=ke(e)(a);if(!n)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(Ea(e));try{return await this.enqueueRequest({description:"Delete team",method:h.DELETE,url:`/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(ze(n)),c}}async setMembers(e,s){const{store:a}=this.client,n=ke(e)(a.getState());if(!n)throw new Error(`Expected team with uuid ${e} to exist`);if(s.length!==new Set(s).size)throw new Error("Duplicate members found in the list");this.dispatch(wa({...n,members:s}));const c=this.enqueueRequest({description:"Set team members",method:h.PUT,url:`/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(ze(n))}),c}async addMembers(e,s){const{store:a}=this.client,n=ke(e)(a.getState());if(!n)throw new Error(`Expected team with uuid ${e} to exist`);const c=[...n.members,...s];return this.setMembers(e,c)}async removeMembers(e,s){const{store:a}=this.client,n=ke(e)(a.getState());if(!n)throw new Error(`Expected team with uuid ${e} to exist`);const c=n.members.filter(r=>!s.includes(r));return this.setMembers(e,c)}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:h.GET,url:"/teams/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Zl(s))}}class mg extends P{async refreshStore(e,s){const a={},n=await this.enqueueRequest({description:"Fetch organization users",method:h.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of n)a[r.id]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:h.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)a[r.id]=r;this.dispatch(Nu(Object.values(a)))}}class pg{constructor(e){f(this,"store");this.store=e}async enqueueRequest(e,s,a){return this._enqueueRequest(e,s,a).then(n=>{if(n instanceof q)throw n;return n})}_enqueueRequest(e,s,a){const n=new Ka,c={...e,BASE_URL:s,serviceName:a};if(e.immediate){const r={...c,uuid:e.uuid??Te.v4()},o={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:a}}}};za(o,this).then(p=>{n.resolve(p.body)}).catch(p=>{ka(p,o),p instanceof Error?n.reject(p):n.reject(new Error((p??De).toString()))})}else{const r=this.store.dispatch(Il(c)),o=d=>{if(d)n.resolve(d.body);else{const u=new q({message:"Could not get a response from the server.",response:d,discard:!0});n.reject(u)}},p=d=>{d instanceof q?d.options.discard=!0:(console.error("Received an unexpected error while processing a request:",d,`
15
+ Converting error to APIError and discarding.`),d=new q({message:"An error occurred while processing the request.",innerError:d,discard:!0})),n.reject(d)};r.then(o,p)}return n}}class Ue{constructor(){f(this,"graph");f(this,"requestAttemptCounter");this.graph=new wh.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Ue;for(let a=0;a<e.length;a++){const n=e[a];if(!n){console.error("Outbox item was undefined");continue}s.sneakRequest(n);for(let c=0;c<a;c++){const r=e[c];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==n.payload.uuid&&r.payload.blocks.some(o=>n.payload.blockers.includes(o))&&Ue._addDependency(n.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){Ue._addDependency(e,s,this.graph)}static _addDependency(e,s,a){if(e===s)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!a.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${s})`);if(!a.hasNode(s))throw new Error(`Tried to add dependency to non-existent node: ${s} (from node: ${e})`);a.addDependency(e,s)}addRequest(e){if(this.graph.addNode(e.payload.uuid,e),!(e.payload.blockers.length===0||this.graph.size()===1))for(const s of this.graph.overallOrder()){if(s===e.payload.uuid)continue;const a=this.graph.getNodeData(s);e.payload.blockers.some(n=>a.payload.blocks.includes(n))&&this._addDependency(e.payload.uuid,s)}}insertRequest(e){this.graph.addNode(e.payload.uuid,e);for(const s of this.graph.overallOrder()){if(s===e.payload.uuid)continue;this.graph.getNodeData(s).payload.blockers.some(n=>e.payload.blocks.includes(n))&&this._addDependency(s,e.payload.uuid)}}sneakRequest(e){this.graph.addNode(e.payload.uuid,e)}_getNextNode(){const e=this.graph.overallOrder(!0);let s=1/0,a;for(const n of e){const c=this.requestAttemptCounter[n]||0;c<s&&(s=c,a=n)}return a}peek(){const e=this._getNextNode();if(e)return this.graph.getNodeData(e)}remove(e){this.graph.removeNode(e),delete this.requestAttemptCounter[e]}pop(){const e=this.peek();return e&&this.graph.removeNode(e.payload.uuid),e}getQueue(){const e=this.graph.overallOrder().map(a=>this.graph.getNodeData(a)),s=this._getNextNode();if(s){const a=this.graph.getNodeData(s),n=e.findIndex(c=>c.payload.uuid===a.payload.uuid);n!==-1&&(e.splice(n,1),e.unshift(a))}return e}getReady(){let e=this.graph.overallOrder(!0).map(s=>this.graph.getNodeData(s));return e=e.sort((s,a)=>s.meta.offline.effect.timestamp.localeCompare(a.meta.offline.effect.timestamp)),e=e.sort((s,a)=>{const n=this.requestAttemptCounter[s.payload.uuid]||0,c=this.requestAttemptCounter[a.payload.uuid]||0;return n-c}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const Ag=(t,e)=>{const s=new e(t);return Bf(s),Lf(t),s};var bh=(t=>(t[t.USER_REGISTRATION=0]="USER_REGISTRATION",t[t.APPLICATION_INVITE=2]="APPLICATION_INVITE",t[t.PROJECT_INVITE=4]="PROJECT_INVITE",t[t.ORGANIZATION_INVITE=6]="ORGANIZATION_INVITE",t[t.ADD_EMAIL_DOMAIN=8]="ADD_EMAIL_DOMAIN",t[t.RESET_PASSWORD=10]="RESET_PASSWORD",t))(bh||{});i.APIError=q,i.AgentService=lS,i.AssetAttachmentService=hS,i.AssetProcedureAttachmentService=mS,i.AssetProcedureFieldValuesAttachmentService=yS,i.AssetProcedureFieldValuesService=fS,i.AssetProcedureFieldsAttachmentService=pS,i.AssetProcedureFieldsService=AS,i.AssetProcedureInstanceService=SS,i.AssetProcedureService=gS,i.AssetService=bS,i.AssetStageCompletionService=TS,i.AssetStageService=FS,i.AssetTypeAttachmentService=IS,i.AssetTypeFieldValuesAttachmentService=OS,i.AssetTypeFieldValuesService=_S,i.AssetTypeFieldsAttachmentService=RS,i.AssetTypeFieldsService=PS,i.AssetTypeService=vS,i.AttachmentModel=Ba,i.BaseApiService=P,i.BaseSDK=pg,i.COMMON_AUTO_FIELDS=xa,i.CategoryService=wS,i.DEFAULT_ISSUE_PRIORITY=jh,i.DEFAULT_ISSUE_STATUS=Eh,i.DeferredPromise=Ka,i.DocumentAttachmentService=ES,i.DocumentService=jS,i.EMPTY_ARRAY=$a,i.EMPTY_OBJECT=La,i.EmailDomainsService=qS,i.EmailVerificationService=MS,i.FileService=zS,i.FormRevisionAttachmentService=kS,i.FormRevisionService=DS,i.FormService=US,i.FormSubmissionAttachmentService=VS,i.FormSubmissionService=GS,i.GeoImageService=$S,i.GeoJsonFeatureService=LS,i.GeoJsonLayerService=BS,i.HttpMethod=h,i.IssueAssociationService=NS,i.IssueAttachmentService=JS,i.IssueCommentAttachmentService=HS,i.IssueCommentService=WS,i.IssuePriority=Mt,i.IssueService=KS,i.IssueStatus=Ct,i.IssueTypeAttachmentService=YS,i.IssueTypeFieldValuesAttachmentService=ZS,i.IssueTypeFieldValuesService=xS,i.IssueTypeFieldsAttachmentService=XS,i.IssueTypeFieldsService=QS,i.IssueTypeService=eg,i.IssueUpdateChange=v,i.IssueUpdateService=tg,i.JWTService=ag,i.LicenseLevel=Ja,i.LicenseService=ng,i.LicenseStatus=Ha,i.OUTBOX_RETRY_DELAY=Wa,i.OrganizationAccessLevel=qt,i.OrganizationAccessService=cg,i.OrganizationService=rg,i.OutboxCoordinator=Ue,i.PaddleCheckoutEvent=Na,i.ProjectAccessLevel=jt,i.ProjectAccessService=dg,i.ProjectAttachmentService=og,i.ProjectFileService=ug,i.ProjectService=lg,i.TeamService=hg,i.UNKNOWN_ERROR_MESSAGE=De,i.UserService=mg,i.VERSION_REDUCER_KEY=Ma,i.VerificationCodeType=bh,i._setLatestRetryTime=Pl,i.acceptProjectInvite=ul,i.addAsset=ps,i.addAssetAttachment=im,i.addAssetAttachments=Bt,i.addAssetProcedure=os,i.addAssetProcedureAttachment=cm,i.addAssetProcedureAttachments=bn,i.addAssetProcedureFieldValues=Zt,i.addAssetProcedureFieldValuesAttachment=Pm,i.addAssetProcedureFieldValuesAttachments=it,i.addAssetProcedureFieldValuesMany=xn,i.addAssetProcedureFields=Vn,i.addAssetProcedureFieldsAttachment=um,i.addAssetProcedureFieldsAttachments=jn,i.addAssetProcedureFieldsMany=fm,i.addAssetProcedureInstance=is,i.addAssetProcedureInstances=cc,i.addAssetProcedures=Gm,i.addAssetStage=ep,i.addAssetStageCompletion=Ts,i.addAssetStageCompletions=Fs,i.addAssetStages=_s,i.addAssetType=Ns,i.addAssetTypeAttachment=ap,i.addAssetTypeAttachments=qs,i.addAssetTypeFieldValues=Vs,i.addAssetTypeFieldValuesAttachment=Fp,i.addAssetTypeFieldValuesAttachments=dt,i.addAssetTypeFieldValuesMany=hr,i.addAssetTypeFields=Zc,i.addAssetTypeFieldsAttachment=rp,i.addAssetTypeFieldsAttachments=Nc,i.addAssetTypeFieldsMany=pp,i.addAssetTypes=Cp,i.addAssets=As,i.addCategory=Ys,i.addConversation=nn,i.addDocumentAttachment=Hp,i.addDocumentAttachments=Er,i.addDocuments=$r,i.addEmailDomain=Wr,i.addForm=di,i.addFormRevision=ni,i.addFormRevisionAttachment=sA,i.addFormRevisionAttachments=nd,i.addFormRevisions=md,i.addFormSubmission=mi,i.addFormSubmissionAttachment=AA,i.addFormSubmissionAttachments=mt,i.addFormSubmissions=yt,i.addForms=hA,i.addGeoImage=Vd,i.addGeoImages=Gd,i.addGeoJsonFeature=Fi,i.addGeoJsonFeatures=Kd,i.addGeoJsonLayer=_i,i.addGeoJsonLayers=vA,i.addIssue=Ki,i.addIssueAssociation=qi,i.addIssueAssociations=Mi,i.addIssueAttachment=VA,i.addIssueAttachments=Ui,i.addIssueComment=Ni,i.addIssueCommentAttachment=LA,i.addIssueCommentAttachments=Fo,i.addIssueComments=HA,i.addIssueType=Pu,i.addIssueTypeAttachment=XA,i.addIssueTypeAttachments=Lo,i.addIssueTypeFieldValues=ta,i.addIssueTypeFieldValuesAttachment=Fy,i.addIssueTypeFieldValuesAttachments=bt,i.addIssueTypeFieldValuesMany=ry,i.addIssueTypeFields=lu,i.addIssueTypeFieldsAttachment=ey,i.addIssueTypeFieldsAttachments=xo,i.addIssueTypeFieldsMany=my,i.addIssueUpdate=qu,i.addIssueUpdates=Mu,i.addIssues=Do,i.addLicenses=qy,i.addOrganization=hf,i.addOrganizations=lf,i.addProject=sf,i.addProjectAttachment=Pf,i.addProjectAttachments=wl,i.addProjectFile=wf,i.addProjectFiles=$l,i.addProjects=tf,i.addTeam=xl,i.addUser=Vy,i.addUsers=Uy,i.agentsReducer=dn,i.agentsSlice=Vt,i.areArraysEqual=Dh,i.assetAttachmentReducer=fn,i.assetAttachmentSlice=$t,i.assetProcedureAttachmentReducer=vn,i.assetProcedureAttachmentSlice=Jt,i.assetProcedureFieldValuesAttachmentReducer=Xn,i.assetProcedureFieldValuesAttachmentSlice=Yt,i.assetProcedureFieldValuesReducer=ic,i.assetProcedureFieldValuesSlice=Qt,i.assetProcedureFieldsAttachmentReducer=kn,i.assetProcedureFieldsAttachmentSlice=Ht,i.assetProcedureFieldsReducer=Bn,i.assetProcedureFieldsSlice=Wt,i.assetProcedureInstanceReducer=oc,i.assetProcedureInstanceSlice=ss,i.assetProcedureReducer=mc,i.assetProcedureSlice=ds,i.assetReducer=Sc,i.assetSlice=ms,i.assetStageCompletionReducer=Ic,i.assetStageCompletionSlice=bs,i.assetStageReducer=wc,i.assetStageSlice=Os,i.assetTypeAttachmentReducer=$c,i.assetTypeAttachmentSlice=js,i.assetTypeFieldValuesAttachmentReducer=or,i.assetTypeFieldValuesAttachmentSlice=ks,i.assetTypeFieldValuesReducer=yr,i.assetTypeFieldValuesSlice=Us,i.assetTypeFieldsAttachmentReducer=Yc,i.assetTypeFieldsAttachmentSlice=Cs,i.assetTypeFieldsReducer=sr,i.assetTypeFieldsSlice=zs,i.assetTypeReducer=gr,i.assetTypeSlice=Bs,i.authReducer=Fr,i.authSlice=ut,i.blobToBase64=Hh,i.categoryReducer=_r,i.categorySlice=Ks,i.clearTokens=Gp,i.constructUploadedFilePayloads=Jh,i.coordinatesAreEqual=zh,i.createModelAdapter=T,i.createMultiPointGeometry=Ch,i.createOfflineAction=Tl,i.createPayload=O,i.createPointGeometry=Mh,i.createSelectionAdapter=qh,i.deleteAsset=ys,i.deleteAssetAttachment=hn,i.deleteAssetAttachments=Nt,i.deleteAssetProcedure=us,i.deleteAssetProcedureAttachment=In,i.deleteAssetProcedureAttachments=Rn,i.deleteAssetProcedureFieldValues=xt,i.deleteAssetProcedureFieldValuesAttachment=wm,i.deleteAssetProcedureFieldValuesAttachments=at,i.deleteAssetProcedureFieldValuesMany=tc,i.deleteAssetProcedureFields=$n,i.deleteAssetProcedureFieldsAttachment=pm,i.deleteAssetProcedureFieldsAttachments=Mn,i.deleteAssetProcedureFieldsMany=Tm,i.deleteAssetProcedureInstance=as,i.deleteAssetProcedureInstances=rc,i.deleteAssetProcedures=Lm,i.deleteAssetStage=tp,i.deleteAssetStageCompletion=Is,i.deleteAssetStageCompletions=Rs,i.deleteAssetStages=ws,i.deleteAssetType=Js,i.deleteAssetTypeAttachment=kc,i.deleteAssetTypeAttachments=Ms,i.deleteAssetTypeFieldValues=Gs,i.deleteAssetTypeFieldValuesAttachment=Op,i.deleteAssetTypeFieldValuesAttachments=ot,i.deleteAssetTypeFieldValuesMany=pr,i.deleteAssetTypeFields=er,i.deleteAssetTypeFieldsAttachment=lp,i.deleteAssetTypeFieldsAttachments=Hc,i.deleteAssetTypeFieldsMany=Sp,i.deleteAssetTypes=kp,i.deleteAssets=yc,i.deleteCategory=Or,i.deleteDocumentAttachment=Mr,i.deleteDocumentAttachments=Cr,i.deleteEmailDomain=Kr,i.deleteForm=oi,i.deleteFormRevision=ci,i.deleteFormRevisionAttachment=cA,i.deleteFormRevisionAttachments=rd,i.deleteFormRevisions=pd,i.deleteFormSubmission=pi,i.deleteFormSubmissionAttachment=gA,i.deleteFormSubmissionAttachments=pt,i.deleteFormSubmissions=ft,i.deleteGeoImage=gi,i.deleteGeoImages=Ld,i.deleteGeoJsonFeature=Ii,i.deleteGeoJsonFeatures=Yd,i.deleteGeoJsonLayer=vi,i.deleteGeoJsonLayers=EA,i.deleteIssue=Yi,i.deleteIssueAssociation=Ci,i.deleteIssueAssociations=zi,i.deleteIssueAttachment=Ao,i.deleteIssueAttachments=Vi,i.deleteIssueComment=Ji,i.deleteIssueCommentAttachment=Po,i.deleteIssueCommentAttachments=Oo,i.deleteIssueComments=WA,i.deleteIssueTypeAttachment=Jo,i.deleteIssueTypeAttachments=Ho,i.deleteIssueTypeFieldValues=sa,i.deleteIssueTypeFieldValuesAttachment=Oy,i.deleteIssueTypeFieldValuesAttachments=Tt,i.deleteIssueTypeFieldValuesMany=ly,i.deleteIssueTypeFields=mu,i.deleteIssueTypeFieldsAttachment=ay,i.deleteIssueTypeFieldsAttachments=tu,i.deleteIssueTypeFieldsMany=fy,i.deleteIssueUpdate=Cu,i.deleteIssueUpdates=zu,i.deleteIssues=Uo,i.deleteOrganization=Af,i.deleteOrganizationAccess=Xu,i.deleteOrganizations=yf,i.deleteProject=ol,i.deleteProjectAccess=tl,i.deleteProjectAccesses=sl,i.deleteProjectAttachment=Ml,i.deleteProjectAttachments=Ra,i.deleteProjectFile=Ll,i.deleteProjectFiles=Bl,i.deleteProjects=nf,i.deleteTeam=Ea,i.deleteUser=Ly,i.deleteUsers=By,i.dequeue=yh,i.discard=ka,i.documentAttachmentReducer=Ur,i.documentAttachmentSlice=Zs,i.documentSlice=xs,i.documentsReducer=Jr,i.downloadFile=Wh,i.downloadInMemoryFile=Nh,i.emailDomainsReducer=Qr,i.emailDomainsSlice=ti,i.emailRegex=em,i.enqueue=Ah,i.enqueueRequest=Il,i.fallbackToEmptyArray=S,i.fallbackToEmptyObject=Ee,i.fileReducer=sd,i.fileSlice=si,i.fileToBlob=Qa,i.formReducer=bd,i.formRevisionAttachmentReducer=od,i.formRevisionAttachmentSlice=ii,i.formRevisionReducer=fd,i.formRevisionsSlice=ai,i.formSlice=ri,i.formSubmissionAttachmentReducer=vd,i.formSubmissionAttachmentSlice=ui,i.formSubmissionReducer=zd,i.formSubmissionSlice=hi,i.geoImageReducer=Jd,i.geoImageSlice=Si,i.geoJsonFeatureReducer=Zd,i.geoJsonFeatureSlice=Ti,i.geoJsonLayerReducer=so,i.geoJsonLayerSlice=Oi,i.getFileIdentifier=Bh,i.getFileS3Key=Ut,i.getLocalDateString=Ya,i.getLocalRelativeDateString=$h,i.getOutboxCoordinator=_e,i.getRenamedFile=Xa,i.hashFile=je,i.initSDK=Ag,i.initializeAssetAttachments=Lt,i.initializeAssetProcedureAttachments=gn,i.initializeAssetProcedureFieldValues=Zn,i.initializeAssetProcedureFieldValuesAttachments=Jn,i.initializeAssetProcedureFields=Un,i.initializeAssetProcedureFieldsAttachments=En,i.initializeAssetProcedureInstances=nc,i.initializeAssetProcedures=lc,i.initializeAssetStageCompletions=bc,i.initializeAssetStages=_c,i.initializeAssetTypeAttachments=Mc,i.initializeAssetTypeFieldValues=lr,i.initializeAssetTypeFieldValuesAttachments=ar,i.initializeAssetTypeFields=Qc,i.initializeAssetTypeFieldsAttachments=Bc,i.initializeAssetTypes=Sr,i.initializeAssets=Ac,i.initializeCategories=Rr,i.initializeConversations=an,i.initializeDocumentAttachments=wr,i.initializeEmailDomains=Hr,i.initializeFormRevisionAttachments=ad,i.initializeFormRevisions=hd,i.initializeFormSubmissionAttachments=Rd,i.initializeFormSubmissions=Ed,i.initializeForms=gd,i.initializeGeoImages=Dd,i.initializeGeoJsonFeatures=Wd,i.initializeGeoJsonLayers=eo,i.initializeIssueAssociations=ao,i.initializeIssueAttachments=Di,i.initializeIssueCommentAttachments=$i,i.initializeIssueTypeAttachments=Zi,i.initializeIssueTypeFieldValues=cu,i.initializeIssueTypeFieldValuesAttachments=fu,i.initializeIssueTypeFields=uu,i.initializeIssueTypeFieldsAttachments=Zo,i.initializeIssueTypes=Ru,i.initializeIssueUpdates=ju,i.initializeIssues=ko,i.initializeLicences=Gu,i.initializeOrganizationAccesses=Ku,i.initializeOrganizations=of,i.initializeProjectAccesses=Sa,i.initializeProjectAttachments=vl,i.initializeProjectFiles=Gl,i.initializeProjects=xy,i.initializeTeams=Zl,i.initializeUsers=Nu,i.isToday=Gh,i.issueAssociationReducer=lo,i.issueAssociationSlice=ji,i.issueAttachmentReducer=bo,i.issueAttachmentSlice=ki,i.issueCommentAttachmentReducer=Eo,i.issueCommentAttachmentSlice=Gi,i.issueCommentReducer=Co,i.issueCommentSlice=Li,i.issueReducer=Go,i.issueSlice=Wi,i.issueTypeAttachmentReducer=Xo,i.issueTypeAttachmentSlice=Qi,i.issueTypeFieldValuesAttachmentReducer=Fu,i.issueTypeFieldValuesAttachmentSlice=ca,i.issueTypeFieldValuesReducer=du,i.issueTypeFieldValuesSlice=ea,i.issueTypeFieldsAttachmentReducer=au,i.issueTypeFieldsAttachmentSlice=xi,i.issueTypeFieldsReducer=Au,i.issueTypeFieldsSlice=na,i.issueTypeReducer=wu,i.issueTypeSlice=da,i.issueUpdateReducer=Uu,i.issueUpdateSlice=ha,i.licenseReducer=Lu,i.licenseSlice=ma,i.logOnlyOnce=Kh,i.markAsDeleted=Rl,i.markForDeletion=Rf,i.memoize=kt,i.moveDocument=Lr,i.offline=F,i.onlyUniqueHashes=xh,i.onlyUniqueOfflineIds=tn,i.organizationAccessReducer=Zu,i.organizationAccessSlice=Aa,i.organizationReducer=bl,i.organizationSlice=Ta,i.outboxReducer=Ol,i.outboxSlice=Fa,i.overmapEnhancer=xf,i.overmapReducers=hh,i.overmapRootReducer=Kf,i.performRequest=za,i.projectAccessReducer=nl,i.projectAccessSlice=fa,i.projectAttachmentReducer=Ul,i.projectAttachmentSlice=Ia,i.projectFileReducer=Yl,i.projectFileSlice=Pa,i.projectReducer=ll,i.projectSlice=ba,i.rehydratedReducer=Xl,i.rehydratedSlice=_a,i.removeDocuments=ei,i.removeIssueType=oa,i.removeUser=Ju,i.resetProjectFileObjectUrls=jf,i.resetStore=ph,i.restructureCreateSelectorWithArgs=g,i.saveActiveProjectFileBounds=Hl,i.selectAccessToken=$p,i.selectActiveOrganizationAccess=Yy,i.selectActiveProjectFileId=Mf,i.selectActiveStatusLicenses=Cy,i.selectAllDocumentAttachments=kr,i.selectAllProjectAttachments=zl,i.selectAncestorIdsOfDocument=Qp,i.selectAssetAttachmentById=An,i.selectAssetAttachmentMapping=mn,i.selectAssetAttachments=pn,i.selectAssetById=gs,i.selectAssetProcedureAttachmentById=_n,i.selectAssetProcedureAttachmentMapping=Pn,i.selectAssetProcedureAttachments=On,i.selectAssetProcedureById=hs,i.selectAssetProcedureFieldValues=es,i.selectAssetProcedureFieldValuesAttachmentById=Em,i.selectAssetProcedureFieldValuesAttachments=Wn,i.selectAssetProcedureFieldValuesAttachmentsByIds=Kn,i.selectAssetProcedureFieldValuesAttachmentsMapping=Xt,i.selectAssetProcedureFieldValuesById=ts,i.selectAssetProcedureFieldValuesMapping=sc,i.selectAssetProcedureFieldValuesOfAsset=Mm,i.selectAssetProcedureFields=Kt,i.selectAssetProcedureFieldsAttachmentById=ym,i.selectAssetProcedureFieldsAttachments=zn,i.selectAssetProcedureFieldsAttachmentsMapping=Cn,i.selectAssetProcedureFieldsById=Rm,i.selectAssetProcedureFieldsMapping=Ln,i.selectAssetProcedureFieldsOfAssetProcedure=Fm,i.selectAssetProcedureInstanceById=rs,i.selectAssetProcedureInstances=cs,i.selectAssetProcedureInstancesByIds=Vm,i.selectAssetProcedureInstancesMapping=ns,i.selectAssetProcedureInstancesOfAssetProcedure=dc,i.selectAssetProcedureInstancesOfAssetType=Um,i.selectAssetProcedures=hc,i.selectAssetProceduresByIds=Hm,i.selectAssetProceduresMapping=ls,i.selectAssetProceduresOfOrganization=Jm,i.selectAssetStageById=Ec,i.selectAssetStageCompletionById=Rc,i.selectAssetStageCompletionMapping=Ps,i.selectAssetStageCompletions=Zm,i.selectAssetStageCompletionsByIds=Pc,i.selectAssetStages=jc,i.selectAssetStagesByIds=Es,i.selectAssetStagesMappingOfAssetProcedure=sp,i.selectAssetStagesOfAssetProcedure=ip,i.selectAssetTypeAttachmentById=Vc,i.selectAssetTypeAttachmentMapping=Dc,i.selectAssetTypeAttachments=Uc,i.selectAssetTypeById=Ws,i.selectAssetTypeFieldValues=$s,i.selectAssetTypeFieldValuesAttachmentById=_p,i.selectAssetTypeFieldValuesAttachments=cr,i.selectAssetTypeFieldValuesAttachmentsByIds=rr,i.selectAssetTypeFieldValuesAttachmentsMapping=Ds,i.selectAssetTypeFieldValuesById=Ls,i.selectAssetTypeFieldValuesMapping=Ar,i.selectAssetTypeFieldValuesOfAsset=Ep,i.selectAssetTypeFields=rt,i.selectAssetTypeFieldsAttachmentById=mp,i.selectAssetTypeFieldsAttachments=Kc,i.selectAssetTypeFieldsAttachmentsMapping=Wc,i.selectAssetTypeFieldsById=Tp,i.selectAssetTypeFieldsMapping=tr,i.selectAssetTypeFieldsOfAssetType=gp,i.selectAssetTypeValuesOfAssetType=jp,i.selectAssetTypes=Dp,i.selectAssetTypesByIds=Up,i.selectAssetTypesMapping=Hs,i.selectAssets=fc,i.selectAssetsByIds=Xm,i.selectAssetsMapping=fs,i.selectAssetsOfAssetType=Ss,i.selectAttachmentsOfAsset=yn,i.selectAttachmentsOfAssetProcedure=om,i.selectAttachmentsOfAssetProcedureFieldValues=Yn,i.selectAttachmentsOfAssetProcedureFields=Am,i.selectAttachmentsOfAssetType=Gc,i.selectAttachmentsOfAssetTypeFieldValues=dr,i.selectAttachmentsOfAssetTypeFields=hp,i.selectAttachmentsOfDocument=Yp,i.selectAttachmentsOfFormRevision=rA,i.selectAttachmentsOfFormSubmission=_d,i.selectAttachmentsOfIssue=So,i.selectAttachmentsOfIssueComment=JA,i.selectAttachmentsOfIssueType=xA,i.selectAttachmentsOfIssueTypeFieldValues=Tu,i.selectAttachmentsOfIssueTypeFields=ny,i.selectAttachmentsOfProject=Dl,i.selectCategories=Bp,i.selectCategoriesByIds=Np,i.selectCategoryById=Qs,i.selectCategoryMapping=Xs,i.selectCommentsOfIssue=KA,i.selectConversation=sm,i.selectConversationMapping=Gt,i.selectConversations=tm,i.selectCurrentUser=Rt,i.selectDeletedRequests=Ff,i.selectDocumentAttachmentById=Dr,i.selectDocumentAttachmentMapping=zr,i.selectDocumentById=Nr,i.selectDocuments=Br,i.selectDocumentsByIds=Xp,i.selectDocumentsMapping=qe,i.selectEmailDomains=Xr,i.selectEmailDomainsAsMapping=Yr,i.selectEmailDomainsOfOrganization=eA,i.selectFieldValuesOfAssetProcedureInstance=Cm,i.selectFormById=Fd,i.selectFormMapping=Td,i.selectFormRevisionAttachmentsMapping=dd,i.selectFormRevisionById=oA,i.selectFormRevisionMapping=ht,i.selectFormRevisions=Ad,i.selectFormRevisionsOfForm=yd,i.selectFormSubmissionAttachemntsByIds=Od,i.selectFormSubmissionAttachmentsMapping=li,i.selectFormSubmissionById=fi,i.selectFormSubmissions=yi,i.selectFormSubmissionsMapping=Ai,i.selectFormSubmissionsOfAsset=Cd,i.selectFormSubmissionsOfForm=qd,i.selectFormSubmissionsOfIssue=Md,i.selectForms=pA,i.selectGeoImageById=bi,i.selectGeoImageMapping=Bd,i.selectGeoImages=Nd,i.selectGeoImagesOfProject=IA,i.selectGeoJsonFeatureById=Pi,i.selectGeoJsonFeatures=Xd,i.selectGeoJsonFeaturesByIds=_A,i.selectGeoJsonFeaturesMapping=Ri,i.selectGeoJsonFeaturesOfLayer=Qd,i.selectGeoJsonLayerById=Ei,i.selectGeoJsonLayers=to,i.selectGeoJsonLayersByIds=CA,i.selectGeoJsonLayersMapping=wi,i.selectGeoJsonLayersOfProject=MA,i.selectIsImportingProjectFile=Cf,i.selectIsLoggedIn=Lp,i.selectIssueAssociationById=co,i.selectIssueAssociationMapping=Xe,i.selectIssueAssociations=UA,i.selectIssueAssociationsOfAsset=uo,i.selectIssueAssociationsOfIssue=oo,i.selectIssueAssociationsToIssue=ro,i.selectIssueAttachmentById=go,i.selectIssueAttachmentMapping=yo,i.selectIssueAttachments=fo,i.selectIssueById=Xi,i.selectIssueCommentAttachmentById=wo,i.selectIssueCommentAttachmentMapping=_o,i.selectIssueCommentAttachments=vo,i.selectIssueCommentById=Hi,i.selectIssueCommentMapping=Mo,i.selectIssueCountOfCategory=Jp,i.selectIssueMapping=Vo,i.selectIssueTypeAttachmentById=Yo,i.selectIssueTypeAttachmentMapping=Wo,i.selectIssueTypeAttachments=Ko,i.selectIssueTypeById=ua,i.selectIssueTypeFieldValues=ia,i.selectIssueTypeFieldValuesAttachmentById=_y,i.selectIssueTypeFieldValuesAttachments=gu,i.selectIssueTypeFieldValuesAttachmentsByIds=bu,i.selectIssueTypeFieldValuesAttachmentsMapping=ra,i.selectIssueTypeFieldValuesById=aa,i.selectIssueTypeFieldValuesMapping=ru,i.selectIssueTypeFieldValuesOfIssue=hy,i.selectIssueTypeFields=gt,i.selectIssueTypeFieldsAttachmentById=cy,i.selectIssueTypeFieldsAttachments=iu,i.selectIssueTypeFieldsAttachmentsMapping=su,i.selectIssueTypeFieldsById=Ty,i.selectIssueTypeFieldsMapping=pu,i.selectIssueTypeFieldsOfIssueType=Sy,i.selectIssueTypeMapping=_u,i.selectIssueTypeValuesOfIssueType=by,i.selectIssueTypes=vu,i.selectIssueTypesByIds=vy,i.selectIssueTypesOfOrganization=wy,i.selectIssueUpdateMapping=ku,i.selectIssueUpdatesOfIssue=Du,i.selectIssuesByIds=YA,i.selectIssuesOfIssueType=la,i.selectIssuesOfIssueTypeCount=Ey,i.selectLatestAssetProcedureFieldsOfAssetProcedure=Im,i.selectLatestAssetTypeFieldsOfAssetType=bp,i.selectLatestFormRevisionOfForm=uA,i.selectLatestIssueTypeFieldsOfIssueType=gy,i.selectLatestRetryTime=If,i.selectLicense=My,i.selectLicenseForProject=$u,i.selectLicenses=It,i.selectLicensesForProjectsMapping=zy,i.selectLicensesOfOrganization=bf,i.selectNumberOfAssetsOfAssetType=Qm,i.selectOrganizationAccessById=Ky,i.selectOrganizationAccessForUser=Xy,i.selectOrganizationAccessUserMapping=Qu,i.selectOrganizationAccesses=ya,i.selectOrganizationById=ff,i.selectOrganizationUsersAsMapping=gl,i.selectOrganizationUsersIds=Sl,i.selectOrganizations=fl,i.selectOrganizationsMapping=yl,i.selectOrganizationsWithAccess=Sf,i.selectProjectAccessById=Qy,i.selectProjectAccessForUser=Zy,i.selectProjectAccessMapping=ga,i.selectProjectAccessUserMapping=al,i.selectProjectAccesses=il,i.selectProjectAttachmentById=kl,i.selectProjectAttachmentMapping=Cl,i.selectProjectById=rf,i.selectProjectFileById=qf,i.selectProjectFileMapping=Wl,i.selectProjectFiles=Kl,i.selectProjectMapping=_t,i.selectProjectUsersAsMapping=ml,i.selectProjectUsersIds=hl,i.selectProjects=cf,i.selectProjectsOfOrganization=gf,i.selectRehydrated=Df,i.selectRootDocuments=Zp,i.selectSortedOrganizationUsers=Tf,i.selectSortedProjectUsers=df,i.selectStageMapping=ct,i.selectTeamById=ke,i.selectTeams=qa,i.selectTeamsByIds=Uf,i.selectTeamsMapping=ja,i.selectTeamsOfOrganization=Vf,i.selectTeamsOfUser=Gf,i.selectUploadUrl=td,i.selectUserById=Hy,i.selectUsersByIds=Wy,i.selectUsersMapping=Pt,i.setActiveProjectFileId=Jl,i.setAsset=Km,i.setAssetAttachment=un,i.setAssetAttachments=am,i.setAssetProcedure=Bm,i.setAssetProcedureAttachment=Tn,i.setAssetProcedureAttachments=rm,i.setAssetProcedureFieldValues=jm,i.setAssetProcedureFieldValuesAttachment=Om,i.setAssetProcedureFieldValuesAttachments=_m,i.setAssetProcedureFieldValuesMany=qm,i.setAssetProcedureFields=Sm,i.setAssetProcedureFieldsAttachment=lm,i.setAssetProcedureFieldsAttachments=hm,i.setAssetProcedureFieldsMany=gm,i.setAssetProcedureInstance=km,i.setAssetProcedureInstances=Dm,i.setAssetProcedures=Nm,i.setAssetStage=vc,i.setAssetStages=xm,i.setAssetType=qp,i.setAssetTypeAttachment=Cc,i.setAssetTypeAttachments=np,i.setAssetTypeFieldValues=vp,i.setAssetTypeFieldValuesAttachment=Ip,i.setAssetTypeFieldValuesAttachments=Rp,i.setAssetTypeFieldValuesMany=wp,i.setAssetTypeFields=Ap,i.setAssetTypeFieldsAttachment=dp,i.setAssetTypeFieldsAttachments=op,i.setAssetTypeFieldsMany=yp,i.setAssetTypes=Mp,i.setAssets=Ym,i.setConversation=cn,i.setCurrentUser=Ny,i.setDocumentAttachment=jr,i.setDocumentAttachments=Wp,i.setDocuments=Gr,i.setForm=lA,i.setFormRevision=ld,i.setFormRevisionAttachment=iA,i.setFormRevisionAttachments=aA,i.setFormSubmission=At,i.setFormSubmissionAttachment=yA,i.setFormSubmissionAttachments=fA,i.setFormSubmissions=bA,i.setGeoImage=We,i.setGeoImages=Ud,i.setGeoJsonFeature=PA,i.setGeoJsonFeatures=OA,i.setGeoJsonLayer=jA,i.setGeoJsonLayers=qA,i.setIsImportingProjectFile=Nl,i.setIssueAssociation=kA,i.setIssueAssociations=zA,i.setIssueAttachment=mo,i.setIssueAttachments=GA,i.setIssueComment=Bi,i.setIssueCommentAttachment=Io,i.setIssueCommentAttachments=BA,i.setIssueComments=qo,i.setIssueType=Ze,i.setIssueTypeAttachment=Bo,i.setIssueTypeAttachments=QA,i.setIssueTypeFieldValues=dy,i.setIssueTypeFieldValuesAttachment=Iy,i.setIssueTypeFieldValuesAttachments=Ry,i.setIssueTypeFieldValuesMany=oy,i.setIssueTypeFields=py,i.setIssueTypeFieldsAttachment=ty,i.setIssueTypeFieldsAttachments=sy,i.setIssueTypeFieldsMany=Ay,i.setIssueUpdate=jy,i.setLoggedIn=Tr,i.setOrganization=uf,i.setOrganizations=Al,i.setProfilePicture=Jy,i.setProject=ef,i.setProjectAttachment=El,i.setProjectAttachments=jl,i.setProjectFile=_f,i.setProjectFiles=vf,i.setProjects=rl,i.setRehydrated=kf,i.setTeam=ze,i.setTokens=Vp,i.setUploadUrl=ed,i.setUser=Dy,i.setUsers=ky,i.shallowEqual=kh,i.slugify=Qh,i.spacesToDashesLower=Xh,i.teamReducer=eh,i.teamSlice=va,i.toFileNameSafeString=Yh,i.toOfflineIdRecord=en,i.truncate=Zh,i.updateAsset=Be,i.updateAssetAttachment=nm,i.updateAssetAttachments=ln,i.updateAssetProcedure=Le,i.updateAssetProcedureAttachment=dm,i.updateAssetProcedureAttachments=Fn,i.updateAssetProcedureFieldValues=Ge,i.updateAssetProcedureFieldValuesAttachment=vm,i.updateAssetProcedureFieldValuesAttachments=Hn,i.updateAssetProcedureFieldValuesMany=ec,i.updateAssetProcedureFields=Gn,i.updateAssetProcedureFieldsAttachment=mm,i.updateAssetProcedureFieldsAttachments=qn,i.updateAssetProcedureFieldsMany=bm,i.updateAssetProcedureInstance=$e,i.updateAssetProcedureInstances=zm,i.updateAssetProcedures=$m,i.updateAssetStage=vs,i.updateAssetStageCompletion=Tc,i.updateAssetStageCompletions=Fc,i.updateAssetStages=nt,i.updateAssetType=Je,i.updateAssetTypeAttachment=cp,i.updateAssetTypeAttachments=zc,i.updateAssetTypeFieldValues=Ne,i.updateAssetTypeFieldValuesAttachment=Pp,i.updateAssetTypeFieldValuesAttachments=nr,i.updateAssetTypeFieldValuesMany=mr,i.updateAssetTypeFields=xc,i.updateAssetTypeFieldsAttachment=up,i.updateAssetTypeFieldsAttachments=Jc,i.updateAssetTypeFieldsMany=fp,i.updateAssetTypes=zp,i.updateAssets=Wm,i.updateCategory=Pr,i.updateConversation=rn,i.updateDocumentAttachment=Kp,i.updateDocumentAttachments=qr,i.updateDocuments=ge,i.updateForm=mA,i.updateFormRevisionAttachment=nA,i.updateFormRevisionAttachments=cd,i.updateFormSubmission=jd,i.updateFormSubmissionAttachment=SA,i.updateFormSubmissionAttachments=Pd,i.updateFormSubmissions=TA,i.updateGeoImage=$d,i.updateGeoImages=FA,i.updateGeoJsonFeature=Ke,i.updateGeoJsonFeatures=RA,i.updateGeoJsonLayer=Ye,i.updateGeoJsonLayers=wA,i.updateIssue=St,i.updateIssueAssociation=no,i.updateIssueAssociations=DA,i.updateIssueAttachment=$A,i.updateIssueAttachments=po,i.updateIssueCommentAttachment=NA,i.updateIssueCommentAttachments=Ro,i.updateIssueType=Ou,i.updateIssueTypeAttachment=ZA,i.updateIssueTypeAttachments=No,i.updateIssueTypeFieldValues=Qe,i.updateIssueTypeFieldValuesAttachment=Py,i.updateIssueTypeFieldValuesAttachments=Su,i.updateIssueTypeFieldValuesMany=uy,i.updateIssueTypeFields=hu,i.updateIssueTypeFieldsAttachment=iy,i.updateIssueTypeFieldsAttachments=eu,i.updateIssueTypeFieldsMany=yy,i.updateLicense=fe,i.updateOrganization=pf,i.updateOrganizationAccess=Yu,i.updateOrganizations=mf,i.updateProject=dl,i.updateProjectAccess=el,i.updateProjectAttachment=Of,i.updateProjectAttachments=ql,i.updateProjectFile=Oa,i.updateProjectFiles=Ef,i.updateProjects=af,i.updateTeam=wa,i.updateUser=$y,i.updateUsers=Gy,i.userReducer=Hu,i.userSlice=pa,i.versioningReducer=sh,i.versioningSlice=th,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});