@overmap-ai/core 1.0.78-view-sets.15 → 1.0.78-view-sets.17
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(a,z){typeof exports=="object"&&typeof module<"u"?z(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("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","jwt-decode","dependency-graph","@tiptap/core"],z):(a=typeof globalThis<"u"?globalThis:a||self,z(a["overmap-core"]={},null,a.toolkit,a.request,a.uuid,a.fileSaver,a.reduxOffline,a.offlineConfig,null,a.localforage,a.createMigration,null,a.idb,a.jwtDecode,a.dependencyGraph))})(this,function(a,z,u,Ge,Le,mm,pm,lc,FF,Am,ym,PF,fm,Sm,gm){"use strict";var gF=Object.defineProperty;var bF=(a,z,u)=>z in a?gF(a,z,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[z]=u;var S=(a,z,u)=>bF(a,typeof z!="symbol"?z+"":z,u);var hm;const hc=Object.freeze([]),mc=Object.freeze({});var pc=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(pc||{}),h=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(h||{}),Ac=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(Ac||{}),Gt=(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))(Gt||{}),Lt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Lt||{}),E=(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))(E||{});const bm=Lt.BACKLOG,Fm=Gt.MEDIUM,yc=6e4;function I(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 Pm(){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 l=new Set(m.selection);for(const p of d.payload)l.has(p)||l.add(p);m.selection=Array.from(l)},unselectOne:(m,d)=>{const l=new Set(m.selection);l.has(d.payload)&&(l.delete(d.payload),m.selection=Array.from(l))},unselectMany:(m,d)=>{const l=new Set(m.selection);for(const p of d.payload)l.has(p)&&l.delete(p);m.selection=Array.from(l)},toggleOne:(m,d)=>{const l=new Set(m.selection);l.has(d.payload)?l.delete(d.payload):l.add(d.payload),m.selection=Array.from(l)},toggleMany:(m,d)=>{const l=new Set(m.selection);for(const p of d.payload)l.has(p)?l.delete(p):l.add(p);m.selection=Array.from(l)},getInitialState:m=>({...m,selection:[]})}}const Je="versioning",P=u.createAction("RESET"),M=u.createAction("RESET_PROJECT_STATE"),O=u.createAction("RESET_ORGANIZATION_STATE");hm=Symbol.toStringTag;class fc{constructor(){S(this,hm,"Promise");S(this,"_promise");S(this,"_resolve");S(this,"_reject");S(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 Tm=t=>({type:"Point",coordinates:t}),Im=t=>({type:"MultiPoint",coordinates:t}),_m=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Nt=!1;["true","1"].includes("".toLowerCase())&&(Nt=!0);function Om(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;const s=Object.keys(t),i=Object.keys(e),c=s.length;if(c!==i.length)return!1;for(let n=0;n<c;n++){const r=s[n];if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1}return!0}function Ht(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Nt&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Nt&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Rm(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 g=t=>t.length===0?hc:t,ht=t=>Object.keys(t).length===0?mc:t,Sc=Ht(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===Wt.getFullYear(),i={day:"numeric",month:"short"};return s||(i.year="numeric"),e.toLocaleDateString([],i)}),vm=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),wm=1e3*86400,Wt=new Date,Mm=t=>new Date(t).toDateString()===Wt.toDateString(),Em=Ht((t,e,s)=>{const i=Math.round((new Date(t).getTime()-Wt.getTime())/wm);return i<e||i>s?Sc(t):vm.format(i,"days")});function jm(t){return new Uint8Array(t).reduce((s,i)=>s+i.toString(16).padStart(2,"0"),"")}const Kt=async(t,e)=>{e||(e=await Ne(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 Ne(t){return new Promise((e,s)=>{const i=new FileReader;i.onload=()=>{const c=i.result;if(!c){s(new Error("FileReader did not return a valid ArrayBuffer."));return}crypto.subtle.digest("SHA-1",c).then(n=>{const r=jm(n);e(r)})},i.readAsArrayBuffer(t)})}function qm(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 gc(t,e){return new File([t],e,{type:t.type})}function Vm(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 zm=async t=>{const e={};for(const s of t){const i=await Ne(s);e[i]={sha1:i,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},bc=async t=>(await fetch(t)).blob(),Dm=t=>new Promise((e,s)=>{const i=new FileReader;i.onloadend=()=>{var c;e(((c=i.result)==null?void 0:c.toString())||"")},i.readAsDataURL(t)});function Cm(t){const e=new Blob([t]);mm.saveAs(e,t.name)}const Fc={};function Um(t,e,s,...i){const c=Fc[t];let n=!1;c?c[e]||(c[e]=!0,n=!0):(Fc[t]={[e]:!0},n=!0),n&&console[s](...i)}const Pc=["created_at","updated_at","index","revision"];function T(t){return{...t,uuid:Le.v4()}}function Tc(t){const e={};for(const s of t)e[s.uuid]=s;return e}function km(t,e=void 0,s=255){let i=t.replace(/[^a-z0-9_\-.]/gi,"_").replace(/_{2,}/g,"_");if(!e){const n=t.split(".");n.length>1&&(e=n[n.length-1])}e&&!e.startsWith(".")&&(e="."+e);const c=e?e.length:0;return i.length+c>s&&(i=i.slice(0,s-c)+(e||"")),i}function Bm(t){return t.toLowerCase().replace(" ","-")}function $m(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Gm(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const f=t=>e=>s=>t(s,e);function Ic(t,e,s){return s.findIndex(i=>i.uuid===t.uuid)===e}function Lm(t,e,s){return s.findIndex(i=>i.file_sha1===t.file_sha1)===e}const Nm=/^.+@.+\..+$/;function w(t){const e={...t};for(const s of[...Pc,"created_by"])s in e&&delete e[s];return e}const U=I(t=>t.uuid),_c=U.getInitialState({}),Yt=u.createSlice({name:"agents",initialState:_c,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,_c)),reducers:{initializeConversations:U.initialize,addConversation:U.addOne,addConversations:U.addMany,setConversation:U.setOne,setConversations:U.setMany,updateConversation:U.updateOne,updateConversations:U.updateMany,deleteConversation:U.deleteOne,deleteConversations:U.deleteMany}}),{initializeConversations:Oc,addConversation:Rc,addConversations:Hm,setConversation:vc,setConversations:Wm,updateConversation:wc,updateConversations:Km,deleteConversation:Ym,deleteConversations:Jm}=Yt.actions,Jt=t=>t.agentsReducer.instances,Zm=u.createSelector([Jt],t=>Object.values(t)),Xm=f(u.createSelector([Jt,(t,e)=>e],(t,e)=>t[e])),Mc=Yt.reducer,k=I(t=>t.uuid),Ec=k.getInitialState({}),Zt=u.createSlice({name:"assetAttachments",initialState:Ec,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Ec)),reducers:{initializeAssetAttachments:k.initialize,addAssetAttachment:k.addOne,addAssetAttachments:k.addMany,setAssetAttachment:k.setOne,setAssetAttachments:k.setMany,updateAssetAttachment:k.updateOne,updateAssetAttachments:k.updateMany,deleteAssetAttachment:k.deleteOne,deleteAssetAttachments:k.deleteMany}}),{initializeAssetAttachments:Xt,addAssetAttachment:Qm,addAssetAttachments:Qt,setAssetAttachment:jc,setAssetAttachments:xm,updateAssetAttachment:ep,updateAssetAttachments:qc,deleteAssetAttachment:Vc,deleteAssetAttachments:xt}=Zt.actions,zc=t=>t.assetAttachmentReducer.instances,Dc=u.createSelector([zc],t=>Object.values(t)),Cc=t=>e=>e.assetAttachmentReducer.instances[t],Uc=f(u.createSelector([Dc,(t,e)=>e],(t,e)=>g(t.filter(({asset:s})=>e===s)))),kc=Zt.reducer,B=I(t=>t.uuid),Bc=B.getInitialState({}),es=u.createSlice({name:"assetProcedureAttachments",initialState:Bc,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Bc)),reducers:{initializeAssetProcedureAttachments:B.initialize,addAssetProcedureAttachment:B.addOne,addAssetProcedureAttachments:B.addMany,setAssetProcedureAttachment:B.setOne,setAssetProcedureAttachments:B.setMany,updateAssetProcedureAttachment:B.updateOne,updateAssetProcedureAttachments:B.updateMany,deleteAssetProcedureAttachment:B.deleteOne,deleteAssetProcedureAttachments:B.deleteMany}}),{initializeAssetProcedureAttachments:$c,addAssetProcedureAttachment:tp,addAssetProcedureAttachments:Gc,setAssetProcedureAttachment:Lc,setAssetProcedureAttachments:sp,updateAssetProcedureAttachment:ap,updateAssetProcedureAttachments:Nc,deleteAssetProcedureAttachment:Hc,deleteAssetProcedureAttachments:Wc}=es.actions,Kc=t=>t.assetProcedureAttachmentReducer.instances,Yc=u.createSelector([Kc],t=>Object.values(t)),Jc=t=>e=>e.assetProcedureAttachmentReducer.instances[t],ip=f(u.createSelector([Yc,(t,e)=>e],(t,e)=>g(t.filter(({asset_procedure:s})=>e===s)))),Zc=es.reducer,$=I(t=>t.uuid),Xc=$.getInitialState({}),ts=u.createSlice({name:"assetProcedureFieldsAttachments",initialState:Xc,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Xc)),reducers:{initializeAssetProcedureFieldsAttachments:$.initialize,addAssetProcedureFieldsAttachment:$.addOne,addAssetProcedureFieldsAttachments:$.addMany,setAssetProcedureFieldsAttachment:$.setOne,setAssetProcedureFieldsAttachments:$.setMany,updateAssetProcedureFieldsAttachment:$.updateOne,updateAssetProcedureFieldsAttachments:$.updateMany,deleteAssetProcedureFieldsAttachment:$.deleteOne,deleteAssetProcedureFieldsAttachments:$.deleteMany}}),{initializeAssetProcedureFieldsAttachments:Qc,addAssetProcedureFieldsAttachment:cp,addAssetProcedureFieldsAttachments:xc,setAssetProcedureFieldsAttachment:np,setAssetProcedureFieldsAttachments:rp,updateAssetProcedureFieldsAttachment:dp,updateAssetProcedureFieldsAttachments:en,deleteAssetProcedureFieldsAttachment:up,deleteAssetProcedureFieldsAttachments:tn}=ts.actions,sn=t=>t.assetProcedureFieldsAttachmentReducer.instances,an=u.createSelector([sn],t=>Object.values(t)),op=f(u.createSelector([an,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),lp=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],cn=ts.reducer,G=I(t=>t.uuid),nn=G.getInitialState({}),ss=u.createSlice({name:"assetProcedureFields",initialState:nn,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,nn)),reducers:{initializeAssetProcedureFields:G.initialize,addAssetProcedureFields:G.addOne,addAssetProcedureFieldsMany:G.addMany,setAssetProcedureFields:G.setOne,setAssetProcedureFieldsMany:G.setMany,updateAssetProcedureFields:G.updateOne,updateAssetProcedureFieldsMany:G.updateMany,deleteAssetProcedureFields:G.deleteOne,deleteAssetProcedureFieldsMany:G.deleteMany}}),{initializeAssetProcedureFields:rn,addAssetProcedureFields:dn,addAssetProcedureFieldsMany:hp,setAssetProcedureFields:mp,setAssetProcedureFieldsMany:pp,updateAssetProcedureFields:un,updateAssetProcedureFieldsMany:Ap,deleteAssetProcedureFields:on,deleteAssetProcedureFieldsMany:yp}=ss.actions,ln=t=>t.assetProcedureFieldsReducer.instances,as=u.createSelector([ln],t=>Object.values(t)),fp=f(u.createSelector([as,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Sp=f(u.createSelector([as,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,i)=>s.submitted_at>i.submitted_at?-1:1)[0])),gp=t=>e=>e.assetProcedureFieldsReducer.instances[t],hn=ss.reducer,L=I(t=>t.uuid),mn=L.getInitialState({}),is=u.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:mn,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,mn)),reducers:{initializeAssetProcedureFieldValuesAttachments:L.initialize,addAssetProcedureFieldValuesAttachment:L.addOne,addAssetProcedureFieldValuesAttachments:L.addMany,setAssetProcedureFieldValuesAttachment:L.setOne,setAssetProcedureFieldValuesAttachments:L.setMany,updateAssetProcedureFieldValuesAttachment:L.updateOne,updateAssetProcedureFieldValuesAttachments:L.updateMany,deleteAssetProcedureFieldValuesAttachment:L.deleteOne,deleteAssetProcedureFieldValuesAttachments:L.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:pn,addAssetProcedureFieldValuesAttachment:bp,addAssetProcedureFieldValuesAttachments:mt,setAssetProcedureFieldValuesAttachment:Fp,setAssetProcedureFieldValuesAttachments:Pp,updateAssetProcedureFieldValuesAttachment:Tp,updateAssetProcedureFieldValuesAttachments:An,deleteAssetProcedureFieldValuesAttachment:Ip,deleteAssetProcedureFieldValuesAttachments:pt}=is.actions,cs=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,yn=u.createSelector([cs],t=>Object.values(t)),_p=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],fn=f(u.createSelector([cs,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),Sn=f(u.createSelector([yn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),gn=is.reducer,N=I(t=>t.uuid),bn=N.getInitialState({}),ns=u.createSlice({name:"assetProcedureFieldValues",initialState:bn,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,bn)),reducers:{initializeAssetProcedureFieldValues:N.initialize,addAssetProcedureFieldValues:N.addOne,addAssetProcedureFieldValuesMany:N.addMany,setAssetProcedureFieldValues:N.setOne,setAssetProcedureFieldValuesMany:N.setMany,updateAssetProcedureFieldValues:N.updateOne,updateAssetProcedureFieldValuesMany:N.updateMany,deleteAssetProcedureFieldValues:N.deleteOne,deleteAssetProcedureFieldValuesMany:N.deleteMany}}),{initializeAssetProcedureFieldValues:Fn,addAssetProcedureFieldValues:rs,addAssetProcedureFieldValuesMany:Pn,setAssetProcedureFieldValues:Op,setAssetProcedureFieldValuesMany:Rp,updateAssetProcedureFieldValues:Ze,updateAssetProcedureFieldValuesMany:Tn,deleteAssetProcedureFieldValues:ds,deleteAssetProcedureFieldValuesMany:In}=ns.actions,_n=t=>t.assetProcedureFieldValuesReducer.instances,us=u.createSelector([_n],t=>Object.values(t)),vp=f(u.createSelector([us,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),wp=f(u.createSelector([us,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),os=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],On=ns.reducer,H=I(t=>t.uuid),Rn=H.getInitialState({}),ls=u.createSlice({name:"assetProcedureInstances",initialState:Rn,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Rn)),reducers:{initializeAssetProcedureInstances:H.initialize,addAssetProcedureInstance:H.addOne,addAssetProcedureInstances:H.addMany,setAssetProcedureInstance:H.setOne,setAssetProcedureInstances:H.setMany,updateAssetProcedureInstance:H.updateOne,updateAssetProcedureInstances:H.updateMany,deleteAssetProcedureInstance:H.deleteOne,deleteAssetProcedureInstances:H.deleteMany}}),{initializeAssetProcedureInstances:vn,addAssetProcedureInstance:hs,addAssetProcedureInstances:wn,updateAssetProcedureInstance:Xe,updateAssetProcedureInstances:Mp,deleteAssetProcedureInstance:ms,deleteAssetProcedureInstances:Mn,setAssetProcedureInstance:Ep,setAssetProcedureInstances:jp}=ls.actions,ps=t=>t.assetProcedureInstanceReducer.instances,As=u.createSelector([ps],t=>Object.values(t)),En=f(u.createSelector([As,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),qp=f(u.createSelector([As,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ys=t=>e=>e.assetProcedureInstanceReducer.instances[t],Vp=f(u.createSelector([ps,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c&&s.push(c)}return g(s)})),jn=ls.reducer,W=I(t=>t.uuid),qn=W.getInitialState({}),fs=u.createSlice({name:"assetProcedures",initialState:qn,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,qn)),reducers:{initializeAssetProcedures:W.initialize,addAssetProcedure:W.addOne,addAssetProcedures:W.addMany,setAssetProcedure:W.setOne,setAssetProcedures:W.setMany,updateAssetProcedure:W.updateOne,updateAssetProcedures:W.updateMany,deleteAssetProcedure:W.deleteOne,deleteAssetProcedures:W.deleteMany}}),{initializeAssetProcedures:Vn,addAssetProcedure:Ss,addAssetProcedures:zp,updateAssetProcedure:Qe,updateAssetProcedures:Dp,deleteAssetProcedure:gs,deleteAssetProcedures:Cp,setAssetProcedure:Up,setAssetProcedures:kp}=fs.actions,bs=t=>t.assetProcedureReducer.instances,zn=u.createSelector([bs],t=>Object.values(t)),Fs=t=>e=>e.assetProcedureReducer.instances[t],Bp=f(u.createSelector([bs,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c&&s.push(c)}return g(s)})),$p=f(u.createSelector([zn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Dn=fs.reducer,K=I(t=>t.uuid),Cn=K.getInitialState({}),Ps=u.createSlice({name:"assetProcedureStepFieldsAttachments",initialState:Cn,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Cn)),reducers:{initializeAssetProcedureStepFieldsAttachments:K.initialize,addAssetProcedureStepFieldsAttachment:K.addOne,addAssetProcedureStepFieldsAttachments:K.addMany,setAssetProcedureStepFieldsAttachment:K.setOne,setAssetProcedureStepFieldsAttachments:K.setMany,updateAssetProcedureStepFieldsAttachment:K.updateOne,updateAssetProcedureStepFieldsAttachments:K.updateMany,deleteAssetProcedureStepFieldsAttachment:K.deleteOne,deleteAssetProcedureStepFieldsAttachments:K.deleteMany}}),{initializeAssetProcedureStepFieldsAttachments:Un,addAssetProcedureStepFieldsAttachment:Gp,addAssetProcedureStepFieldsAttachments:kn,setAssetProcedureStepFieldsAttachment:Lp,setAssetProcedureStepFieldsAttachments:Np,updateAssetProcedureStepFieldsAttachment:Hp,updateAssetProcedureStepFieldsAttachments:Bn,deleteAssetProcedureStepFieldsAttachment:Wp,deleteAssetProcedureStepFieldsAttachments:$n}=Ps.actions,Gn=t=>t.assetProcedureStepFieldsAttachmentReducer.instances,Ln=u.createSelector([Gn],t=>Object.values(t)),Kp=f(u.createSelector([Ln,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Yp=t=>e=>e.assetProcedureStepFieldsAttachmentReducer.instances[t],Nn=Ps.reducer,Y=I(t=>t.uuid),Hn=Y.getInitialState({}),Ts=u.createSlice({name:"assetProcedureStepFields",initialState:Hn,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Hn)),reducers:{initializeAssetProcedureStepFields:Y.initialize,addAssetProcedureStepFields:Y.addOne,addAssetProcedureStepFieldsMany:Y.addMany,setAssetProcedureStepFields:Y.setOne,setAssetProcedureStepFieldsMany:Y.setMany,updateAssetProcedureStepFields:Y.updateOne,updateAssetProcedureStepFieldsMany:Y.updateMany,deleteAssetProcedureStepFields:Y.deleteOne,deleteAssetProcedureStepFieldsMany:Y.deleteMany}}),{initializeAssetProcedureStepFields:Wn,addAssetProcedureStepFields:Is,addAssetProcedureStepFieldsMany:Jp,setAssetProcedureStepFields:Zp,setAssetProcedureStepFieldsMany:Xp,updateAssetProcedureStepFields:xe,updateAssetProcedureStepFieldsMany:Qp,deleteAssetProcedureStepFields:_s,deleteAssetProcedureStepFieldsMany:xp}=Ts.actions,Os=t=>t.assetProcedureStepFieldsReducer.instances,Rs=u.createSelector([Os],t=>Object.values(t)),eA=f(u.createSelector([Rs,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_step===e)))),tA=f(u.createSelector([Rs,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure_step===e).sort((s,i)=>s.submitted_at>i.submitted_at?-1:1)[0])),sA=u.createSelector([Os],t=>{const e={};for(const s of Object.values(t)){const i=e[s.asset_procedure_step];(!i||i.submitted_at<s.submitted_at)&&(e[s.asset_procedure_step]=s)}return e}),aA=t=>e=>e.assetProcedureStepFieldsReducer.instances[t],Kn=Ts.reducer,J=I(t=>t.uuid),Yn=J.getInitialState({}),vs=u.createSlice({name:"assetProcedureStepFieldValuesAttachments",initialState:Yn,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Yn)),reducers:{initializeAssetProcedureStepFieldValuesAttachments:J.initialize,addAssetProcedureStepFieldValuesAttachment:J.addOne,addAssetProcedureStepFieldValuesAttachments:J.addMany,setAssetProcedureStepFieldValuesAttachment:J.setOne,setAssetProcedureStepFieldValuesAttachments:J.setMany,updateAssetProcedureStepFieldValuesAttachment:J.updateOne,updateAssetProcedureStepFieldValuesAttachments:J.updateMany,deleteAssetProcedureStepFieldValuesAttachment:J.deleteOne,deleteAssetProcedureStepFieldValuesAttachments:J.deleteMany}}),{initializeAssetProcedureStepFieldValuesAttachments:Jn,addAssetProcedureStepFieldValuesAttachment:iA,addAssetProcedureStepFieldValuesAttachments:At,setAssetProcedureStepFieldValuesAttachment:cA,setAssetProcedureStepFieldValuesAttachments:nA,updateAssetProcedureStepFieldValuesAttachment:rA,updateAssetProcedureStepFieldValuesAttachments:Zn,deleteAssetProcedureStepFieldValuesAttachment:dA,deleteAssetProcedureStepFieldValuesAttachments:yt}=vs.actions,ws=t=>t.assetProcedureStepFieldValuesAttachmentReducer.instances,Xn=u.createSelector([ws],t=>Object.values(t)),uA=t=>e=>e.assetProcedureStepFieldValuesAttachmentReducer.instances[t],Qn=f(u.createSelector([ws,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),xn=f(u.createSelector([Xn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),er=vs.reducer,Z=I(t=>t.uuid),tr=Z.getInitialState({}),Ms=u.createSlice({name:"assetProcedureStepFieldValues",initialState:tr,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,tr)),reducers:{initializeAssetProcedureStepFieldValues:Z.initialize,addAssetProcedureStepFieldValues:Z.addOne,addAssetProcedureStepFieldValuesMany:Z.addMany,setAssetProcedureStepFieldValues:Z.setOne,setAssetProcedureStepFieldValuesMany:Z.setMany,updateAssetProcedureStepFieldValues:Z.updateOne,updateAssetProcedureStepFieldValuesMany:Z.updateMany,deleteAssetProcedureStepFieldValues:Z.deleteOne,deleteAssetProcedureStepFieldValuesMany:Z.deleteMany}}),{initializeAssetProcedureStepFieldValues:sr,addAssetProcedureStepFieldValues:Es,addAssetProcedureStepFieldValuesMany:ar,setAssetProcedureStepFieldValues:oA,setAssetProcedureStepFieldValuesMany:lA,updateAssetProcedureStepFieldValues:et,updateAssetProcedureStepFieldValuesMany:ir,deleteAssetProcedureStepFieldValues:js,deleteAssetProcedureStepFieldValuesMany:cr}=Ms.actions,nr=t=>t.assetProcedureStepFieldValuesReducer.instances,ft=u.createSelector([nr],t=>Object.values(t)),hA=f(u.createSelector([ft,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),mA=f(u.createSelector([ft,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),pA=f(u.createSelector([ft,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_step===e)))),qs=t=>e=>e.assetProcedureStepFieldValuesReducer.instances[t],rr=Ms.reducer,X=I(t=>t.uuid),dr=X.getInitialState({}),Vs=u.createSlice({name:"assetProcedureSteps",initialState:dr,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,dr)),reducers:{initializeAssetProcedureSteps:X.initialize,setAssetProcedureStep:X.setOne,setAssetProcedureSteps:X.setMany,addAssetProcedureStep:X.addOne,addAssetProcedureSteps:X.addMany,updateAssetProcedureStep:X.updateOne,updateAssetProcedureSteps:X.updateMany,deleteAssetProcedureStep:X.deleteOne,deleteAssetProcedureSteps:X.deleteMany}}),{initializeAssetProcedureSteps:ur,setAssetProcedureStep:or,setAssetProcedureSteps:AA,addAssetProcedureStep:yA,addAssetProcedureSteps:zs,updateAssetProcedureStep:Ds,updateAssetProcedureSteps:St,deleteAssetProcedureStep:fA,deleteAssetProcedureSteps:Cs}=Vs.actions,lr=Vs.reducer,gt=t=>t.assetProcedureStepReducer.instances,hr=t=>e=>e.assetProcedureStepReducer.instances[t],mr=u.createSelector([gt],t=>Object.values(t)),SA=f(u.createSelector([gt,(t,e)=>e],(t,e)=>{const s={};for(const[i,c]of Object.entries(t))c.asset_procedure===e&&(s[i]=c);return ht(s)})),gA=f(u.createSelector([mr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Us=f(u.createSelector([gt,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectAssetProcedureStepsByIds: No step exists with the id",i)}return g(s)})),Q=I(t=>t.uuid),pr=Q.getInitialState({}),ks=u.createSlice({name:"assets",initialState:pr,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,pr)),reducers:{initializeAssets:Q.initialize,addAsset:Q.addOne,addAssets:Q.addMany,setAsset:Q.setOne,setAssets:Q.setMany,updateAsset:Q.updateOne,updateAssets:Q.updateMany,deleteAsset:Q.deleteOne,deleteAssets:Q.deleteMany}}),{initializeAssets:Ar,addAsset:Bs,addAssets:bt,updateAsset:tt,updateAssets:bA,deleteAsset:$s,deleteAssets:Gs,setAsset:FA,setAssets:PA}=ks.actions,Ls=t=>t.assetReducer.instances,yr=u.createSelector([Ls],t=>g(Object.values(t))),Ns=f(u.createSelector([yr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),Hs=t=>e=>e.assetReducer.instances[t],fr=f(u.createSelector([Ls,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c&&s.push(c)}return g(s)})),TA=t=>e=>Ns(t)(e).length,Sr=ks.reducer,x=I(t=>t.uuid),gr=x.getInitialState({}),Ws=u.createSlice({name:"assetStageCompletions",initialState:gr,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,gr)),reducers:{initializeAssetStageCompletions:x.initialize,addAssetStageCompletion:x.addOne,addAssetStageCompletions:x.addMany,setAssetStageCompletion:x.setOne,setAssetStageCompletions:x.setMany,updateAssetStageCompletion:x.updateOne,updateAssetStageCompletions:x.updateMany,deleteAssetStageCompletion:x.deleteOne,deleteAssetStageCompletions:x.deleteMany}}),{initializeAssetStageCompletions:br,addAssetStageCompletion:Ks,addAssetStageCompletions:Ys,setAssetStageCompletion:IA,setAssetStageCompletions:_A,updateAssetStageCompletion:Fr,updateAssetStageCompletions:Pr,deleteAssetStageCompletion:Js,deleteAssetStageCompletions:Zs}=Ws.actions,Tr=Ws.reducer,Xs=t=>t.assetStageCompletionReducer.instances,OA=u.createSelector([Xs],t=>Object.values(t)),Ir=t=>e=>e.assetStageCompletionReducer.instances[t],_r=f(u.createSelector([Xs,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),ee=I(t=>t.uuid),Or=ee.getInitialState({}),Qs=u.createSlice({name:"assetStages",initialState:Or,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Or)),reducers:{initializeAssetStages:ee.initialize,setAssetStage:ee.setOne,setAssetStages:ee.setMany,addAssetStage:ee.addOne,addAssetStages:ee.addMany,updateAssetStage:ee.updateOne,updateAssetStages:ee.updateMany,deleteAssetStage:ee.deleteOne,deleteAssetStages:ee.deleteMany}}),{initializeAssetStages:Rr,setAssetStage:vr,setAssetStages:RA,addAssetStage:vA,addAssetStages:xs,updateAssetStage:ea,updateAssetStages:Ft,deleteAssetStage:wA,deleteAssetStages:ta}=Qs.actions,wr=Qs.reducer,Pt=t=>t.assetStageReducer.instances,Mr=t=>e=>e.assetStageReducer.instances[t],Er=u.createSelector([Pt],t=>Object.values(t)),MA=f(u.createSelector([Pt,(t,e)=>e],(t,e)=>{const s={};for(const[i,c]of Object.entries(t))c.asset_procedure===e&&(s[i]=c);return ht(s)})),EA=f(u.createSelector([Er,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),sa=f(u.createSelector([Pt,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectStagesFromStageIds: No stage exists with the id",i)}return g(s)})),te=I(t=>t.uuid),jr=te.getInitialState({}),aa=u.createSlice({name:"assetTypeAttachments",initialState:jr,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,jr)),reducers:{initializeAssetTypeAttachments:te.initialize,addAssetTypeAttachment:te.addOne,addAssetTypeAttachments:te.addMany,setAssetTypeAttachment:te.setOne,setAssetTypeAttachments:te.setMany,updateAssetTypeAttachment:te.updateOne,updateAssetTypeAttachments:te.updateMany,deleteAssetTypeAttachment:te.deleteOne,deleteAssetTypeAttachments:te.deleteMany}}),{initializeAssetTypeAttachments:qr,addAssetTypeAttachment:jA,addAssetTypeAttachments:ia,setAssetTypeAttachment:Vr,setAssetTypeAttachments:qA,updateAssetTypeAttachment:VA,updateAssetTypeAttachments:zr,deleteAssetTypeAttachment:Dr,deleteAssetTypeAttachments:ca}=aa.actions,Cr=t=>t.assetTypeAttachmentReducer.instances,Ur=u.createSelector([Cr],t=>Object.values(t)),kr=t=>e=>e.assetTypeAttachmentReducer.instances[t],Br=f(u.createSelector([Ur,(t,e)=>e],(t,e)=>g(t.filter(({asset_type:s})=>e===s)))),$r=aa.reducer,se=I(t=>t.uuid),Gr=se.getInitialState({}),na=u.createSlice({name:"assetTypeFieldsAttachments",initialState:Gr,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Gr)),reducers:{initializeAssetTypeFieldsAttachments:se.initialize,addAssetTypeFieldsAttachment:se.addOne,addAssetTypeFieldsAttachments:se.addMany,setAssetTypeFieldsAttachment:se.setOne,setAssetTypeFieldsAttachments:se.setMany,updateAssetTypeFieldsAttachment:se.updateOne,updateAssetTypeFieldsAttachments:se.updateMany,deleteAssetTypeFieldsAttachment:se.deleteOne,deleteAssetTypeFieldsAttachments:se.deleteMany}}),{initializeAssetTypeFieldsAttachments:Lr,addAssetTypeFieldsAttachment:zA,addAssetTypeFieldsAttachments:Nr,setAssetTypeFieldsAttachment:DA,setAssetTypeFieldsAttachments:CA,updateAssetTypeFieldsAttachment:UA,updateAssetTypeFieldsAttachments:Hr,deleteAssetTypeFieldsAttachment:kA,deleteAssetTypeFieldsAttachments:Wr}=na.actions,Kr=t=>t.assetTypeFieldsAttachmentReducer.instances,Yr=u.createSelector([Kr],t=>Object.values(t)),BA=f(u.createSelector([Yr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),$A=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Jr=na.reducer,ae=I(t=>t.uuid),Zr=ae.getInitialState({}),ra=u.createSlice({name:"assetTypeFields",initialState:Zr,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Zr)),reducers:{initializeAssetTypeFields:ae.initialize,addAssetTypeFields:ae.addOne,addAssetTypeFieldsMany:ae.addMany,setAssetTypeFields:ae.setOne,setAssetTypeFieldsMany:ae.setMany,updateAssetTypeFields:ae.updateOne,updateAssetTypeFieldsMany:ae.updateMany,deleteAssetTypeFields:ae.deleteOne,deleteAssetTypeFieldsMany:ae.deleteMany}}),{initializeAssetTypeFields:Xr,addAssetTypeFields:Qr,addAssetTypeFieldsMany:GA,setAssetTypeFields:LA,setAssetTypeFieldsMany:NA,updateAssetTypeFields:xr,updateAssetTypeFieldsMany:HA,deleteAssetTypeFields:ed,deleteAssetTypeFieldsMany:WA}=ra.actions,td=t=>t.assetTypeFieldsReducer.instances,Tt=u.createSelector([td],t=>Object.values(t)),KA=f(u.createSelector([Tt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),YA=f(u.createSelector([Tt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,i)=>s.submitted_at>i.submitted_at?-1:1)[0])),JA=t=>e=>e.assetTypeFieldsReducer.instances[t],sd=ra.reducer,ie=I(t=>t.uuid),ad=ie.getInitialState({}),da=u.createSlice({name:"assetTypeFieldValuesAttachments",initialState:ad,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,ad)),reducers:{initializeAssetTypeFieldValuesAttachments:ie.initialize,addAssetTypeFieldValuesAttachment:ie.addOne,addAssetTypeFieldValuesAttachments:ie.addMany,setAssetTypeFieldValuesAttachment:ie.setOne,setAssetTypeFieldValuesAttachments:ie.setMany,updateAssetTypeFieldValuesAttachment:ie.updateOne,updateAssetTypeFieldValuesAttachments:ie.updateMany,deleteAssetTypeFieldValuesAttachment:ie.deleteOne,deleteAssetTypeFieldValuesAttachments:ie.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:id,addAssetTypeFieldValuesAttachment:ZA,addAssetTypeFieldValuesAttachments:It,setAssetTypeFieldValuesAttachment:XA,setAssetTypeFieldValuesAttachments:QA,updateAssetTypeFieldValuesAttachment:xA,updateAssetTypeFieldValuesAttachments:cd,deleteAssetTypeFieldValuesAttachment:ey,deleteAssetTypeFieldValuesAttachments:_t}=da.actions,ua=t=>t.assetTypeFieldValuesAttachmentReducer.instances,nd=u.createSelector([ua],t=>Object.values(t)),ty=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],rd=f(u.createSelector([ua,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),dd=f(u.createSelector([nd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),ud=da.reducer,ce=I(t=>t.uuid),od=ce.getInitialState({}),oa=u.createSlice({name:"assetTypeFieldValues",initialState:od,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,od)),reducers:{initializeAssetTypeFieldValues:ce.initialize,addAssetTypeFieldValues:ce.addOne,addAssetTypeFieldValuesMany:ce.addMany,setAssetTypeFieldValues:ce.setOne,setAssetTypeFieldValuesMany:ce.setMany,updateAssetTypeFieldValues:ce.updateOne,updateAssetTypeFieldValuesMany:ce.updateMany,deleteAssetTypeFieldValues:ce.deleteOne,deleteAssetTypeFieldValuesMany:ce.deleteMany}}),{initializeAssetTypeFieldValues:ld,addAssetTypeFieldValues:la,addAssetTypeFieldValuesMany:hd,setAssetTypeFieldValues:sy,setAssetTypeFieldValuesMany:ay,updateAssetTypeFieldValues:st,updateAssetTypeFieldValuesMany:md,deleteAssetTypeFieldValues:ha,deleteAssetTypeFieldValuesMany:pd}=oa.actions,Ad=t=>t.assetTypeFieldValuesReducer.instances,ma=u.createSelector([Ad],t=>Object.values(t)),iy=f(u.createSelector([ma,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),cy=f(u.createSelector([Tt,ma,(t,e)=>e],(t,e,s)=>{const i=new Set(t.filter(c=>c.asset_type===s).map(c=>c.uuid));return g(e.filter(c=>i.has(c.fields_revision)))})),pa=t=>e=>e.assetTypeFieldValuesReducer.instances[t],yd=oa.reducer,ne=I(t=>t.uuid),fd=ne.getInitialState({}),Aa=u.createSlice({name:"assetTypes",initialState:fd,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,fd)),reducers:{initializeAssetTypes:ne.initialize,setAssetType:ne.setOne,setAssetTypes:ne.setMany,addAssetType:ne.addOne,addAssetTypes:ne.addMany,updateAssetType:ne.updateOne,updateAssetTypes:ne.updateMany,deleteAssetType:ne.deleteOne,deleteAssetTypes:ne.deleteMany}}),{initializeAssetTypes:Sd,setAssetType:ny,setAssetTypes:ry,addAssetType:ya,addAssetTypes:dy,updateAssetType:at,updateAssetTypes:uy,deleteAssetType:fa,deleteAssetTypes:oy}=Aa.actions,Sa=t=>t.assetTypeReducer.instances,gd=u.createSelector([Sa],t=>Object.values(t)),ga=t=>e=>e.assetTypeReducer.instances[t],ly=f(u.createSelector([Sa,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectAssetTypesByIds: No assetType exists with the id",i)}return g(s)})),hy=f(u.createSelector([gd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),bd=Aa.reducer,Fd={accessToken:"",refreshToken:"",isLoggedIn:!1},Ot=u.createSlice({name:"auth",initialState:Fd,extraReducers:t=>t.addCase(P,e=>Object.assign(e,Fd)),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||Ot.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:my,clearTokens:py,setLoggedIn:Pd}=Ot.actions,Ay=t=>t.authReducer.accessToken,yy=t=>t.authReducer.isLoggedIn,Td=Ot.reducer,re=I(t=>t.uuid),Id=re.getInitialState({}),ba=u.createSlice({name:"categories",initialState:Id,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Id)),reducers:{initializeCategories:re.initialize,addCategory:re.addOne,addCategories:re.addMany,setCategory:re.setOne,setCategories:re.setMany,updateCategory:re.updateOne,updateCategories:re.updateMany,deleteCategory:re.deleteOne,deleteCategories:re.deleteMany}}),{initializeCategories:_d,addCategory:Fa,addCategories:fy,setCategory:Sy,setCategories:gy,updateCategory:Od,updateCategories:by,deleteCategory:Rd,deleteCategories:Fy}=ba.actions,Pa=t=>t.categoryReducer.instances,vd=u.createSelector([Pa],t=>Object.values(t)),Ta=t=>e=>e.categoryReducer.instances[t],Py=f(u.createSelector([Pa,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectCategoryByIds: No category exists with the id",i)}return g(s)})),Ty=f(u.createSelector([vd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),wd=ba.reducer,de=I(t=>t.uuid),Md=de.getInitialState({}),Ia=u.createSlice({name:"documentAttachments",initialState:Md,extraReducers:t=>t.addCase(P,e=>Object.assign(e,Md)),reducers:{initializeDocumentAttachments:de.initialize,addDocumentAttachment:de.addOne,addDocumentAttachments:de.addMany,setDocumentAttachment:de.setOne,setDocumentAttachments:de.setMany,updateDocumentAttachment:de.updateOne,updateDocumentAttachments:de.updateMany,deleteDocumentAttachment:de.deleteOne,deleteDocumentAttachments:de.deleteMany}}),{initializeDocumentAttachments:Ed,addDocumentAttachment:Iy,addDocumentAttachments:jd,setDocumentAttachment:qd,setDocumentAttachments:_y,updateDocumentAttachment:Oy,updateDocumentAttachments:Vd,deleteDocumentAttachment:zd,deleteDocumentAttachments:Dd}=Ia.actions,Cd=t=>t.documentAttachmentReducer.instances,Ud=u.createSelector([Cd],t=>Object.values(t)),kd=t=>e=>e.documentAttachmentReducer.instances[t],Ry=f(u.createSelector([Ud,(t,e)=>e],(t,e)=>g(t.filter(({document:s})=>e===s)))),Bd=Ia.reducer,$d={documents:{}},_a=u.createSlice({name:"documents",initialState:$d,extraReducers:t=>t.addCase(P,e=>{Object.assign(e,$d)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(Ic).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Tc(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 i=t.documents[s.parent_document];t.documents[s.parent_document]={...i,children_documents:[...i.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 i=t.documents[s.uuid];if(s.organization!==void 0&&s.organization!==i.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==i.project)throw new Error("project cannot be updated");t.documents[s.uuid]={...i,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:i,position:c}=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 n=t.documents[s];if(n.parent_document&&t.documents[n.parent_document]){const{children_documents:r}=t.documents[n.parent_document];t.documents[n.parent_document].children_documents.splice(r.indexOf(n.uuid),1)}if(i){const r=t.documents[i],o=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(c){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,n.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,n.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[i].children_documents.unshift(n.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[i].children_documents.push(n.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 i=t.documents[s];if(i.parent_document&&t.documents[i.parent_document]){const c=t.documents[i.parent_document];t.documents[i.parent_document]={...c,children_documents:c.children_documents.filter(n=>n!==i.uuid)}}delete t.documents[s]}}}}),{setDocuments:Gd,addDocuments:Ld,updateDocuments:Ce,moveDocument:Nd,removeDocuments:Oa}=_a.actions,He=t=>t.documentsReducer.documents,Hd=u.createSelector([He],t=>Object.values(t)),Wd=t=>e=>e.documentsReducer.documents[t],vy=f(u.createSelector([He,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectDocumentByIds: No document exists with the id",i)}return g(s)})),wy=f(u.createSelector([He,(t,e)=>e],(t,e)=>{const s=[],i=t[e];if(!i||!i.parent_document)return s;let c=t[i.parent_document];for(;c;)s.push(c.uuid),c=t[c.parent_document??""];return g(s)})),My=u.createSelector([Hd],t=>g(t.filter(e=>!e.parent_document))),Kd=_a.reducer,ue=I(t=>t.uuid),Yd=ue.getInitialState({}),Ra=u.createSlice({name:"emailDomains",initialState:Yd,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Yd)),reducers:{initializeEmailDomains:ue.initialize,addEmailDomain:ue.addOne,addEmailDomains:ue.addMany,setEmailDomain:ue.setOne,setEmailDomains:ue.setMany,updateEmailDomain:ue.updateOne,updateEmailDomains:ue.updateMany,deleteEmailDomain:ue.deleteOne,deleteEmailDomains:ue.deleteMany}}),{initializeEmailDomains:Jd,addEmailDomain:Zd,addEmailDomains:Ey,setEmailDomain:jy,setEmailDomains:qy,updateEmailDomain:Vy,updateEmailDomains:zy,deleteEmailDomain:Xd,deleteEmailDomains:Dy}=Ra.actions,Qd=t=>t.emailDomainsReducer.instances,xd=u.createSelector([Qd],t=>Object.values(t)),Cy=f(u.createSelector([xd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),eu=Ra.reducer,tu={s3Urls:{}},su=1e3*60*60,Uy=su*24*7,va=u.createSlice({name:"file",initialState:tu,extraReducers:t=>t.addCase(P,e=>Object.assign(e,tu)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:i,sha1:c}=e.payload,n=new Date,r=new Date(n.getTime()+Uy);t.s3Urls[c]={url:s,fields:i,exp:r.getTime()}}}}),{setUploadUrl:au}=va.actions,iu=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const i=new Date().getTime();if(!((s.exp??i)-i<su))return s},cu=va.reducer,oe=I(t=>t.uuid),nu=oe.getInitialState({}),wa=u.createSlice({name:"formRevisionAttachments",initialState:nu,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,nu)),reducers:{initializeFormRevisionAttachments:oe.initialize,addFormRevisionAttachment:oe.addOne,addFormRevisionAttachments:oe.addMany,setFormRevisionAttachment:oe.setOne,setFormRevisionAttachments:oe.setMany,updateFormRevisionAttachment:oe.updateOne,updateFormRevisionAttachments:oe.updateMany,deleteFormRevisionAttachment:oe.deleteOne,deleteFormRevisionAttachments:oe.deleteMany}}),{initializeFormRevisionAttachments:ru,addFormRevisionAttachment:ky,addFormRevisionAttachments:du,setFormRevisionAttachment:By,setFormRevisionAttachments:$y,updateFormRevisionAttachment:Gy,updateFormRevisionAttachments:uu,deleteFormRevisionAttachment:Ly,deleteFormRevisionAttachments:ou}=wa.actions,lu=t=>t.formRevisionAttachmentReducer.instances,Ny=f(u.createSelector([lu,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_revision===e)))),hu=wa.reducer,Hy=(t,e)=>{const s=t.revision,i=e.revision;return s===void 0&&i===void 0?t.submitted_at<e.submitted_at?-1:1:s===void 0?1:i===void 0||s<i?-1:1},le=I(t=>t.uuid),mu=le.getInitialState({}),Ma=u.createSlice({name:"formRevisions",initialState:mu,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,mu)),reducers:{initializeFormRevisions:le.initialize,addFormRevision:le.addOne,addFormRevisions:le.addMany,setFormRevision:le.setOne,setFormRevisions:le.setMany,updateFormRevision:le.updateOne,updateFormRevisions:le.updateMany,deleteFormRevision:le.deleteOne,deleteFormRevisions:le.deleteMany}}),{initializeFormRevisions:pu,addFormRevision:Ea,addFormRevisions:Au,setFormRevision:yu,setFormRevisions:Wy,updateFormRevision:Ky,updateFormRevisions:Yy,deleteFormRevision:ja,deleteFormRevisions:fu}=Ma.actions,Rt=t=>t.formRevisionReducer.instances,Su=u.createSelector([Rt],t=>Object.values(t)),Jy=t=>e=>e.formRevisionReducer.instances[t],Zy=f(u.createSelector([Rt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(n=>n.form===e);if(s.length===0)return;const c=s.sort(Hy)[s.length-1];return t[c.uuid]})),gu=f(u.createSelector([Su,(t,e)=>e],(t,e)=>g(t.filter(s=>s.form===e)))),bu=Ma.reducer,he=I(t=>t.uuid),Fu=he.getInitialState({}),qa=u.createSlice({name:"forms",initialState:Fu,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Fu)),reducers:{initializeForms:he.initialize,addForm:he.addOne,addForms:he.addMany,setForm:he.setOne,setForms:he.setMany,updateForm:he.updateOne,updateForms:he.updateMany,deleteForm:he.deleteOne,deleteForms:he.deleteMany}}),{initializeForms:Pu,addForm:Va,addForms:Xy,setForm:Qy,setForms:xy,updateForm:ef,updateForms:tf,deleteForm:za,deleteForms:sf}=qa.actions,Tu=qa.reducer,Iu=t=>t.formReducer.instances,_u=u.createSelector([Iu],t=>Object.values(t)),Ou=t=>e=>e.formReducer.instances[t],af=f(u.createSelector([_u,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),me=I(t=>t.uuid),Ru=me.getInitialState({}),Da=u.createSlice({name:"formSubmissionAttachments",initialState:Ru,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Ru)),reducers:{initializeFormSubmissionAttachments:me.initialize,addFormSubmissionAttachment:me.addOne,addFormSubmissionAttachments:me.addMany,setFormSubmissionAttachment:me.setOne,setFormSubmissionAttachments:me.setMany,updateFormSubmissionAttachment:me.updateOne,updateFormSubmissionAttachments:me.updateMany,deleteFormSubmissionAttachment:me.deleteOne,deleteFormSubmissionAttachments:me.deleteMany}}),{initializeFormSubmissionAttachments:vu,addFormSubmissionAttachment:cf,addFormSubmissionAttachments:vt,setFormSubmissionAttachment:nf,setFormSubmissionAttachments:rf,updateFormSubmissionAttachment:df,updateFormSubmissionAttachments:wu,deleteFormSubmissionAttachment:uf,deleteFormSubmissionAttachments:wt}=Da.actions,Ca=t=>t.formSubmissionAttachmentReducer.instances,Mu=f(u.createSelector([Ca,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),Eu=f(u.createSelector([Ca,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_submission===e)))),ju=Da.reducer,pe=I(t=>t.uuid),qu=pe.getInitialState({}),Ua=u.createSlice({name:"formSubmissions",initialState:qu,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,qu)),reducers:{initializeFormSubmissions:pe.initialize,setFormSubmission:pe.setOne,setFormSubmissions:pe.setMany,addFormSubmission:pe.addOne,addFormSubmissions:pe.addMany,updateFormSubmission:pe.updateOne,updateFormSubmissions:pe.updateMany,deleteFormSubmission:pe.deleteOne,deleteFormSubmissions:pe.deleteMany}}),{initializeFormSubmissions:Vu,setFormSubmission:Mt,setFormSubmissions:of,addFormSubmission:ka,addFormSubmissions:Et,updateFormSubmission:zu,updateFormSubmissions:lf,deleteFormSubmission:Ba,deleteFormSubmissions:jt}=Ua.actions,$a=t=>t.formSubmissionReducer.instances,Ga=u.createSelector([$a],t=>Object.values(t)),La=t=>e=>e.formSubmissionReducer.instances[t],Du=f(u.createSelector([$a,Rt,(t,e)=>e],(t,e,s)=>{const i=new Set;for(const c of Object.values(e))c.form===s&&i.add(c.uuid);return Object.values(t).filter(c=>i.has(c.form_revision))})),Cu=f(u.createSelector([Ga,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),Uu=f(u.createSelector([Ga,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),ku=Ua.reducer,Ae=I(t=>t.uuid),Bu=Ae.getInitialState({}),Na=u.createSlice({name:"geoImages",initialState:Bu,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Bu)),reducers:{initializeGeoImages:Ae.initialize,setGeoImage:Ae.setOne,setGeoImages:Ae.setMany,addGeoImage:Ae.addOne,addGeoImages:Ae.addMany,updateGeoImage:Ae.updateOne,updateGeoImages:Ae.updateMany,deleteGeoImage:Ae.deleteOne,deleteGeoImages:Ae.deleteMany}}),{initializeGeoImages:$u,setGeoImage:it,setGeoImages:Gu,addGeoImage:Lu,addGeoImages:Nu,updateGeoImage:Hu,updateGeoImages:hf,deleteGeoImage:Ha,deleteGeoImages:Wu}=Na.actions,Ku=t=>t.geoImageReducer.instances,Yu=u.createSelector([Ku],t=>Object.values(t)),Wa=t=>e=>e.geoImageReducer.instances[t],mf=f(u.createSelector([Yu,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),Ju=Na.reducer,ye=I(t=>t.uuid),Zu=ye.getInitialState({}),Ka=u.createSlice({name:"issueAssociations",initialState:Zu,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Zu)),reducers:{initializeIssueAssociations:ye.initialize,addIssueAssociation:ye.addOne,addIssueAssociations:ye.addMany,setIssueAssociation:ye.setOne,setIssueAssociations:ye.setMany,updateIssueAssociation:ye.updateOne,updateIssueAssociations:ye.updateMany,deleteIssueAssociation:ye.deleteOne,deleteIssueAssociations:ye.deleteMany}}),{initializeIssueAssociations:Xu,setIssueAssociations:pf,setIssueAssociation:Af,updateIssueAssociation:Qu,updateIssueAssociations:yf,addIssueAssociation:Ya,addIssueAssociations:Ja,deleteIssueAssociation:Za,deleteIssueAssociations:Xa}=Ka.actions,ct=t=>t.issueAssociationReducer.instances,ff=u.createSelector([ct],t=>Object.values(t)),xu=t=>e=>e.issueAssociationReducer.instances[t],eo=f(u.createSelector([ct,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.associated_issue===e)))),to=f(u.createSelector([ct,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),so=f(u.createSelector([ct,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.asset===e)))),ao=Ka.reducer,fe=I(t=>t.uuid),io=fe.getInitialState({}),Qa=u.createSlice({name:"issueAttachments",initialState:io,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,io)),reducers:{initializeIssueAttachments:fe.initialize,addIssueAttachment:fe.addOne,addIssueAttachments:fe.addMany,setIssueAttachment:fe.setOne,setIssueAttachments:fe.setMany,updateIssueAttachment:fe.updateOne,updateIssueAttachments:fe.updateMany,deleteIssueAttachment:fe.deleteOne,deleteIssueAttachments:fe.deleteMany}}),{initializeIssueAttachments:xa,addIssueAttachment:Sf,addIssueAttachments:ei,setIssueAttachment:co,setIssueAttachments:gf,updateIssueAttachment:bf,updateIssueAttachments:no,deleteIssueAttachment:ro,deleteIssueAttachments:ti}=Qa.actions,uo=t=>t.issueAttachmentReducer.instances,oo=u.createSelector([uo],t=>Object.values(t)),lo=f(u.createSelector([oo,(t,e)=>e],(t,e)=>g(t.filter(({issue:s})=>e===s)))),ho=t=>e=>e.issueAttachmentReducer.instances[t],mo=Qa.reducer,Se=I(t=>t.uuid),po=Se.getInitialState({}),si=u.createSlice({name:"issueCommentAttachments",initialState:po,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,po)),reducers:{initializeIssueCommentAttachments:Se.initialize,addIssueCommentAttachment:Se.addOne,addIssueCommentAttachments:Se.addMany,setIssueCommentAttachment:Se.setOne,setIssueCommentAttachments:Se.setMany,updateIssueCommentAttachment:Se.updateOne,updateIssueCommentAttachments:Se.updateMany,deleteIssueCommentAttachment:Se.deleteOne,deleteIssueCommentAttachments:Se.deleteMany}}),{initializeIssueCommentAttachments:ai,addIssueCommentAttachment:Ff,addIssueCommentAttachments:Ao,setIssueCommentAttachment:yo,setIssueCommentAttachments:Pf,updateIssueCommentAttachment:Tf,updateIssueCommentAttachments:fo,deleteIssueCommentAttachment:So,deleteIssueCommentAttachments:go}=si.actions,bo=t=>t.issueCommentAttachmentReducer.instances,Fo=u.createSelector([bo],t=>Object.values(t)),Po=t=>e=>e.issueCommentAttachmentReducer.instances[t],If=f(u.createSelector([Fo,(t,e)=>e],(t,e)=>g(t.filter(({issue_comment:s})=>e===s)))),To=si.reducer,ge=I(t=>t.uuid),Io=ge.getInitialState({}),ii=u.createSlice({name:"issueComments",initialState:Io,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Io)),reducers:{initializeIssueComments:ge.initialize,addIssueComment:ge.addOne,addIssueComments:ge.addMany,setIssueComment:ge.setOne,setIssueComments:ge.setMany,updateIssueComment:ge.updateOne,updateIssueComments:ge.updateMany,deleteIssueComment:ge.deleteOne,deleteIssueComments:ge.deleteMany}}),{initializeIssueComments:_f,addIssueComment:ci,addIssueComments:Of,setIssueComment:ni,setIssueComments:_o,updateIssueComment:Rf,updateIssueComments:vf,deleteIssueComment:ri,deleteIssueComments:wf}=ii.actions,Oo=t=>t.issueCommentReducer.instances,di=t=>e=>e.issueCommentReducer.instances[t],Mf=f(u.createSelector([Oo,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Ro=ii.reducer,be=I(t=>t.uuid),vo=be.getInitialState({}),ui=u.createSlice({name:"issues",initialState:vo,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,vo)),reducers:{initializeIssues:be.initialize,addIssue:be.addOne,addIssues:be.addMany,setIssue:be.setOne,setIssues:be.setMany,updateIssue:be.updateOne,updateIssues:be.updateMany,deleteIssue:be.deleteOne,deleteIssues:be.deleteMany}}),{initializeIssues:wo,addIssue:oi,addIssues:Mo,setIssue:Ef,setIssues:jf,updateIssue:qt,updateIssues:qf,deleteIssue:li,deleteIssues:Eo}=ui.actions,hi=t=>t.issueReducer.instances,Vf=u.createSelector([hi],t=>Object.values(t)),mi=t=>e=>e.issueReducer.instances[t],zf=f(u.createSelector([hi,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectIssuesByIds: No issue exists with the id",i)}return g(s)})),jo=ui.reducer,Fe=I(t=>t.uuid),qo=Fe.getInitialState({}),pi=u.createSlice({name:"issueTypeAttachments",initialState:qo,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,qo)),reducers:{initializeIssueTypeAttachments:Fe.initialize,addIssueTypeAttachment:Fe.addOne,addIssueTypeAttachments:Fe.addMany,setIssueTypeAttachment:Fe.setOne,setIssueTypeAttachments:Fe.setMany,updateIssueTypeAttachment:Fe.updateOne,updateIssueTypeAttachments:Fe.updateMany,deleteIssueTypeAttachment:Fe.deleteOne,deleteIssueTypeAttachments:Fe.deleteMany}}),{initializeIssueTypeAttachments:Ai,addIssueTypeAttachment:Df,addIssueTypeAttachments:Vo,setIssueTypeAttachment:zo,setIssueTypeAttachments:Cf,updateIssueTypeAttachment:Uf,updateIssueTypeAttachments:Do,deleteIssueTypeAttachment:Co,deleteIssueTypeAttachments:Uo}=pi.actions,ko=t=>t.issueTypeAttachmentReducer.instances,Bo=u.createSelector([ko],t=>Object.values(t)),$o=t=>e=>e.issueTypeAttachmentReducer.instances[t],kf=f(u.createSelector([Bo,(t,e)=>e],(t,e)=>g(t.filter(({issue_type:s})=>e===s)))),Go=pi.reducer,Pe=I(t=>t.uuid),Lo=Pe.getInitialState({}),yi=u.createSlice({name:"issueTypeFieldsAttachments",initialState:Lo,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Lo)),reducers:{initializeIssueTypeFieldsAttachments:Pe.initialize,addIssueTypeFieldsAttachment:Pe.addOne,addIssueTypeFieldsAttachments:Pe.addMany,setIssueTypeFieldsAttachment:Pe.setOne,setIssueTypeFieldsAttachments:Pe.setMany,updateIssueTypeFieldsAttachment:Pe.updateOne,updateIssueTypeFieldsAttachments:Pe.updateMany,deleteIssueTypeFieldsAttachment:Pe.deleteOne,deleteIssueTypeFieldsAttachments:Pe.deleteMany}}),{initializeIssueTypeFieldsAttachments:No,addIssueTypeFieldsAttachment:Bf,addIssueTypeFieldsAttachments:Ho,setIssueTypeFieldsAttachment:$f,setIssueTypeFieldsAttachments:Gf,updateIssueTypeFieldsAttachment:Lf,updateIssueTypeFieldsAttachments:Wo,deleteIssueTypeFieldsAttachment:Nf,deleteIssueTypeFieldsAttachments:Ko}=yi.actions,Yo=t=>t.issueTypeFieldsAttachmentReducer.instances,Jo=u.createSelector([Yo],t=>Object.values(t)),Hf=f(u.createSelector([Jo,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Wf=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],Zo=yi.reducer,Te=I(t=>t.uuid),Xo=Te.getInitialState({}),fi=u.createSlice({name:"issueTypeFieldValues",initialState:Xo,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Xo)),reducers:{initializeIssueTypeFieldValues:Te.initialize,addIssueTypeFieldValues:Te.addOne,addIssueTypeFieldValuesMany:Te.addMany,setIssueTypeFieldValues:Te.setOne,setIssueTypeFieldValuesMany:Te.setMany,updateIssueTypeFieldValues:Te.updateOne,updateIssueTypeFieldValuesMany:Te.updateMany,deleteIssueTypeFieldValues:Te.deleteOne,deleteIssueTypeFieldValuesMany:Te.deleteMany}}),{initializeIssueTypeFieldValues:Qo,addIssueTypeFieldValues:Si,addIssueTypeFieldValuesMany:Kf,setIssueTypeFieldValues:Yf,setIssueTypeFieldValuesMany:Jf,updateIssueTypeFieldValues:nt,updateIssueTypeFieldValuesMany:Zf,deleteIssueTypeFieldValues:gi,deleteIssueTypeFieldValuesMany:Xf}=fi.actions,xo=t=>t.issueTypeFieldValuesReducer.instances,bi=u.createSelector([xo],t=>Object.values(t)),Qf=f(u.createSelector([bi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue===e)))),Fi=t=>e=>e.issueTypeFieldValuesReducer.instances[t],el=fi.reducer,Ie=I(t=>t.uuid),tl=Ie.getInitialState({}),Pi=u.createSlice({name:"issueTypeFields",initialState:tl,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,tl)),reducers:{initializeIssueTypeFields:Ie.initialize,addIssueTypeFields:Ie.addOne,addIssueTypeFieldsMany:Ie.addMany,setIssueTypeFields:Ie.setOne,setIssueTypeFieldsMany:Ie.setMany,updateIssueTypeFields:Ie.updateOne,updateIssueTypeFieldsMany:Ie.updateMany,deleteIssueTypeFields:Ie.deleteOne,deleteIssueTypeFieldsMany:Ie.deleteMany}}),{initializeIssueTypeFields:sl,addIssueTypeFields:al,addIssueTypeFieldsMany:xf,setIssueTypeFields:eS,setIssueTypeFieldsMany:tS,updateIssueTypeFields:il,updateIssueTypeFieldsMany:sS,deleteIssueTypeFields:cl,deleteIssueTypeFieldsMany:aS}=Pi.actions,nl=t=>t.issueTypeFieldsReducer.instances,Vt=u.createSelector([nl],t=>Object.values(t)),iS=f(u.createSelector([Vt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue_type===e)))),cS=f(u.createSelector([Vt,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,i)=>s.submitted_at>i.submitted_at?-1:1)[0])),nS=f(u.createSelector([Vt,bi,(t,e)=>e],(t,e,s)=>{const i=new Set(t.filter(c=>c.issue_type===s).map(c=>c.uuid));return g(e.filter(c=>i.has(c.fields_revision)))})),rS=t=>e=>e.issueTypeFieldsReducer.instances[t],rl=Pi.reducer,_e=I(t=>t.uuid),dl=_e.getInitialState({}),Ti=u.createSlice({name:"issueTypeFieldValuesAttachments",initialState:dl,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,dl)),reducers:{initializeIssueTypeFieldValuesAttachments:_e.initialize,addIssueTypeFieldValuesAttachment:_e.addOne,addIssueTypeFieldValuesAttachments:_e.addMany,setIssueTypeFieldValuesAttachment:_e.setOne,setIssueTypeFieldValuesAttachments:_e.setMany,updateIssueTypeFieldValuesAttachment:_e.updateOne,updateIssueTypeFieldValuesAttachments:_e.updateMany,deleteIssueTypeFieldValuesAttachment:_e.deleteOne,deleteIssueTypeFieldValuesAttachments:_e.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:ul,addIssueTypeFieldValuesAttachment:dS,addIssueTypeFieldValuesAttachments:zt,setIssueTypeFieldValuesAttachment:uS,setIssueTypeFieldValuesAttachments:oS,updateIssueTypeFieldValuesAttachment:lS,updateIssueTypeFieldValuesAttachments:ol,deleteIssueTypeFieldValuesAttachment:hS,deleteIssueTypeFieldValuesAttachments:Dt}=Ti.actions,Ii=t=>t.issueTypeFieldValuesAttachmentReducer.instances,ll=u.createSelector([Ii],t=>Object.values(t)),mS=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],hl=f(u.createSelector([Ii,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),ml=f(u.createSelector([ll,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),pl=Ti.reducer,C=I(t=>t.uuid),Al=C.getInitialState({}),_i=u.createSlice({name:"issueTypes",initialState:Al,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Al)),reducers:{initializeIssueTypes:C.initialize,addIssueType:C.addOne,addIssueTypes:C.addMany,setIssueType:C.setOne,setIssueTypes:C.setMany,updateIssueType:C.updateOne,updateIssueTypes:C.updateMany,deleteIssueType:C.deleteOne,deleteIssueTypes:C.deleteMany,removeIssueType:C.deleteOne}}),{initializeIssueTypes:yl,addIssueType:fl,addIssueTypes:pS,setIssueType:rt,setIssueTypes:AS,updateIssueType:Sl,updateIssueTypes:yS,deleteIssueType:fS,deleteIssueTypes:SS,removeIssueType:Oi}=_i.actions,gl=t=>t.issueTypeReducer.instances,bl=u.createSelector(gl,t=>Object.values(t)),Ri=t=>e=>e.issueTypeReducer.instances[t],gS=t=>e=>{const s=[];for(const i of t){const c=e.issueTypeReducer.instances[i];c?s.push(c):console.warn("selectIssueTypesByIds: No issue type exists with the id",i)}return s},bS=f(u.createSelector([bl,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),vi=f(u.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue_type===e)))),FS=t=>e=>vi(t)(e).length,Fl=_i.reducer,Oe=I(t=>t.uuid),Pl=Oe.getInitialState({}),wi=u.createSlice({name:"issueUpdates",initialState:Pl,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Pl)),reducers:{initializeIssueUpdates:Oe.initialize,addIssueUpdate:Oe.addOne,addIssueUpdates:Oe.addMany,setIssueUpdate:Oe.setOne,setIssueUpdates:Oe.setMany,updateIssueUpdate:Oe.updateOne,updateIssueUpdates:Oe.updateMany,deleteIssueUpdate:Oe.deleteOne,deleteIssueUpdates:Oe.deleteMany}}),{initializeIssueUpdates:Tl,addIssueUpdate:Il,addIssueUpdates:_l,setIssueUpdate:PS,setIssueUpdates:TS,updateIssueUpdate:IS,updateIssueUpdates:_S,deleteIssueUpdate:Ol,deleteIssueUpdates:Rl}=wi.actions,vl=t=>t.issueUpdateReducer.instances,wl=f(u.createSelector([vl,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Ml=wi.reducer,Re=I(t=>t.id),El=Re.getInitialState({currentUser:null}),Mi=u.createSlice({name:"users",initialState:El,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,El)),reducers:{initializeUsers:Re.initialize,setUsers:Re.setMany,setUser:Re.setOne,addUsers:Re.addMany,addUser:Re.addOne,updateUsers:Re.updateMany,updateUser:Re.updateOne,deleteUser:Re.deleteOne,deleteUsers:Re.deleteMany,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:jl,setUsers:OS,setUser:RS,addUsers:vS,addUser:ql,updateUsers:wS,updateUser:MS,deleteUser:Vl,deleteUsers:ES,setCurrentUser:jS,setProfilePicture:qS}=Mi.actions,zl=Mi.reducer,Dl=t=>t.userReducer.currentUser,Ct=t=>t.userReducer.instances,Ei=u.createSelector([Ct],t=>Object.values(t)),Cl=t=>e=>e.userReducer.instances[t],VS=f(u.createSelector([Ct,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectUsersByIds: No user exists with the uuid",i)}return g(s)})),ve=I(t=>t.uuid),Ul=ve.getInitialState({}),ji=u.createSlice({name:"organizationAccess",initialState:Ul,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Ul)),reducers:{initializeOrganizationAccesses:ve.initialize,addOrganizationAccess:ve.addOne,addOrganizationAccesses:ve.addMany,setOrganizationAccess:ve.setOne,setOrganizationAccesses:ve.setMany,updateOrganizationAccess:ve.updateOne,updateOrganizationAccesses:ve.updateMany,deleteOrganizationAccess:ve.deleteOne,deleteOrganizationAccesses:ve.deleteMany}}),{initializeOrganizationAccesses:kl,addOrganizationAccess:Bl,addOrganizationAccesses:zS,setOrganizationAccess:DS,setOrganizationAccesses:CS,updateOrganizationAccess:Ut,updateOrganizationAccesses:US,deleteOrganizationAccess:$l,deleteOrganizationAccesses:kS}=ji.actions,Gl=ji.reducer,qi=t=>t.organizationAccessReducer.instances,Vi=t=>e=>e.organizationAccessReducer.instances[t],BS=u.createSelector([Dl,qi],(t,e)=>Object.values(e).find(i=>i.user===(t==null?void 0:t.id))??null),Ll=u.createSelector([qi],t=>{const e={};for(const s of Object.values(t))e[s.user]=s;return ht(e)}),$S=f(u.createSelector([Ct,Ll,(t,e)=>e],(t,e,s)=>g(Object.values(t).filter(i=>{const c=e[i.id];return!!c&&c.organization===s})))),we=I(t=>t.uuid),Nl=we.getInitialState({}),zi=u.createSlice({name:"organizations",initialState:Nl,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Nl)),reducers:{initializeOrganizations:we.initialize,setOrganizations:we.setMany,setOrganization:we.setOne,addOrganizations:we.addMany,addOrganization:we.addOne,updateOrganizations:we.updateMany,updateOrganization:we.updateOne,deleteOrganization:we.deleteOne,deleteOrganizations:we.deleteMany}}),{initializeOrganizations:GS,setOrganizations:Hl,setOrganization:LS,addOrganizations:NS,addOrganization:HS,updateOrganizations:WS,updateOrganization:KS,deleteOrganization:YS,deleteOrganizations:JS}=zi.actions,Wl=t=>t.organizationReducer.instances,ZS=u.createSelector([Wl],t=>Object.values(t)),XS=t=>e=>e.organizationReducer.instances[t],Kl=zi.reducer,Yl=(t,e,s)=>{const i=t.uuid?t:{...t,uuid:Le.v4()};return{payload:i,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:i,BASE_URL:e,serviceName:s}}}}},Jl={deletedRequests:[],latestRetryTime:0},Di=u.createSlice({name:"outbox",initialState:Jl,extraReducers:t=>t.addCase(P,e=>Object.assign(e,Jl)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...i}=t;return Yl(i,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}}}),QS=t=>t.outboxReducer.deletedRequests,xS=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Zl,markForDeletion:eg,markAsDeleted:Xl,_setLatestRetryTime:Ql}=Di.actions,xl=Di.reducer,Me=I(t=>t.uuid),eh=Me.getInitialState({}),Ci=u.createSlice({name:"projectAccess",initialState:eh,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,eh)),reducers:{initializeProjectAccesses:Me.initialize,addProjectAccess:Me.addOne,addProjectAccesses:Me.addMany,setProjectAccess:Me.setOne,setProjectAccesses:Me.setMany,updateProjectAccess:Me.updateOne,updateProjectAccesses:Me.updateMany,deleteProjectAccess:Me.deleteOne,deleteProjectAccesses:Me.deleteMany}}),{initializeProjectAccesses:th,addProjectAccess:Ui,addProjectAccesses:sh,setProjectAccess:tg,setProjectAccesses:sg,updateProjectAccess:dt,updateProjectAccesses:ag,deleteProjectAccess:ki,deleteProjectAccesses:ah}=Ci.actions,ih=Ci.reducer,Bi=t=>t.projectAccessReducer.instances,kt=u.createSelector(Bi,t=>Object.values(t)),$i=t=>e=>e.projectAccessReducer.instances[t],ch=f(u.createSelector([Bi,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.project===e)))),ig=f(u.createSelector([kt,(t,e)=>e],(t,e)=>{const s={};for(const i of t.filter(c=>c.project===e))s[i.user]=i;return s})),cg=f(u.createSelector([Ei,kt,(t,e)=>e],(t,e,s)=>{const i=new Set(e.filter(c=>c.project===s).map(c=>c.user));return g(t.filter(c=>i.has(c.id)))})),Ee=I(t=>t.uuid),nh=Ee.getInitialState({}),Gi=u.createSlice({name:"projectAttachments",initialState:nh,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,nh)),reducers:{initializeProjectAttachments:Ee.initialize,addProjectAttachment:Ee.addOne,addProjectAttachments:Ee.addMany,setProjectAttachment:Ee.setOne,setProjectAttachments:Ee.setMany,updateProjectAttachment:Ee.updateOne,updateProjectAttachments:Ee.updateMany,deleteProjectAttachment:Ee.deleteOne,deleteProjectAttachments:Ee.deleteMany}}),{initializeProjectAttachments:rh,addProjectAttachment:ng,addProjectAttachments:dh,setProjectAttachment:uh,setProjectAttachments:oh,updateProjectAttachment:rg,updateProjectAttachments:lh,deleteProjectAttachment:hh,deleteProjectAttachments:Li}=Gi.actions,mh=t=>t.projectAttachmentReducer.instances,ph=u.createSelector([mh],t=>Object.values(t)),Ah=t=>e=>e.projectAttachmentReducer.instances[t],yh=f(u.createSelector([ph,(t,e)=>e],(t,e)=>g(t.filter(({project:s})=>e===s)))),fh=Gi.reducer,je=I(t=>t.uuid),Sh=je.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),Ni=u.createSlice({name:"projectFiles",initialState:Sh,extraReducers:t=>t.addMatcher(u.isAnyOf(P,M,O),e=>Object.assign(e,Sh)),reducers:{initializeProjectFiles:je.initialize,setProjectFile:je.setOne,setProjectFiles:je.setMany,addProjectFile:je.addOne,addProjectFiles:je.addMany,updateProjectFile:je.updateOne,updateProjectFiles:je.updateMany,deleteProjectFile:je.deleteOne,deleteProjectFiles:je.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:gh,setProjectFile:dg,setProjectFiles:ug,addProjectFile:og,addProjectFiles:bh,updateProjectFile:Hi,updateProjectFiles:lg,deleteProjectFile:Fh,deleteProjectFiles:Ph,setIsImportingProjectFile:Th,setActiveProjectFileId:Ih,saveActiveProjectFileBounds:_h,resetProjectFileObjectUrls:hg}=Ni.actions,Oh=t=>t.projectFileReducer.instances,Rh=u.createSelector([Oh],t=>g(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),mg=t=>e=>e.projectFileReducer.instances[t],pg=t=>t.projectFileReducer.activeProjectFileId,Ag=t=>t.projectFileReducer.isImportingProjectFile,vh=Ni.reducer,qe=I(t=>t.uuid),wh=qe.getInitialState({}),Wi=u.createSlice({name:"projects",initialState:wh,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,wh)),reducers:{initializeProjects:qe.initialize,setProjects:qe.setMany,setProject:qe.setOne,addProjects:qe.addMany,addProject:qe.addOne,updateProjects:qe.updateMany,updateProject:qe.updateOne,deleteProject:qe.deleteOne,deleteProjects:qe.deleteMany}}),{initializeProjects:Mh,setProjects:yg,setProject:fg,addProjects:Sg,addProject:Eh,updateProjects:gg,updateProject:jh,deleteProject:Ki,deleteProjects:bg}=Wi.actions,qh=Wi.reducer,Vh=t=>t.projectReducer.instances,Yi=u.createSelector([Vh],t=>g(Object.values(t))),zh=t=>e=>e.projectReducer.instances[t],Fg=f(u.createSelector([Yi,kt,(t,e)=>e],(t,e,s)=>{const i=new Set(e.filter(c=>c.user===s).map(c=>c.project));return g(t.filter(c=>i.has(c.uuid)))})),Pg=f(u.createSelector([Yi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization_owner===e)))),Tg={isRehydrated:!1},Ji=u.createSlice({name:"rehydrated",initialState:Tg,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:Ig}=Ji.actions,_g=t=>t.rehydratedReducer.isRehydrated,Dh=Ji.reducer,Ve=I(t=>t.uuid),Ch=Ve.getInitialState({}),Zi=u.createSlice({name:"teamMemberships",initialState:Ch,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Ch)),reducers:{initializeTeamMemberships:Ve.initialize,addTeamMembership:Ve.addOne,addTeamMemberships:Ve.addMany,setTeamMembership:Ve.setOne,setTeamMemberships:Ve.setMany,updateTeamMembership:Ve.updateOne,updateTeamMemberships:Ve.updateMany,deleteTeamMembership:Ve.deleteOne,deleteTeamMemberships:Ve.deleteMany}}),{initializeTeamMemberships:Uh,addTeamMembership:kh,addTeamMemberships:Og,setTeamMembership:Xi,setTeamMemberships:Rg,updateTeamMembership:vg,updateTeamMemberships:wg,deleteTeamMembership:Qi,deleteTeamMemberships:Mg}=Zi.actions,Bh=Zi.reducer,$h=t=>t.teamMembershipReducer.instances,xi=u.createSelector([$h],t=>Object.values(t)),Gh=t=>e=>e.teamMembershipReducer.instances[t],Eg=f(u.createSelector([xi,(t,e)=>e],(t,e)=>{const s={};for(const i of t.filter(c=>c.team===e))s[i.user]=i;return s})),jg=f(u.createSelector([Ei,xi,(t,e)=>e],(t,e,s)=>{const i=new Set(e.filter(c=>c.team===s).map(c=>c.user));return g(t.filter(c=>i.has(c.id)))})),ze=I(t=>t.uuid),Lh=ze.getInitialState({}),ec=u.createSlice({name:"teams",initialState:Lh,extraReducers:t=>t.addMatcher(u.isAnyOf(P,O),e=>Object.assign(e,Lh)),reducers:{initializeTeams:ze.initialize,addTeam:ze.addOne,addTeams:ze.addMany,setTeam:ze.setOne,setTeams:ze.setMany,updateTeam:ze.updateOne,updateTeams:ze.updateMany,deleteTeam:ze.deleteOne,deleteTeams:ze.deleteMany}}),{initializeTeams:Nh,addTeam:Hh,addTeams:qg,setTeam:ut,setTeams:Vg,updateTeam:Wh,updateTeams:zg,deleteTeam:tc,deleteTeams:Dg}=ec.actions,sc=t=>t.teamReducer.instances,Kh=u.createSelector([sc],t=>Object.values(t)),ac=t=>e=>e.teamReducer.instances[t],Cg=f(u.createSelector([sc,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectTeamsByIds: No team exists with the id",i)}return g(s)})),Ug=f(u.createSelector([Kh,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Yh=ec.reducer,kg={version:0},Jh=u.createSlice({name:"versioning",initialState:kg,reducers:{}}),Zh=Jh.reducer,ic={outboxReducer:xl,fileReducer:cu,authReducer:Td},Bg=u.combineReducers(ic),Xh={...ic,[Je]:Zh,categoryReducer:wd,assetReducer:Sr,assetAttachmentReducer:kc,assetStageCompletionReducer:Tr,assetStageReducer:wr,assetTypeReducer:bd,assetTypeAttachmentReducer:$r,issueReducer:jo,issueAttachmentReducer:mo,issueTypeReducer:Fl,issueTypeAttachmentReducer:Go,organizationReducer:Kl,projectReducer:qh,projectAttachmentReducer:fh,projectAccessReducer:ih,organizationAccessReducer:Gl,projectFileReducer:vh,rehydratedReducer:Dh,formReducer:Tu,formRevisionReducer:bu,formRevisionAttachmentReducer:hu,formSubmissionAttachmentReducer:ju,formSubmissionReducer:ku,userReducer:zl,emailDomainsReducer:eu,documentsReducer:Kd,documentAttachmentReducer:Bd,teamReducer:Yh,agentsReducer:Mc,issueCommentReducer:Ro,issueCommentAttachmentReducer:To,issueUpdateReducer:Ml,geoImageReducer:Ju,issueAssociationReducer:ao,issueTypeFieldsReducer:rl,issueTypeFieldValuesReducer:el,issueTypeFieldsAttachmentReducer:Zo,issueTypeFieldValuesAttachmentReducer:pl,assetTypeFieldsReducer:sd,assetTypeFieldValuesReducer:yd,assetTypeFieldsAttachmentReducer:Jr,assetTypeFieldValuesAttachmentReducer:ud,assetProcedureReducer:Dn,assetProcedureInstanceReducer:jn,assetProcedureFieldsReducer:hn,assetProcedureFieldValuesReducer:On,assetProcedureFieldsAttachmentReducer:cn,assetProcedureFieldValuesAttachmentReducer:gn,assetProcedureAttachmentReducer:Zc,assetProcedureStepFieldsAttachmentReducer:Nn,assetProcedureStepFieldsReducer:Kn,assetProcedureStepFieldValuesAttachmentReducer:er,assetProcedureStepFieldValuesReducer:rr,assetProcedureStepReducer:lr,teamMembershipReducer:Bh},$g=u.combineReducers(Xh);let Qh;function Gg(t){Qh=t}function ot(){return Qh}let xh;function Lg(t){xh=t}function Ng(){return xh}const em={};class tm{constructor(e){S(this,"client");em[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 sm=()=>cm.length-1,am=t=>(t[Je]={version:sm()},t),im=()=>am({}),Hg=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Wg=t=>e=>{var s;return e===void 0&&(e={}),((s=e[Je])==null?void 0:s.version)===sm()?e:t(e)},cm=[am,im,im,Hg],Kg=Object.fromEntries(cm.map((t,e)=>[e,Wg(t)]));let cc=null;function ke(){const t=ot();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(cc)return cc;const e=t.getState().offline.outbox,s=Ke._fromOutbox(e);return cc=s,s}const Yg=t=>{if(t)throw t;const e=ot();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},nm=(t,e,s)=>{const i=ke();return i?(i.addRequest(e),i.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},rm=(t,e,s)=>{const i=ke();if(!i)return console.warn("Outbox coordinator not set; cannot dequeue request yet."),[];const n=e.meta.offlineAction.payload.uuid;return i.remove(n),i.getQueue()};async function Jg(t,e){if(!e.payload)throw new Error("Received empty payload");return ib(e)}const Zg={...lc,effect:Jg,discard:rc,returnPromises:!0,persistCallback:Yg,retry:nb,persistOptions:{storage:Am},queue:{...lc.queue,enqueue:nm,dequeue:rm,peek:(...t)=>cb(...t)}},Xg=ym(Kg,Je),Qg=u.compose(pm.offline(Zg),Xg);function xg(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(c=>c 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 nc(t,e){const s=em[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const i=s instanceof R;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");i&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const n={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:o,headers:m,method:d,queryParams:l,attachmentHash:p,isExternalUrl:A,isAuthNeeded:y,isResponseBlob:b}={...n,...r.request},F=r.request;let _=F.url;const v=p?await e.files.fetchCache(p):void 0;if(p&&!v)throw new Error(`Cannot upload file ${p} because it's not cached.`);!A&&!_.startsWith("http")&&(!_.startsWith("/")&&!_.startsWith("blob:")&&(_="/"+_),_=t.meta.offline.effect.BASE_URL+_);const q=V=>{if(p){const De=F.s3url;if(!De)throw new Error(`No S3 URL for file ${p}`);if("warning"in De)throw new Error(`S3 URL warning for file ${p}`);if(!v)throw new Error(`No file for file ${p}`);const lt=De.fields["x-amz-checksum-sha1"];if(!lt)throw new Error(`No checksum for file ${p}`);return V.set("x-amz-checksum-sha1",lt).field({...o,...De.fields}).attach("file",v)}return V.send(o)},SF={[h.GET]:()=>b?Ge.get(_.toString()).responseType("blob"):Ge.get(_.toString()),[h.POST]:()=>{const V=Ge.post(_.toString());return q(V)},[h.PATCH]:()=>{const V=Ge.patch(_.toString());return q(V)},[h.PUT]:()=>{const V=Ge.put(_.toString());return q(V)},[h.DELETE]:()=>{const V=Ge.delete(_.toString());return q(V)}}[d];let $e=SF();if(y&&i){const V=s.auth.getAuthHeader();$e=$e.set("Authorization",V)}m&&($e=$e.set(m));try{return await $e.query(l)}catch(V){const De=xg(V),lt=De==null?void 0:De.status;if(i&<===401)return await s.auth.handleUnauthorized($e,De),$e.query(l);throw new D({response:De,innerError:V,discard:um.includes(lt)})}}class eb{constructor(e){S(this,"_all");S(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 dm{constructor(){S(this,"next");this.next=null}then(e){return new eb(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!ot())throw new Error("Client store not set");const i=Ng();if(!i)throw new Error("Client SDK not set");return nc(e,i)}}}class tb extends dm{async run(e){return super.run(e)}}class sb extends dm{async run(e){return super.run(e)}}const ab=new tb().then(new sb).compile();function ib(t){var e;return(e=ab[0])==null?void 0:e.run(t)}const um=[400,409,403,404,405,500];function rc(t,e,s=0){var d;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
|
|
1
|
+
(function(a,z){typeof exports=="object"&&typeof module<"u"?z(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("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","jwt-decode","dependency-graph","@tiptap/core"],z):(a=typeof globalThis<"u"?globalThis:a||self,z(a["overmap-core"]={},null,a.toolkit,a.request,a.uuid,a.fileSaver,a.reduxOffline,a.offlineConfig,null,a.localforage,a.createMigration,null,a.idb,a.jwtDecode,a.dependencyGraph))})(this,function(a,z,d,Ge,Le,um,om,uc,PP,lm,hm,FP,mm,pm,Am){"use strict";var gP=Object.defineProperty;var bP=(a,z,d)=>z in a?gP(a,z,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[z]=d;var S=(a,z,d)=>bP(a,typeof z!="symbol"?z+"":z,d);var dm;const oc=Object.freeze([]),lc=Object.freeze({});var hc=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(hc||{}),h=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(h||{}),mc=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(mc||{}),Gt=(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))(Gt||{}),Lt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Lt||{}),E=(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))(E||{});const ym=Lt.BACKLOG,fm=Gt.MEDIUM,pc=6e4;function I(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 Sm(){return{initializeSelection:(m,u)=>{m.selection=Array.from(new Set(u.payload))},selectOne:(m,u)=>{new Set(m.selection).has(u.payload)||m.selection.push(u.payload)},selectMany:(m,u)=>{const l=new Set(m.selection);for(const p of u.payload)l.has(p)||l.add(p);m.selection=Array.from(l)},unselectOne:(m,u)=>{const l=new Set(m.selection);l.has(u.payload)&&(l.delete(u.payload),m.selection=Array.from(l))},unselectMany:(m,u)=>{const l=new Set(m.selection);for(const p of u.payload)l.has(p)&&l.delete(p);m.selection=Array.from(l)},toggleOne:(m,u)=>{const l=new Set(m.selection);l.has(u.payload)?l.delete(u.payload):l.add(u.payload),m.selection=Array.from(l)},toggleMany:(m,u)=>{const l=new Set(m.selection);for(const p of u.payload)l.has(p)?l.delete(p):l.add(p);m.selection=Array.from(l)},getInitialState:m=>({...m,selection:[]})}}const Je="versioning",F=d.createAction("RESET"),M=d.createAction("RESET_PROJECT_STATE"),O=d.createAction("RESET_ORGANIZATION_STATE");dm=Symbol.toStringTag;class Ac{constructor(){S(this,dm,"Promise");S(this,"_promise");S(this,"_resolve");S(this,"_reject");S(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 gm=t=>({type:"Point",coordinates:t}),bm=t=>({type:"MultiPoint",coordinates:t}),Pm=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Nt=!1;["true","1"].includes("".toLowerCase())&&(Nt=!0);function Fm(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;const s=Object.keys(t),i=Object.keys(e),c=s.length;if(c!==i.length)return!1;for(let n=0;n<c;n++){const r=s[n];if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1}return!0}function Ht(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Nt&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Nt&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Tm(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 g=t=>t.length===0?oc:t,ht=t=>Object.keys(t).length===0?lc:t,yc=Ht(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===Wt.getFullYear(),i={day:"numeric",month:"short"};return s||(i.year="numeric"),e.toLocaleDateString([],i)}),Im=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),_m=1e3*86400,Wt=new Date,Om=t=>new Date(t).toDateString()===Wt.toDateString(),Rm=Ht((t,e,s)=>{const i=Math.round((new Date(t).getTime()-Wt.getTime())/_m);return i<e||i>s?yc(t):Im.format(i,"days")});function vm(t){return new Uint8Array(t).reduce((s,i)=>s+i.toString(16).padStart(2,"0"),"")}const Kt=async(t,e)=>{e||(e=await Ne(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 Ne(t){return new Promise((e,s)=>{const i=new FileReader;i.onload=()=>{const c=i.result;if(!c){s(new Error("FileReader did not return a valid ArrayBuffer."));return}crypto.subtle.digest("SHA-1",c).then(n=>{const r=vm(n);e(r)})},i.readAsArrayBuffer(t)})}function wm(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 fc(t,e){return new File([t],e,{type:t.type})}function Mm(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 Em=async t=>{const e={};for(const s of t){const i=await Ne(s);e[i]={sha1:i,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},Sc=async t=>(await fetch(t)).blob(),jm=t=>new Promise((e,s)=>{const i=new FileReader;i.onloadend=()=>{var c;e(((c=i.result)==null?void 0:c.toString())||"")},i.readAsDataURL(t)});function qm(t){const e=new Blob([t]);um.saveAs(e,t.name)}const gc={};function Vm(t,e,s,...i){const c=gc[t];let n=!1;c?c[e]||(c[e]=!0,n=!0):(gc[t]={[e]:!0},n=!0),n&&console[s](...i)}const bc=["created_at","updated_at","index","revision"];function T(t){return{...t,uuid:Le.v4()}}function Pc(t){const e={};for(const s of t)e[s.uuid]=s;return e}function zm(t,e=void 0,s=255){let i=t.replace(/[^a-z0-9_\-.]/gi,"_").replace(/_{2,}/g,"_");if(!e){const n=t.split(".");n.length>1&&(e=n[n.length-1])}e&&!e.startsWith(".")&&(e="."+e);const c=e?e.length:0;return i.length+c>s&&(i=i.slice(0,s-c)+(e||"")),i}function Um(t){return t.toLowerCase().replace(" ","-")}function Dm(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Cm(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const f=t=>e=>s=>t(s,e);function Fc(t,e,s){return s.findIndex(i=>i.uuid===t.uuid)===e}function km(t,e,s){return s.findIndex(i=>i.file_sha1===t.file_sha1)===e}const Bm=/^.+@.+\..+$/;function v(t){const e={...t};for(const s of[...bc,"created_by"])s in e&&delete e[s];return e}const C=I(t=>t.uuid),Tc=C.getInitialState({}),Yt=d.createSlice({name:"agents",initialState:Tc,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Tc)),reducers:{initializeConversations:C.initialize,addConversation:C.addOne,addConversations:C.addMany,setConversation:C.setOne,setConversations:C.setMany,updateConversation:C.updateOne,updateConversations:C.updateMany,deleteConversation:C.deleteOne,deleteConversations:C.deleteMany}}),{initializeConversations:Ic,addConversation:_c,addConversations:$m,setConversation:Oc,setConversations:Gm,updateConversation:Rc,updateConversations:Lm,deleteConversation:Nm,deleteConversations:Hm}=Yt.actions,Jt=t=>t.agentsReducer.instances,Wm=d.createSelector([Jt],t=>Object.values(t)),Km=f(d.createSelector([Jt,(t,e)=>e],(t,e)=>t[e])),vc=Yt.reducer,k=I(t=>t.uuid),wc=k.getInitialState({}),Zt=d.createSlice({name:"assetAttachments",initialState:wc,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,wc)),reducers:{initializeAssetAttachments:k.initialize,addAssetAttachment:k.addOne,addAssetAttachments:k.addMany,setAssetAttachment:k.setOne,setAssetAttachments:k.setMany,updateAssetAttachment:k.updateOne,updateAssetAttachments:k.updateMany,deleteAssetAttachment:k.deleteOne,deleteAssetAttachments:k.deleteMany}}),{initializeAssetAttachments:Xt,addAssetAttachment:Ym,addAssetAttachments:Qt,setAssetAttachment:Mc,setAssetAttachments:Jm,updateAssetAttachment:Zm,updateAssetAttachments:Ec,deleteAssetAttachment:jc,deleteAssetAttachments:xt}=Zt.actions,qc=t=>t.assetAttachmentReducer.instances,Vc=d.createSelector([qc],t=>Object.values(t)),zc=t=>e=>e.assetAttachmentReducer.instances[t],Uc=f(d.createSelector([Vc,(t,e)=>e],(t,e)=>g(t.filter(({asset:s})=>e===s)))),Dc=Zt.reducer,B=I(t=>t.uuid),Cc=B.getInitialState({}),es=d.createSlice({name:"assetProcedureAttachments",initialState:Cc,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Cc)),reducers:{initializeAssetProcedureAttachments:B.initialize,addAssetProcedureAttachment:B.addOne,addAssetProcedureAttachments:B.addMany,setAssetProcedureAttachment:B.setOne,setAssetProcedureAttachments:B.setMany,updateAssetProcedureAttachment:B.updateOne,updateAssetProcedureAttachments:B.updateMany,deleteAssetProcedureAttachment:B.deleteOne,deleteAssetProcedureAttachments:B.deleteMany}}),{initializeAssetProcedureAttachments:kc,addAssetProcedureAttachment:Xm,addAssetProcedureAttachments:Bc,setAssetProcedureAttachment:$c,setAssetProcedureAttachments:Qm,updateAssetProcedureAttachment:xm,updateAssetProcedureAttachments:Gc,deleteAssetProcedureAttachment:Lc,deleteAssetProcedureAttachments:Nc}=es.actions,Hc=t=>t.assetProcedureAttachmentReducer.instances,Wc=d.createSelector([Hc],t=>Object.values(t)),Kc=t=>e=>e.assetProcedureAttachmentReducer.instances[t],ep=f(d.createSelector([Wc,(t,e)=>e],(t,e)=>g(t.filter(({asset_procedure:s})=>e===s)))),Yc=es.reducer,$=I(t=>t.uuid),Jc=$.getInitialState({}),ts=d.createSlice({name:"assetProcedureFieldsAttachments",initialState:Jc,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Jc)),reducers:{initializeAssetProcedureFieldsAttachments:$.initialize,addAssetProcedureFieldsAttachment:$.addOne,addAssetProcedureFieldsAttachments:$.addMany,setAssetProcedureFieldsAttachment:$.setOne,setAssetProcedureFieldsAttachments:$.setMany,updateAssetProcedureFieldsAttachment:$.updateOne,updateAssetProcedureFieldsAttachments:$.updateMany,deleteAssetProcedureFieldsAttachment:$.deleteOne,deleteAssetProcedureFieldsAttachments:$.deleteMany}}),{initializeAssetProcedureFieldsAttachments:Zc,addAssetProcedureFieldsAttachment:tp,addAssetProcedureFieldsAttachments:Xc,setAssetProcedureFieldsAttachment:sp,setAssetProcedureFieldsAttachments:ap,updateAssetProcedureFieldsAttachment:ip,updateAssetProcedureFieldsAttachments:Qc,deleteAssetProcedureFieldsAttachment:cp,deleteAssetProcedureFieldsAttachments:xc}=ts.actions,en=t=>t.assetProcedureFieldsAttachmentReducer.instances,tn=d.createSelector([en],t=>Object.values(t)),np=f(d.createSelector([tn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),rp=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],sn=ts.reducer,G=I(t=>t.uuid),an=G.getInitialState({}),ss=d.createSlice({name:"assetProcedureFields",initialState:an,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,an)),reducers:{initializeAssetProcedureFields:G.initialize,addAssetProcedureFields:G.addOne,addAssetProcedureFieldsMany:G.addMany,setAssetProcedureFields:G.setOne,setAssetProcedureFieldsMany:G.setMany,updateAssetProcedureFields:G.updateOne,updateAssetProcedureFieldsMany:G.updateMany,deleteAssetProcedureFields:G.deleteOne,deleteAssetProcedureFieldsMany:G.deleteMany}}),{initializeAssetProcedureFields:cn,addAssetProcedureFields:nn,addAssetProcedureFieldsMany:dp,setAssetProcedureFields:up,setAssetProcedureFieldsMany:op,updateAssetProcedureFields:rn,updateAssetProcedureFieldsMany:lp,deleteAssetProcedureFields:dn,deleteAssetProcedureFieldsMany:hp}=ss.actions,un=t=>t.assetProcedureFieldsReducer.instances,as=d.createSelector([un],t=>Object.values(t)),mp=f(d.createSelector([as,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),pp=f(d.createSelector([as,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,i)=>s.submitted_at>i.submitted_at?-1:1)[0])),Ap=t=>e=>e.assetProcedureFieldsReducer.instances[t],on=ss.reducer,L=I(t=>t.uuid),ln=L.getInitialState({}),is=d.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:ln,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,ln)),reducers:{initializeAssetProcedureFieldValuesAttachments:L.initialize,addAssetProcedureFieldValuesAttachment:L.addOne,addAssetProcedureFieldValuesAttachments:L.addMany,setAssetProcedureFieldValuesAttachment:L.setOne,setAssetProcedureFieldValuesAttachments:L.setMany,updateAssetProcedureFieldValuesAttachment:L.updateOne,updateAssetProcedureFieldValuesAttachments:L.updateMany,deleteAssetProcedureFieldValuesAttachment:L.deleteOne,deleteAssetProcedureFieldValuesAttachments:L.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:hn,addAssetProcedureFieldValuesAttachment:yp,addAssetProcedureFieldValuesAttachments:mt,setAssetProcedureFieldValuesAttachment:fp,setAssetProcedureFieldValuesAttachments:Sp,updateAssetProcedureFieldValuesAttachment:gp,updateAssetProcedureFieldValuesAttachments:mn,deleteAssetProcedureFieldValuesAttachment:bp,deleteAssetProcedureFieldValuesAttachments:pt}=is.actions,cs=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,pn=d.createSelector([cs],t=>Object.values(t)),Pp=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],An=f(d.createSelector([cs,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),yn=f(d.createSelector([pn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),fn=is.reducer,N=I(t=>t.uuid),Sn=N.getInitialState({}),ns=d.createSlice({name:"assetProcedureFieldValues",initialState:Sn,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Sn)),reducers:{initializeAssetProcedureFieldValues:N.initialize,addAssetProcedureFieldValues:N.addOne,addAssetProcedureFieldValuesMany:N.addMany,setAssetProcedureFieldValues:N.setOne,setAssetProcedureFieldValuesMany:N.setMany,updateAssetProcedureFieldValues:N.updateOne,updateAssetProcedureFieldValuesMany:N.updateMany,deleteAssetProcedureFieldValues:N.deleteOne,deleteAssetProcedureFieldValuesMany:N.deleteMany}}),{initializeAssetProcedureFieldValues:gn,addAssetProcedureFieldValues:rs,addAssetProcedureFieldValuesMany:bn,setAssetProcedureFieldValues:Fp,setAssetProcedureFieldValuesMany:Tp,updateAssetProcedureFieldValues:Ze,updateAssetProcedureFieldValuesMany:Pn,deleteAssetProcedureFieldValues:ds,deleteAssetProcedureFieldValuesMany:Fn}=ns.actions,Tn=t=>t.assetProcedureFieldValuesReducer.instances,us=d.createSelector([Tn],t=>Object.values(t)),Ip=f(d.createSelector([us,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),_p=f(d.createSelector([us,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),os=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],In=ns.reducer,H=I(t=>t.uuid),_n=H.getInitialState({}),ls=d.createSlice({name:"assetProcedureInstances",initialState:_n,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,_n)),reducers:{initializeAssetProcedureInstances:H.initialize,addAssetProcedureInstance:H.addOne,addAssetProcedureInstances:H.addMany,setAssetProcedureInstance:H.setOne,setAssetProcedureInstances:H.setMany,updateAssetProcedureInstance:H.updateOne,updateAssetProcedureInstances:H.updateMany,deleteAssetProcedureInstance:H.deleteOne,deleteAssetProcedureInstances:H.deleteMany}}),{initializeAssetProcedureInstances:On,addAssetProcedureInstance:hs,addAssetProcedureInstances:Rn,updateAssetProcedureInstance:Xe,updateAssetProcedureInstances:Op,deleteAssetProcedureInstance:ms,deleteAssetProcedureInstances:vn,setAssetProcedureInstance:Rp,setAssetProcedureInstances:vp}=ls.actions,ps=t=>t.assetProcedureInstanceReducer.instances,As=d.createSelector([ps],t=>Object.values(t)),wn=f(d.createSelector([As,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),wp=f(d.createSelector([As,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ys=t=>e=>e.assetProcedureInstanceReducer.instances[t],Mp=f(d.createSelector([ps,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c&&s.push(c)}return g(s)})),Mn=ls.reducer,W=I(t=>t.uuid),En=W.getInitialState({}),fs=d.createSlice({name:"assetProcedures",initialState:En,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,En)),reducers:{initializeAssetProcedures:W.initialize,addAssetProcedure:W.addOne,addAssetProcedures:W.addMany,setAssetProcedure:W.setOne,setAssetProcedures:W.setMany,updateAssetProcedure:W.updateOne,updateAssetProcedures:W.updateMany,deleteAssetProcedure:W.deleteOne,deleteAssetProcedures:W.deleteMany}}),{initializeAssetProcedures:jn,addAssetProcedure:Ss,addAssetProcedures:Ep,updateAssetProcedure:Qe,updateAssetProcedures:jp,deleteAssetProcedure:gs,deleteAssetProcedures:qp,setAssetProcedure:Vp,setAssetProcedures:zp}=fs.actions,bs=t=>t.assetProcedureReducer.instances,qn=d.createSelector([bs],t=>Object.values(t)),Ps=t=>e=>e.assetProcedureReducer.instances[t],Up=f(d.createSelector([bs,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c&&s.push(c)}return g(s)})),Dp=f(d.createSelector([qn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Vn=fs.reducer,K=I(t=>t.uuid),zn=K.getInitialState({}),Fs=d.createSlice({name:"assetProcedureStepFieldsAttachments",initialState:zn,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,zn)),reducers:{initializeAssetProcedureStepFieldsAttachments:K.initialize,addAssetProcedureStepFieldsAttachment:K.addOne,addAssetProcedureStepFieldsAttachments:K.addMany,setAssetProcedureStepFieldsAttachment:K.setOne,setAssetProcedureStepFieldsAttachments:K.setMany,updateAssetProcedureStepFieldsAttachment:K.updateOne,updateAssetProcedureStepFieldsAttachments:K.updateMany,deleteAssetProcedureStepFieldsAttachment:K.deleteOne,deleteAssetProcedureStepFieldsAttachments:K.deleteMany}}),{initializeAssetProcedureStepFieldsAttachments:Un,addAssetProcedureStepFieldsAttachment:Cp,addAssetProcedureStepFieldsAttachments:Dn,setAssetProcedureStepFieldsAttachment:kp,setAssetProcedureStepFieldsAttachments:Bp,updateAssetProcedureStepFieldsAttachment:$p,updateAssetProcedureStepFieldsAttachments:Cn,deleteAssetProcedureStepFieldsAttachment:Gp,deleteAssetProcedureStepFieldsAttachments:kn}=Fs.actions,Bn=t=>t.assetProcedureStepFieldsAttachmentReducer.instances,$n=d.createSelector([Bn],t=>Object.values(t)),Lp=f(d.createSelector([$n,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Np=t=>e=>e.assetProcedureStepFieldsAttachmentReducer.instances[t],Gn=Fs.reducer,Y=I(t=>t.uuid),Ln=Y.getInitialState({}),Ts=d.createSlice({name:"assetProcedureStepFields",initialState:Ln,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Ln)),reducers:{initializeAssetProcedureStepFields:Y.initialize,addAssetProcedureStepFields:Y.addOne,addAssetProcedureStepFieldsMany:Y.addMany,setAssetProcedureStepFields:Y.setOne,setAssetProcedureStepFieldsMany:Y.setMany,updateAssetProcedureStepFields:Y.updateOne,updateAssetProcedureStepFieldsMany:Y.updateMany,deleteAssetProcedureStepFields:Y.deleteOne,deleteAssetProcedureStepFieldsMany:Y.deleteMany}}),{initializeAssetProcedureStepFields:Nn,addAssetProcedureStepFields:Is,addAssetProcedureStepFieldsMany:Hp,setAssetProcedureStepFields:Wp,setAssetProcedureStepFieldsMany:Kp,updateAssetProcedureStepFields:xe,updateAssetProcedureStepFieldsMany:Yp,deleteAssetProcedureStepFields:_s,deleteAssetProcedureStepFieldsMany:Jp}=Ts.actions,Os=t=>t.assetProcedureStepFieldsReducer.instances,Rs=d.createSelector([Os],t=>Object.values(t)),Zp=f(d.createSelector([Rs,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_step===e)))),Xp=f(d.createSelector([Rs,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure_step===e).sort((s,i)=>s.submitted_at>i.submitted_at?-1:1)[0])),Qp=d.createSelector([Os],t=>{const e={};for(const s of Object.values(t)){const i=e[s.asset_procedure_step];(!i||i.submitted_at<s.submitted_at)&&(e[s.asset_procedure_step]=s)}return e}),xp=t=>e=>e.assetProcedureStepFieldsReducer.instances[t],Hn=Ts.reducer,J=I(t=>t.uuid),Wn=J.getInitialState({}),vs=d.createSlice({name:"assetProcedureStepFieldValuesAttachments",initialState:Wn,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Wn)),reducers:{initializeAssetProcedureStepFieldValuesAttachments:J.initialize,addAssetProcedureStepFieldValuesAttachment:J.addOne,addAssetProcedureStepFieldValuesAttachments:J.addMany,setAssetProcedureStepFieldValuesAttachment:J.setOne,setAssetProcedureStepFieldValuesAttachments:J.setMany,updateAssetProcedureStepFieldValuesAttachment:J.updateOne,updateAssetProcedureStepFieldValuesAttachments:J.updateMany,deleteAssetProcedureStepFieldValuesAttachment:J.deleteOne,deleteAssetProcedureStepFieldValuesAttachments:J.deleteMany}}),{initializeAssetProcedureStepFieldValuesAttachments:Kn,addAssetProcedureStepFieldValuesAttachment:eA,addAssetProcedureStepFieldValuesAttachments:At,setAssetProcedureStepFieldValuesAttachment:tA,setAssetProcedureStepFieldValuesAttachments:sA,updateAssetProcedureStepFieldValuesAttachment:aA,updateAssetProcedureStepFieldValuesAttachments:Yn,deleteAssetProcedureStepFieldValuesAttachment:iA,deleteAssetProcedureStepFieldValuesAttachments:yt}=vs.actions,ws=t=>t.assetProcedureStepFieldValuesAttachmentReducer.instances,Jn=d.createSelector([ws],t=>Object.values(t)),cA=t=>e=>e.assetProcedureStepFieldValuesAttachmentReducer.instances[t],Zn=f(d.createSelector([ws,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),Xn=f(d.createSelector([Jn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Qn=vs.reducer,Z=I(t=>t.uuid),xn=Z.getInitialState({}),Ms=d.createSlice({name:"assetProcedureStepFieldValues",initialState:xn,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,xn)),reducers:{initializeAssetProcedureStepFieldValues:Z.initialize,addAssetProcedureStepFieldValues:Z.addOne,addAssetProcedureStepFieldValuesMany:Z.addMany,setAssetProcedureStepFieldValues:Z.setOne,setAssetProcedureStepFieldValuesMany:Z.setMany,updateAssetProcedureStepFieldValues:Z.updateOne,updateAssetProcedureStepFieldValuesMany:Z.updateMany,deleteAssetProcedureStepFieldValues:Z.deleteOne,deleteAssetProcedureStepFieldValuesMany:Z.deleteMany}}),{initializeAssetProcedureStepFieldValues:er,addAssetProcedureStepFieldValues:Es,addAssetProcedureStepFieldValuesMany:tr,setAssetProcedureStepFieldValues:nA,setAssetProcedureStepFieldValuesMany:rA,updateAssetProcedureStepFieldValues:et,updateAssetProcedureStepFieldValuesMany:sr,deleteAssetProcedureStepFieldValues:js,deleteAssetProcedureStepFieldValuesMany:ar}=Ms.actions,ir=t=>t.assetProcedureStepFieldValuesReducer.instances,ft=d.createSelector([ir],t=>Object.values(t)),dA=f(d.createSelector([ft,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),uA=f(d.createSelector([ft,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),oA=f(d.createSelector([ft,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_step===e)))),qs=t=>e=>e.assetProcedureStepFieldValuesReducer.instances[t],cr=Ms.reducer,X=I(t=>t.uuid),nr=X.getInitialState({}),Vs=d.createSlice({name:"assetProcedureSteps",initialState:nr,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,nr)),reducers:{initializeAssetProcedureSteps:X.initialize,setAssetProcedureStep:X.setOne,setAssetProcedureSteps:X.setMany,addAssetProcedureStep:X.addOne,addAssetProcedureSteps:X.addMany,updateAssetProcedureStep:X.updateOne,updateAssetProcedureSteps:X.updateMany,deleteAssetProcedureStep:X.deleteOne,deleteAssetProcedureSteps:X.deleteMany}}),{initializeAssetProcedureSteps:rr,setAssetProcedureStep:dr,setAssetProcedureSteps:lA,addAssetProcedureStep:zs,addAssetProcedureSteps:hA,updateAssetProcedureStep:St,updateAssetProcedureSteps:mA,deleteAssetProcedureStep:Us,deleteAssetProcedureSteps:pA}=Vs.actions,ur=Vs.reducer,gt=t=>t.assetProcedureStepReducer.instances,Ds=t=>e=>e.assetProcedureStepReducer.instances[t],or=d.createSelector([gt],t=>Object.values(t)),AA=f(d.createSelector([gt,(t,e)=>e],(t,e)=>{const s={};for(const[i,c]of Object.entries(t))c.asset_procedure===e&&(s[i]=c);return ht(s)})),yA=f(d.createSelector([or,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),fA=f(d.createSelector([gt,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectAssetProcedureStepsByIds: No step exists with the id",i)}return g(s)})),Q=I(t=>t.uuid),lr=Q.getInitialState({}),Cs=d.createSlice({name:"assets",initialState:lr,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,lr)),reducers:{initializeAssets:Q.initialize,addAsset:Q.addOne,addAssets:Q.addMany,setAsset:Q.setOne,setAssets:Q.setMany,updateAsset:Q.updateOne,updateAssets:Q.updateMany,deleteAsset:Q.deleteOne,deleteAssets:Q.deleteMany}}),{initializeAssets:hr,addAsset:ks,addAssets:bt,updateAsset:tt,updateAssets:SA,deleteAsset:Bs,deleteAssets:$s,setAsset:gA,setAssets:bA}=Cs.actions,Gs=t=>t.assetReducer.instances,mr=d.createSelector([Gs],t=>g(Object.values(t))),Ls=f(d.createSelector([mr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),Ns=t=>e=>e.assetReducer.instances[t],pr=f(d.createSelector([Gs,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c&&s.push(c)}return g(s)})),PA=t=>e=>Ls(t)(e).length,Ar=Cs.reducer,x=I(t=>t.uuid),yr=x.getInitialState({}),Hs=d.createSlice({name:"assetStageCompletions",initialState:yr,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,yr)),reducers:{initializeAssetStageCompletions:x.initialize,addAssetStageCompletion:x.addOne,addAssetStageCompletions:x.addMany,setAssetStageCompletion:x.setOne,setAssetStageCompletions:x.setMany,updateAssetStageCompletion:x.updateOne,updateAssetStageCompletions:x.updateMany,deleteAssetStageCompletion:x.deleteOne,deleteAssetStageCompletions:x.deleteMany}}),{initializeAssetStageCompletions:fr,addAssetStageCompletion:Ws,addAssetStageCompletions:Ks,setAssetStageCompletion:FA,setAssetStageCompletions:TA,updateAssetStageCompletion:Sr,updateAssetStageCompletions:gr,deleteAssetStageCompletion:Ys,deleteAssetStageCompletions:Js}=Hs.actions,br=Hs.reducer,Zs=t=>t.assetStageCompletionReducer.instances,IA=d.createSelector([Zs],t=>Object.values(t)),Pr=t=>e=>e.assetStageCompletionReducer.instances[t],Fr=f(d.createSelector([Zs,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),ee=I(t=>t.uuid),Tr=ee.getInitialState({}),Xs=d.createSlice({name:"assetStages",initialState:Tr,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Tr)),reducers:{initializeAssetStages:ee.initialize,setAssetStage:ee.setOne,setAssetStages:ee.setMany,addAssetStage:ee.addOne,addAssetStages:ee.addMany,updateAssetStage:ee.updateOne,updateAssetStages:ee.updateMany,deleteAssetStage:ee.deleteOne,deleteAssetStages:ee.deleteMany}}),{initializeAssetStages:Ir,setAssetStage:_r,setAssetStages:_A,addAssetStage:Qs,addAssetStages:OA,updateAssetStage:Pt,updateAssetStages:RA,deleteAssetStage:xs,deleteAssetStages:vA}=Xs.actions,Or=Xs.reducer,Ft=t=>t.assetStageReducer.instances,ea=t=>e=>e.assetStageReducer.instances[t],Rr=d.createSelector([Ft],t=>Object.values(t)),wA=f(d.createSelector([Ft,(t,e)=>e],(t,e)=>{const s={};for(const[i,c]of Object.entries(t))c.asset_procedure===e&&(s[i]=c);return ht(s)})),MA=f(d.createSelector([Rr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),EA=f(d.createSelector([Ft,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectStagesFromStageIds: No stage exists with the id",i)}return g(s)})),te=I(t=>t.uuid),vr=te.getInitialState({}),ta=d.createSlice({name:"assetTypeAttachments",initialState:vr,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,vr)),reducers:{initializeAssetTypeAttachments:te.initialize,addAssetTypeAttachment:te.addOne,addAssetTypeAttachments:te.addMany,setAssetTypeAttachment:te.setOne,setAssetTypeAttachments:te.setMany,updateAssetTypeAttachment:te.updateOne,updateAssetTypeAttachments:te.updateMany,deleteAssetTypeAttachment:te.deleteOne,deleteAssetTypeAttachments:te.deleteMany}}),{initializeAssetTypeAttachments:wr,addAssetTypeAttachment:jA,addAssetTypeAttachments:sa,setAssetTypeAttachment:Mr,setAssetTypeAttachments:qA,updateAssetTypeAttachment:VA,updateAssetTypeAttachments:Er,deleteAssetTypeAttachment:jr,deleteAssetTypeAttachments:aa}=ta.actions,qr=t=>t.assetTypeAttachmentReducer.instances,Vr=d.createSelector([qr],t=>Object.values(t)),zr=t=>e=>e.assetTypeAttachmentReducer.instances[t],Ur=f(d.createSelector([Vr,(t,e)=>e],(t,e)=>g(t.filter(({asset_type:s})=>e===s)))),Dr=ta.reducer,se=I(t=>t.uuid),Cr=se.getInitialState({}),ia=d.createSlice({name:"assetTypeFieldsAttachments",initialState:Cr,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Cr)),reducers:{initializeAssetTypeFieldsAttachments:se.initialize,addAssetTypeFieldsAttachment:se.addOne,addAssetTypeFieldsAttachments:se.addMany,setAssetTypeFieldsAttachment:se.setOne,setAssetTypeFieldsAttachments:se.setMany,updateAssetTypeFieldsAttachment:se.updateOne,updateAssetTypeFieldsAttachments:se.updateMany,deleteAssetTypeFieldsAttachment:se.deleteOne,deleteAssetTypeFieldsAttachments:se.deleteMany}}),{initializeAssetTypeFieldsAttachments:kr,addAssetTypeFieldsAttachment:zA,addAssetTypeFieldsAttachments:Br,setAssetTypeFieldsAttachment:UA,setAssetTypeFieldsAttachments:DA,updateAssetTypeFieldsAttachment:CA,updateAssetTypeFieldsAttachments:$r,deleteAssetTypeFieldsAttachment:kA,deleteAssetTypeFieldsAttachments:Gr}=ia.actions,Lr=t=>t.assetTypeFieldsAttachmentReducer.instances,Nr=d.createSelector([Lr],t=>Object.values(t)),BA=f(d.createSelector([Nr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),$A=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Hr=ia.reducer,ae=I(t=>t.uuid),Wr=ae.getInitialState({}),ca=d.createSlice({name:"assetTypeFields",initialState:Wr,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Wr)),reducers:{initializeAssetTypeFields:ae.initialize,addAssetTypeFields:ae.addOne,addAssetTypeFieldsMany:ae.addMany,setAssetTypeFields:ae.setOne,setAssetTypeFieldsMany:ae.setMany,updateAssetTypeFields:ae.updateOne,updateAssetTypeFieldsMany:ae.updateMany,deleteAssetTypeFields:ae.deleteOne,deleteAssetTypeFieldsMany:ae.deleteMany}}),{initializeAssetTypeFields:Kr,addAssetTypeFields:Yr,addAssetTypeFieldsMany:GA,setAssetTypeFields:LA,setAssetTypeFieldsMany:NA,updateAssetTypeFields:Jr,updateAssetTypeFieldsMany:HA,deleteAssetTypeFields:Zr,deleteAssetTypeFieldsMany:WA}=ca.actions,Xr=t=>t.assetTypeFieldsReducer.instances,Tt=d.createSelector([Xr],t=>Object.values(t)),KA=f(d.createSelector([Tt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),YA=f(d.createSelector([Tt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,i)=>s.submitted_at>i.submitted_at?-1:1)[0])),JA=t=>e=>e.assetTypeFieldsReducer.instances[t],Qr=ca.reducer,ie=I(t=>t.uuid),xr=ie.getInitialState({}),na=d.createSlice({name:"assetTypeFieldValuesAttachments",initialState:xr,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,xr)),reducers:{initializeAssetTypeFieldValuesAttachments:ie.initialize,addAssetTypeFieldValuesAttachment:ie.addOne,addAssetTypeFieldValuesAttachments:ie.addMany,setAssetTypeFieldValuesAttachment:ie.setOne,setAssetTypeFieldValuesAttachments:ie.setMany,updateAssetTypeFieldValuesAttachment:ie.updateOne,updateAssetTypeFieldValuesAttachments:ie.updateMany,deleteAssetTypeFieldValuesAttachment:ie.deleteOne,deleteAssetTypeFieldValuesAttachments:ie.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:ed,addAssetTypeFieldValuesAttachment:ZA,addAssetTypeFieldValuesAttachments:It,setAssetTypeFieldValuesAttachment:XA,setAssetTypeFieldValuesAttachments:QA,updateAssetTypeFieldValuesAttachment:xA,updateAssetTypeFieldValuesAttachments:td,deleteAssetTypeFieldValuesAttachment:ey,deleteAssetTypeFieldValuesAttachments:_t}=na.actions,ra=t=>t.assetTypeFieldValuesAttachmentReducer.instances,sd=d.createSelector([ra],t=>Object.values(t)),ty=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],ad=f(d.createSelector([ra,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),id=f(d.createSelector([sd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),cd=na.reducer,ce=I(t=>t.uuid),nd=ce.getInitialState({}),da=d.createSlice({name:"assetTypeFieldValues",initialState:nd,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,nd)),reducers:{initializeAssetTypeFieldValues:ce.initialize,addAssetTypeFieldValues:ce.addOne,addAssetTypeFieldValuesMany:ce.addMany,setAssetTypeFieldValues:ce.setOne,setAssetTypeFieldValuesMany:ce.setMany,updateAssetTypeFieldValues:ce.updateOne,updateAssetTypeFieldValuesMany:ce.updateMany,deleteAssetTypeFieldValues:ce.deleteOne,deleteAssetTypeFieldValuesMany:ce.deleteMany}}),{initializeAssetTypeFieldValues:rd,addAssetTypeFieldValues:ua,addAssetTypeFieldValuesMany:dd,setAssetTypeFieldValues:sy,setAssetTypeFieldValuesMany:ay,updateAssetTypeFieldValues:st,updateAssetTypeFieldValuesMany:ud,deleteAssetTypeFieldValues:oa,deleteAssetTypeFieldValuesMany:od}=da.actions,ld=t=>t.assetTypeFieldValuesReducer.instances,la=d.createSelector([ld],t=>Object.values(t)),iy=f(d.createSelector([la,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),cy=f(d.createSelector([Tt,la,(t,e)=>e],(t,e,s)=>{const i=new Set(t.filter(c=>c.asset_type===s).map(c=>c.uuid));return g(e.filter(c=>i.has(c.fields_revision)))})),ha=t=>e=>e.assetTypeFieldValuesReducer.instances[t],hd=da.reducer,ne=I(t=>t.uuid),md=ne.getInitialState({}),ma=d.createSlice({name:"assetTypes",initialState:md,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,md)),reducers:{initializeAssetTypes:ne.initialize,setAssetType:ne.setOne,setAssetTypes:ne.setMany,addAssetType:ne.addOne,addAssetTypes:ne.addMany,updateAssetType:ne.updateOne,updateAssetTypes:ne.updateMany,deleteAssetType:ne.deleteOne,deleteAssetTypes:ne.deleteMany}}),{initializeAssetTypes:pd,setAssetType:ny,setAssetTypes:ry,addAssetType:pa,addAssetTypes:dy,updateAssetType:at,updateAssetTypes:uy,deleteAssetType:Aa,deleteAssetTypes:oy}=ma.actions,ya=t=>t.assetTypeReducer.instances,Ad=d.createSelector([ya],t=>Object.values(t)),fa=t=>e=>e.assetTypeReducer.instances[t],ly=f(d.createSelector([ya,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectAssetTypesByIds: No assetType exists with the id",i)}return g(s)})),hy=f(d.createSelector([Ad,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),yd=ma.reducer,fd={accessToken:"",refreshToken:"",isLoggedIn:!1},Ot=d.createSlice({name:"auth",initialState:fd,extraReducers:t=>t.addCase(F,e=>Object.assign(e,fd)),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||Ot.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:my,clearTokens:py,setLoggedIn:Sd}=Ot.actions,Ay=t=>t.authReducer.accessToken,yy=t=>t.authReducer.isLoggedIn,gd=Ot.reducer,re=I(t=>t.uuid),bd=re.getInitialState({}),Sa=d.createSlice({name:"categories",initialState:bd,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,bd)),reducers:{initializeCategories:re.initialize,addCategory:re.addOne,addCategories:re.addMany,setCategory:re.setOne,setCategories:re.setMany,updateCategory:re.updateOne,updateCategories:re.updateMany,deleteCategory:re.deleteOne,deleteCategories:re.deleteMany}}),{initializeCategories:Pd,addCategory:ga,addCategories:fy,setCategory:Sy,setCategories:gy,updateCategory:Fd,updateCategories:by,deleteCategory:Td,deleteCategories:Py}=Sa.actions,ba=t=>t.categoryReducer.instances,Id=d.createSelector([ba],t=>Object.values(t)),Pa=t=>e=>e.categoryReducer.instances[t],Fy=f(d.createSelector([ba,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectCategoryByIds: No category exists with the id",i)}return g(s)})),Ty=f(d.createSelector([Id,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),_d=Sa.reducer,de=I(t=>t.uuid),Od=de.getInitialState({}),Fa=d.createSlice({name:"documentAttachments",initialState:Od,extraReducers:t=>t.addCase(F,e=>Object.assign(e,Od)),reducers:{initializeDocumentAttachments:de.initialize,addDocumentAttachment:de.addOne,addDocumentAttachments:de.addMany,setDocumentAttachment:de.setOne,setDocumentAttachments:de.setMany,updateDocumentAttachment:de.updateOne,updateDocumentAttachments:de.updateMany,deleteDocumentAttachment:de.deleteOne,deleteDocumentAttachments:de.deleteMany}}),{initializeDocumentAttachments:Rd,addDocumentAttachment:Iy,addDocumentAttachments:vd,setDocumentAttachment:wd,setDocumentAttachments:_y,updateDocumentAttachment:Oy,updateDocumentAttachments:Md,deleteDocumentAttachment:Ed,deleteDocumentAttachments:jd}=Fa.actions,qd=t=>t.documentAttachmentReducer.instances,Vd=d.createSelector([qd],t=>Object.values(t)),zd=t=>e=>e.documentAttachmentReducer.instances[t],Ry=f(d.createSelector([Vd,(t,e)=>e],(t,e)=>g(t.filter(({document:s})=>e===s)))),Ud=Fa.reducer,Dd={documents:{}},Ta=d.createSlice({name:"documents",initialState:Dd,extraReducers:t=>t.addCase(F,e=>{Object.assign(e,Dd)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(Fc).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Pc(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 i=t.documents[s.parent_document];t.documents[s.parent_document]={...i,children_documents:[...i.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 i=t.documents[s.uuid];if(s.organization!==void 0&&s.organization!==i.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==i.project)throw new Error("project cannot be updated");t.documents[s.uuid]={...i,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:i,position:c}=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 n=t.documents[s];if(n.parent_document&&t.documents[n.parent_document]){const{children_documents:r}=t.documents[n.parent_document];t.documents[n.parent_document].children_documents.splice(r.indexOf(n.uuid),1)}if(i){const r=t.documents[i],o=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(c){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,n.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,n.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[i].children_documents.unshift(n.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[i].children_documents.push(n.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 i=t.documents[s];if(i.parent_document&&t.documents[i.parent_document]){const c=t.documents[i.parent_document];t.documents[i.parent_document]={...c,children_documents:c.children_documents.filter(n=>n!==i.uuid)}}delete t.documents[s]}}}}),{setDocuments:Cd,addDocuments:kd,updateDocuments:De,moveDocument:Bd,removeDocuments:Ia}=Ta.actions,He=t=>t.documentsReducer.documents,$d=d.createSelector([He],t=>Object.values(t)),Gd=t=>e=>e.documentsReducer.documents[t],vy=f(d.createSelector([He,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectDocumentByIds: No document exists with the id",i)}return g(s)})),wy=f(d.createSelector([He,(t,e)=>e],(t,e)=>{const s=[],i=t[e];if(!i||!i.parent_document)return s;let c=t[i.parent_document];for(;c;)s.push(c.uuid),c=t[c.parent_document??""];return g(s)})),My=d.createSelector([$d],t=>g(t.filter(e=>!e.parent_document))),Ld=Ta.reducer,ue=I(t=>t.uuid),Nd=ue.getInitialState({}),_a=d.createSlice({name:"emailDomains",initialState:Nd,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Nd)),reducers:{initializeEmailDomains:ue.initialize,addEmailDomain:ue.addOne,addEmailDomains:ue.addMany,setEmailDomain:ue.setOne,setEmailDomains:ue.setMany,updateEmailDomain:ue.updateOne,updateEmailDomains:ue.updateMany,deleteEmailDomain:ue.deleteOne,deleteEmailDomains:ue.deleteMany}}),{initializeEmailDomains:Hd,addEmailDomain:Wd,addEmailDomains:Ey,setEmailDomain:jy,setEmailDomains:qy,updateEmailDomain:Vy,updateEmailDomains:zy,deleteEmailDomain:Kd,deleteEmailDomains:Uy}=_a.actions,Yd=t=>t.emailDomainsReducer.instances,Jd=d.createSelector([Yd],t=>Object.values(t)),Dy=f(d.createSelector([Jd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Zd=_a.reducer,Xd={s3Urls:{}},Qd=1e3*60*60,Cy=Qd*24*7,Oa=d.createSlice({name:"file",initialState:Xd,extraReducers:t=>t.addCase(F,e=>Object.assign(e,Xd)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:i,sha1:c}=e.payload,n=new Date,r=new Date(n.getTime()+Cy);t.s3Urls[c]={url:s,fields:i,exp:r.getTime()}}}}),{setUploadUrl:xd}=Oa.actions,eu=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const i=new Date().getTime();if(!((s.exp??i)-i<Qd))return s},tu=Oa.reducer,oe=I(t=>t.uuid),su=oe.getInitialState({}),Ra=d.createSlice({name:"formRevisionAttachments",initialState:su,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,su)),reducers:{initializeFormRevisionAttachments:oe.initialize,addFormRevisionAttachment:oe.addOne,addFormRevisionAttachments:oe.addMany,setFormRevisionAttachment:oe.setOne,setFormRevisionAttachments:oe.setMany,updateFormRevisionAttachment:oe.updateOne,updateFormRevisionAttachments:oe.updateMany,deleteFormRevisionAttachment:oe.deleteOne,deleteFormRevisionAttachments:oe.deleteMany}}),{initializeFormRevisionAttachments:au,addFormRevisionAttachment:ky,addFormRevisionAttachments:iu,setFormRevisionAttachment:By,setFormRevisionAttachments:$y,updateFormRevisionAttachment:Gy,updateFormRevisionAttachments:cu,deleteFormRevisionAttachment:Ly,deleteFormRevisionAttachments:nu}=Ra.actions,ru=t=>t.formRevisionAttachmentReducer.instances,Ny=f(d.createSelector([ru,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_revision===e)))),du=Ra.reducer,Hy=(t,e)=>{const s=t.revision,i=e.revision;return s===void 0&&i===void 0?t.submitted_at<e.submitted_at?-1:1:s===void 0?1:i===void 0||s<i?-1:1},le=I(t=>t.uuid),uu=le.getInitialState({}),va=d.createSlice({name:"formRevisions",initialState:uu,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,uu)),reducers:{initializeFormRevisions:le.initialize,addFormRevision:le.addOne,addFormRevisions:le.addMany,setFormRevision:le.setOne,setFormRevisions:le.setMany,updateFormRevision:le.updateOne,updateFormRevisions:le.updateMany,deleteFormRevision:le.deleteOne,deleteFormRevisions:le.deleteMany}}),{initializeFormRevisions:ou,addFormRevision:wa,addFormRevisions:lu,setFormRevision:hu,setFormRevisions:Wy,updateFormRevision:Ky,updateFormRevisions:Yy,deleteFormRevision:Ma,deleteFormRevisions:mu}=va.actions,Rt=t=>t.formRevisionReducer.instances,pu=d.createSelector([Rt],t=>Object.values(t)),Jy=t=>e=>e.formRevisionReducer.instances[t],Zy=f(d.createSelector([Rt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(n=>n.form===e);if(s.length===0)return;const c=s.sort(Hy)[s.length-1];return t[c.uuid]})),Au=f(d.createSelector([pu,(t,e)=>e],(t,e)=>g(t.filter(s=>s.form===e)))),yu=va.reducer,he=I(t=>t.uuid),fu=he.getInitialState({}),Ea=d.createSlice({name:"forms",initialState:fu,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,fu)),reducers:{initializeForms:he.initialize,addForm:he.addOne,addForms:he.addMany,setForm:he.setOne,setForms:he.setMany,updateForm:he.updateOne,updateForms:he.updateMany,deleteForm:he.deleteOne,deleteForms:he.deleteMany}}),{initializeForms:Su,addForm:ja,addForms:Xy,setForm:Qy,setForms:xy,updateForm:ef,updateForms:tf,deleteForm:qa,deleteForms:sf}=Ea.actions,gu=Ea.reducer,bu=t=>t.formReducer.instances,Pu=d.createSelector([bu],t=>Object.values(t)),Fu=t=>e=>e.formReducer.instances[t],af=f(d.createSelector([Pu,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),me=I(t=>t.uuid),Tu=me.getInitialState({}),Va=d.createSlice({name:"formSubmissionAttachments",initialState:Tu,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Tu)),reducers:{initializeFormSubmissionAttachments:me.initialize,addFormSubmissionAttachment:me.addOne,addFormSubmissionAttachments:me.addMany,setFormSubmissionAttachment:me.setOne,setFormSubmissionAttachments:me.setMany,updateFormSubmissionAttachment:me.updateOne,updateFormSubmissionAttachments:me.updateMany,deleteFormSubmissionAttachment:me.deleteOne,deleteFormSubmissionAttachments:me.deleteMany}}),{initializeFormSubmissionAttachments:Iu,addFormSubmissionAttachment:cf,addFormSubmissionAttachments:vt,setFormSubmissionAttachment:nf,setFormSubmissionAttachments:rf,updateFormSubmissionAttachment:df,updateFormSubmissionAttachments:_u,deleteFormSubmissionAttachment:uf,deleteFormSubmissionAttachments:wt}=Va.actions,za=t=>t.formSubmissionAttachmentReducer.instances,Ou=f(d.createSelector([za,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),Ru=f(d.createSelector([za,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_submission===e)))),vu=Va.reducer,pe=I(t=>t.uuid),wu=pe.getInitialState({}),Ua=d.createSlice({name:"formSubmissions",initialState:wu,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,wu)),reducers:{initializeFormSubmissions:pe.initialize,setFormSubmission:pe.setOne,setFormSubmissions:pe.setMany,addFormSubmission:pe.addOne,addFormSubmissions:pe.addMany,updateFormSubmission:pe.updateOne,updateFormSubmissions:pe.updateMany,deleteFormSubmission:pe.deleteOne,deleteFormSubmissions:pe.deleteMany}}),{initializeFormSubmissions:Mu,setFormSubmission:Mt,setFormSubmissions:of,addFormSubmission:Da,addFormSubmissions:Et,updateFormSubmission:Eu,updateFormSubmissions:lf,deleteFormSubmission:Ca,deleteFormSubmissions:jt}=Ua.actions,ka=t=>t.formSubmissionReducer.instances,Ba=d.createSelector([ka],t=>Object.values(t)),$a=t=>e=>e.formSubmissionReducer.instances[t],ju=f(d.createSelector([ka,Rt,(t,e)=>e],(t,e,s)=>{const i=new Set;for(const c of Object.values(e))c.form===s&&i.add(c.uuid);return Object.values(t).filter(c=>i.has(c.form_revision))})),qu=f(d.createSelector([Ba,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),Vu=f(d.createSelector([Ba,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),zu=Ua.reducer,Ae=I(t=>t.uuid),Uu=Ae.getInitialState({}),Ga=d.createSlice({name:"geoImages",initialState:Uu,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Uu)),reducers:{initializeGeoImages:Ae.initialize,setGeoImage:Ae.setOne,setGeoImages:Ae.setMany,addGeoImage:Ae.addOne,addGeoImages:Ae.addMany,updateGeoImage:Ae.updateOne,updateGeoImages:Ae.updateMany,deleteGeoImage:Ae.deleteOne,deleteGeoImages:Ae.deleteMany}}),{initializeGeoImages:Du,setGeoImage:it,setGeoImages:Cu,addGeoImage:ku,addGeoImages:Bu,updateGeoImage:$u,updateGeoImages:hf,deleteGeoImage:La,deleteGeoImages:Gu}=Ga.actions,Lu=t=>t.geoImageReducer.instances,Nu=d.createSelector([Lu],t=>Object.values(t)),Na=t=>e=>e.geoImageReducer.instances[t],mf=f(d.createSelector([Nu,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),Hu=Ga.reducer,ye=I(t=>t.uuid),Wu=ye.getInitialState({}),Ha=d.createSlice({name:"issueAssociations",initialState:Wu,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Wu)),reducers:{initializeIssueAssociations:ye.initialize,addIssueAssociation:ye.addOne,addIssueAssociations:ye.addMany,setIssueAssociation:ye.setOne,setIssueAssociations:ye.setMany,updateIssueAssociation:ye.updateOne,updateIssueAssociations:ye.updateMany,deleteIssueAssociation:ye.deleteOne,deleteIssueAssociations:ye.deleteMany}}),{initializeIssueAssociations:Ku,setIssueAssociations:pf,setIssueAssociation:Af,updateIssueAssociation:Yu,updateIssueAssociations:yf,addIssueAssociation:Wa,addIssueAssociations:Ka,deleteIssueAssociation:Ya,deleteIssueAssociations:Ja}=Ha.actions,ct=t=>t.issueAssociationReducer.instances,ff=d.createSelector([ct],t=>Object.values(t)),Ju=t=>e=>e.issueAssociationReducer.instances[t],Zu=f(d.createSelector([ct,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.associated_issue===e)))),Xu=f(d.createSelector([ct,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Qu=f(d.createSelector([ct,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.asset===e)))),xu=Ha.reducer,fe=I(t=>t.uuid),eo=fe.getInitialState({}),Za=d.createSlice({name:"issueAttachments",initialState:eo,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,eo)),reducers:{initializeIssueAttachments:fe.initialize,addIssueAttachment:fe.addOne,addIssueAttachments:fe.addMany,setIssueAttachment:fe.setOne,setIssueAttachments:fe.setMany,updateIssueAttachment:fe.updateOne,updateIssueAttachments:fe.updateMany,deleteIssueAttachment:fe.deleteOne,deleteIssueAttachments:fe.deleteMany}}),{initializeIssueAttachments:Xa,addIssueAttachment:Sf,addIssueAttachments:Qa,setIssueAttachment:to,setIssueAttachments:gf,updateIssueAttachment:bf,updateIssueAttachments:so,deleteIssueAttachment:ao,deleteIssueAttachments:xa}=Za.actions,io=t=>t.issueAttachmentReducer.instances,co=d.createSelector([io],t=>Object.values(t)),no=f(d.createSelector([co,(t,e)=>e],(t,e)=>g(t.filter(({issue:s})=>e===s)))),ro=t=>e=>e.issueAttachmentReducer.instances[t],uo=Za.reducer,Se=I(t=>t.uuid),oo=Se.getInitialState({}),ei=d.createSlice({name:"issueCommentAttachments",initialState:oo,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,oo)),reducers:{initializeIssueCommentAttachments:Se.initialize,addIssueCommentAttachment:Se.addOne,addIssueCommentAttachments:Se.addMany,setIssueCommentAttachment:Se.setOne,setIssueCommentAttachments:Se.setMany,updateIssueCommentAttachment:Se.updateOne,updateIssueCommentAttachments:Se.updateMany,deleteIssueCommentAttachment:Se.deleteOne,deleteIssueCommentAttachments:Se.deleteMany}}),{initializeIssueCommentAttachments:ti,addIssueCommentAttachment:Pf,addIssueCommentAttachments:lo,setIssueCommentAttachment:ho,setIssueCommentAttachments:Ff,updateIssueCommentAttachment:Tf,updateIssueCommentAttachments:mo,deleteIssueCommentAttachment:po,deleteIssueCommentAttachments:Ao}=ei.actions,yo=t=>t.issueCommentAttachmentReducer.instances,fo=d.createSelector([yo],t=>Object.values(t)),So=t=>e=>e.issueCommentAttachmentReducer.instances[t],If=f(d.createSelector([fo,(t,e)=>e],(t,e)=>g(t.filter(({issue_comment:s})=>e===s)))),go=ei.reducer,ge=I(t=>t.uuid),bo=ge.getInitialState({}),si=d.createSlice({name:"issueComments",initialState:bo,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,bo)),reducers:{initializeIssueComments:ge.initialize,addIssueComment:ge.addOne,addIssueComments:ge.addMany,setIssueComment:ge.setOne,setIssueComments:ge.setMany,updateIssueComment:ge.updateOne,updateIssueComments:ge.updateMany,deleteIssueComment:ge.deleteOne,deleteIssueComments:ge.deleteMany}}),{initializeIssueComments:_f,addIssueComment:ai,addIssueComments:Of,setIssueComment:ii,setIssueComments:Po,updateIssueComment:Rf,updateIssueComments:vf,deleteIssueComment:ci,deleteIssueComments:wf}=si.actions,Fo=t=>t.issueCommentReducer.instances,ni=t=>e=>e.issueCommentReducer.instances[t],Mf=f(d.createSelector([Fo,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),To=si.reducer,be=I(t=>t.uuid),Io=be.getInitialState({}),ri=d.createSlice({name:"issues",initialState:Io,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Io)),reducers:{initializeIssues:be.initialize,addIssue:be.addOne,addIssues:be.addMany,setIssue:be.setOne,setIssues:be.setMany,updateIssue:be.updateOne,updateIssues:be.updateMany,deleteIssue:be.deleteOne,deleteIssues:be.deleteMany}}),{initializeIssues:_o,addIssue:di,addIssues:Oo,setIssue:Ef,setIssues:jf,updateIssue:qt,updateIssues:qf,deleteIssue:ui,deleteIssues:Ro}=ri.actions,oi=t=>t.issueReducer.instances,Vf=d.createSelector([oi],t=>Object.values(t)),li=t=>e=>e.issueReducer.instances[t],zf=f(d.createSelector([oi,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectIssuesByIds: No issue exists with the id",i)}return g(s)})),vo=ri.reducer,Pe=I(t=>t.uuid),wo=Pe.getInitialState({}),hi=d.createSlice({name:"issueTypeAttachments",initialState:wo,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,wo)),reducers:{initializeIssueTypeAttachments:Pe.initialize,addIssueTypeAttachment:Pe.addOne,addIssueTypeAttachments:Pe.addMany,setIssueTypeAttachment:Pe.setOne,setIssueTypeAttachments:Pe.setMany,updateIssueTypeAttachment:Pe.updateOne,updateIssueTypeAttachments:Pe.updateMany,deleteIssueTypeAttachment:Pe.deleteOne,deleteIssueTypeAttachments:Pe.deleteMany}}),{initializeIssueTypeAttachments:mi,addIssueTypeAttachment:Uf,addIssueTypeAttachments:Mo,setIssueTypeAttachment:Eo,setIssueTypeAttachments:Df,updateIssueTypeAttachment:Cf,updateIssueTypeAttachments:jo,deleteIssueTypeAttachment:qo,deleteIssueTypeAttachments:Vo}=hi.actions,zo=t=>t.issueTypeAttachmentReducer.instances,Uo=d.createSelector([zo],t=>Object.values(t)),Do=t=>e=>e.issueTypeAttachmentReducer.instances[t],kf=f(d.createSelector([Uo,(t,e)=>e],(t,e)=>g(t.filter(({issue_type:s})=>e===s)))),Co=hi.reducer,Fe=I(t=>t.uuid),ko=Fe.getInitialState({}),pi=d.createSlice({name:"issueTypeFieldsAttachments",initialState:ko,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,ko)),reducers:{initializeIssueTypeFieldsAttachments:Fe.initialize,addIssueTypeFieldsAttachment:Fe.addOne,addIssueTypeFieldsAttachments:Fe.addMany,setIssueTypeFieldsAttachment:Fe.setOne,setIssueTypeFieldsAttachments:Fe.setMany,updateIssueTypeFieldsAttachment:Fe.updateOne,updateIssueTypeFieldsAttachments:Fe.updateMany,deleteIssueTypeFieldsAttachment:Fe.deleteOne,deleteIssueTypeFieldsAttachments:Fe.deleteMany}}),{initializeIssueTypeFieldsAttachments:Bo,addIssueTypeFieldsAttachment:Bf,addIssueTypeFieldsAttachments:$o,setIssueTypeFieldsAttachment:$f,setIssueTypeFieldsAttachments:Gf,updateIssueTypeFieldsAttachment:Lf,updateIssueTypeFieldsAttachments:Go,deleteIssueTypeFieldsAttachment:Nf,deleteIssueTypeFieldsAttachments:Lo}=pi.actions,No=t=>t.issueTypeFieldsAttachmentReducer.instances,Ho=d.createSelector([No],t=>Object.values(t)),Hf=f(d.createSelector([Ho,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Wf=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],Wo=pi.reducer,Te=I(t=>t.uuid),Ko=Te.getInitialState({}),Ai=d.createSlice({name:"issueTypeFieldValues",initialState:Ko,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Ko)),reducers:{initializeIssueTypeFieldValues:Te.initialize,addIssueTypeFieldValues:Te.addOne,addIssueTypeFieldValuesMany:Te.addMany,setIssueTypeFieldValues:Te.setOne,setIssueTypeFieldValuesMany:Te.setMany,updateIssueTypeFieldValues:Te.updateOne,updateIssueTypeFieldValuesMany:Te.updateMany,deleteIssueTypeFieldValues:Te.deleteOne,deleteIssueTypeFieldValuesMany:Te.deleteMany}}),{initializeIssueTypeFieldValues:Yo,addIssueTypeFieldValues:yi,addIssueTypeFieldValuesMany:Kf,setIssueTypeFieldValues:Yf,setIssueTypeFieldValuesMany:Jf,updateIssueTypeFieldValues:nt,updateIssueTypeFieldValuesMany:Zf,deleteIssueTypeFieldValues:fi,deleteIssueTypeFieldValuesMany:Xf}=Ai.actions,Jo=t=>t.issueTypeFieldValuesReducer.instances,Si=d.createSelector([Jo],t=>Object.values(t)),Qf=f(d.createSelector([Si,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue===e)))),gi=t=>e=>e.issueTypeFieldValuesReducer.instances[t],Zo=Ai.reducer,Ie=I(t=>t.uuid),Xo=Ie.getInitialState({}),bi=d.createSlice({name:"issueTypeFields",initialState:Xo,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Xo)),reducers:{initializeIssueTypeFields:Ie.initialize,addIssueTypeFields:Ie.addOne,addIssueTypeFieldsMany:Ie.addMany,setIssueTypeFields:Ie.setOne,setIssueTypeFieldsMany:Ie.setMany,updateIssueTypeFields:Ie.updateOne,updateIssueTypeFieldsMany:Ie.updateMany,deleteIssueTypeFields:Ie.deleteOne,deleteIssueTypeFieldsMany:Ie.deleteMany}}),{initializeIssueTypeFields:Qo,addIssueTypeFields:xo,addIssueTypeFieldsMany:xf,setIssueTypeFields:eS,setIssueTypeFieldsMany:tS,updateIssueTypeFields:el,updateIssueTypeFieldsMany:sS,deleteIssueTypeFields:tl,deleteIssueTypeFieldsMany:aS}=bi.actions,sl=t=>t.issueTypeFieldsReducer.instances,Vt=d.createSelector([sl],t=>Object.values(t)),iS=f(d.createSelector([Vt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue_type===e)))),cS=f(d.createSelector([Vt,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,i)=>s.submitted_at>i.submitted_at?-1:1)[0])),nS=f(d.createSelector([Vt,Si,(t,e)=>e],(t,e,s)=>{const i=new Set(t.filter(c=>c.issue_type===s).map(c=>c.uuid));return g(e.filter(c=>i.has(c.fields_revision)))})),rS=t=>e=>e.issueTypeFieldsReducer.instances[t],al=bi.reducer,_e=I(t=>t.uuid),il=_e.getInitialState({}),Pi=d.createSlice({name:"issueTypeFieldValuesAttachments",initialState:il,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,il)),reducers:{initializeIssueTypeFieldValuesAttachments:_e.initialize,addIssueTypeFieldValuesAttachment:_e.addOne,addIssueTypeFieldValuesAttachments:_e.addMany,setIssueTypeFieldValuesAttachment:_e.setOne,setIssueTypeFieldValuesAttachments:_e.setMany,updateIssueTypeFieldValuesAttachment:_e.updateOne,updateIssueTypeFieldValuesAttachments:_e.updateMany,deleteIssueTypeFieldValuesAttachment:_e.deleteOne,deleteIssueTypeFieldValuesAttachments:_e.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:cl,addIssueTypeFieldValuesAttachment:dS,addIssueTypeFieldValuesAttachments:zt,setIssueTypeFieldValuesAttachment:uS,setIssueTypeFieldValuesAttachments:oS,updateIssueTypeFieldValuesAttachment:lS,updateIssueTypeFieldValuesAttachments:nl,deleteIssueTypeFieldValuesAttachment:hS,deleteIssueTypeFieldValuesAttachments:Ut}=Pi.actions,Fi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,rl=d.createSelector([Fi],t=>Object.values(t)),mS=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],dl=f(d.createSelector([Fi,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(i=>s.has(i.uuid)))})),ul=f(d.createSelector([rl,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),ol=Pi.reducer,D=I(t=>t.uuid),ll=D.getInitialState({}),Ti=d.createSlice({name:"issueTypes",initialState:ll,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,ll)),reducers:{initializeIssueTypes:D.initialize,addIssueType:D.addOne,addIssueTypes:D.addMany,setIssueType:D.setOne,setIssueTypes:D.setMany,updateIssueType:D.updateOne,updateIssueTypes:D.updateMany,deleteIssueType:D.deleteOne,deleteIssueTypes:D.deleteMany,removeIssueType:D.deleteOne}}),{initializeIssueTypes:hl,addIssueType:ml,addIssueTypes:pS,setIssueType:rt,setIssueTypes:AS,updateIssueType:pl,updateIssueTypes:yS,deleteIssueType:fS,deleteIssueTypes:SS,removeIssueType:Ii}=Ti.actions,Al=t=>t.issueTypeReducer.instances,yl=d.createSelector(Al,t=>Object.values(t)),_i=t=>e=>e.issueTypeReducer.instances[t],gS=t=>e=>{const s=[];for(const i of t){const c=e.issueTypeReducer.instances[i];c?s.push(c):console.warn("selectIssueTypesByIds: No issue type exists with the id",i)}return s},bS=f(d.createSelector([yl,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Oi=f(d.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue_type===e)))),PS=t=>e=>Oi(t)(e).length,fl=Ti.reducer,Oe=I(t=>t.uuid),Sl=Oe.getInitialState({}),Ri=d.createSlice({name:"issueUpdates",initialState:Sl,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,Sl)),reducers:{initializeIssueUpdates:Oe.initialize,addIssueUpdate:Oe.addOne,addIssueUpdates:Oe.addMany,setIssueUpdate:Oe.setOne,setIssueUpdates:Oe.setMany,updateIssueUpdate:Oe.updateOne,updateIssueUpdates:Oe.updateMany,deleteIssueUpdate:Oe.deleteOne,deleteIssueUpdates:Oe.deleteMany}}),{initializeIssueUpdates:gl,addIssueUpdate:bl,addIssueUpdates:Pl,setIssueUpdate:FS,setIssueUpdates:TS,updateIssueUpdate:IS,updateIssueUpdates:_S,deleteIssueUpdate:Fl,deleteIssueUpdates:Tl}=Ri.actions,Il=t=>t.issueUpdateReducer.instances,_l=f(d.createSelector([Il,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Ol=Ri.reducer,Re=I(t=>t.id),Rl=Re.getInitialState({currentUser:null}),vi=d.createSlice({name:"users",initialState:Rl,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Rl)),reducers:{initializeUsers:Re.initialize,setUsers:Re.setMany,setUser:Re.setOne,addUsers:Re.addMany,addUser:Re.addOne,updateUsers:Re.updateMany,updateUser:Re.updateOne,deleteUser:Re.deleteOne,deleteUsers:Re.deleteMany,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:vl,setUsers:OS,setUser:RS,addUsers:vS,addUser:wl,updateUsers:wS,updateUser:MS,deleteUser:Ml,deleteUsers:ES,setCurrentUser:jS,setProfilePicture:qS}=vi.actions,El=vi.reducer,jl=t=>t.userReducer.currentUser,Dt=t=>t.userReducer.instances,wi=d.createSelector([Dt],t=>Object.values(t)),ql=t=>e=>e.userReducer.instances[t],VS=f(d.createSelector([Dt,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectUsersByIds: No user exists with the uuid",i)}return g(s)})),ve=I(t=>t.uuid),Vl=ve.getInitialState({}),Mi=d.createSlice({name:"organizationAccess",initialState:Vl,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Vl)),reducers:{initializeOrganizationAccesses:ve.initialize,addOrganizationAccess:ve.addOne,addOrganizationAccesses:ve.addMany,setOrganizationAccess:ve.setOne,setOrganizationAccesses:ve.setMany,updateOrganizationAccess:ve.updateOne,updateOrganizationAccesses:ve.updateMany,deleteOrganizationAccess:ve.deleteOne,deleteOrganizationAccesses:ve.deleteMany}}),{initializeOrganizationAccesses:zl,addOrganizationAccess:Ul,addOrganizationAccesses:zS,setOrganizationAccess:US,setOrganizationAccesses:DS,updateOrganizationAccess:Ct,updateOrganizationAccesses:CS,deleteOrganizationAccess:Dl,deleteOrganizationAccesses:kS}=Mi.actions,Cl=Mi.reducer,Ei=t=>t.organizationAccessReducer.instances,ji=t=>e=>e.organizationAccessReducer.instances[t],BS=d.createSelector([jl,Ei],(t,e)=>Object.values(e).find(i=>i.user===(t==null?void 0:t.id))??null),kl=d.createSelector([Ei],t=>{const e={};for(const s of Object.values(t))e[s.user]=s;return ht(e)}),$S=f(d.createSelector([Dt,kl,(t,e)=>e],(t,e,s)=>g(Object.values(t).filter(i=>{const c=e[i.id];return!!c&&c.organization===s})))),we=I(t=>t.uuid),Bl=we.getInitialState({}),qi=d.createSlice({name:"organizations",initialState:Bl,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Bl)),reducers:{initializeOrganizations:we.initialize,setOrganizations:we.setMany,setOrganization:we.setOne,addOrganizations:we.addMany,addOrganization:we.addOne,updateOrganizations:we.updateMany,updateOrganization:we.updateOne,deleteOrganization:we.deleteOne,deleteOrganizations:we.deleteMany}}),{initializeOrganizations:GS,setOrganizations:$l,setOrganization:LS,addOrganizations:NS,addOrganization:HS,updateOrganizations:WS,updateOrganization:KS,deleteOrganization:YS,deleteOrganizations:JS}=qi.actions,Gl=t=>t.organizationReducer.instances,ZS=d.createSelector([Gl],t=>Object.values(t)),XS=t=>e=>e.organizationReducer.instances[t],Ll=qi.reducer,Nl=(t,e,s)=>{const i=t.uuid?t:{...t,uuid:Le.v4()};return{payload:i,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:i,BASE_URL:e,serviceName:s}}}}},Hl={deletedRequests:[],latestRetryTime:0},Vi=d.createSlice({name:"outbox",initialState:Hl,extraReducers:t=>t.addCase(F,e=>Object.assign(e,Hl)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...i}=t;return Nl(i,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}}}),QS=t=>t.outboxReducer.deletedRequests,xS=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Wl,markForDeletion:eg,markAsDeleted:Kl,_setLatestRetryTime:Yl}=Vi.actions,Jl=Vi.reducer,Me=I(t=>t.uuid),Zl=Me.getInitialState({}),zi=d.createSlice({name:"projectAccess",initialState:Zl,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,Zl)),reducers:{initializeProjectAccesses:Me.initialize,addProjectAccess:Me.addOne,addProjectAccesses:Me.addMany,setProjectAccess:Me.setOne,setProjectAccesses:Me.setMany,updateProjectAccess:Me.updateOne,updateProjectAccesses:Me.updateMany,deleteProjectAccess:Me.deleteOne,deleteProjectAccesses:Me.deleteMany}}),{initializeProjectAccesses:Xl,addProjectAccess:Ui,addProjectAccesses:Ql,setProjectAccess:tg,setProjectAccesses:sg,updateProjectAccess:dt,updateProjectAccesses:ag,deleteProjectAccess:Di,deleteProjectAccesses:xl}=zi.actions,eh=zi.reducer,Ci=t=>t.projectAccessReducer.instances,kt=d.createSelector(Ci,t=>Object.values(t)),ki=t=>e=>e.projectAccessReducer.instances[t],th=f(d.createSelector([Ci,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.project===e)))),ig=f(d.createSelector([kt,(t,e)=>e],(t,e)=>{const s={};for(const i of t.filter(c=>c.project===e))s[i.user]=i;return s})),cg=f(d.createSelector([wi,kt,(t,e)=>e],(t,e,s)=>{const i=new Set(e.filter(c=>c.project===s).map(c=>c.user));return g(t.filter(c=>i.has(c.id)))})),Ee=I(t=>t.uuid),sh=Ee.getInitialState({}),Bi=d.createSlice({name:"projectAttachments",initialState:sh,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,sh)),reducers:{initializeProjectAttachments:Ee.initialize,addProjectAttachment:Ee.addOne,addProjectAttachments:Ee.addMany,setProjectAttachment:Ee.setOne,setProjectAttachments:Ee.setMany,updateProjectAttachment:Ee.updateOne,updateProjectAttachments:Ee.updateMany,deleteProjectAttachment:Ee.deleteOne,deleteProjectAttachments:Ee.deleteMany}}),{initializeProjectAttachments:ah,addProjectAttachment:ng,addProjectAttachments:ih,setProjectAttachment:ch,setProjectAttachments:nh,updateProjectAttachment:rg,updateProjectAttachments:rh,deleteProjectAttachment:dh,deleteProjectAttachments:$i}=Bi.actions,uh=t=>t.projectAttachmentReducer.instances,oh=d.createSelector([uh],t=>Object.values(t)),lh=t=>e=>e.projectAttachmentReducer.instances[t],hh=f(d.createSelector([oh,(t,e)=>e],(t,e)=>g(t.filter(({project:s})=>e===s)))),mh=Bi.reducer,je=I(t=>t.uuid),ph=je.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),Gi=d.createSlice({name:"projectFiles",initialState:ph,extraReducers:t=>t.addMatcher(d.isAnyOf(F,M,O),e=>Object.assign(e,ph)),reducers:{initializeProjectFiles:je.initialize,setProjectFile:je.setOne,setProjectFiles:je.setMany,addProjectFile:je.addOne,addProjectFiles:je.addMany,updateProjectFile:je.updateOne,updateProjectFiles:je.updateMany,deleteProjectFile:je.deleteOne,deleteProjectFiles:je.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:Ah,setProjectFile:dg,setProjectFiles:ug,addProjectFile:og,addProjectFiles:yh,updateProjectFile:Li,updateProjectFiles:lg,deleteProjectFile:fh,deleteProjectFiles:Sh,setIsImportingProjectFile:gh,setActiveProjectFileId:bh,saveActiveProjectFileBounds:Ph,resetProjectFileObjectUrls:hg}=Gi.actions,Fh=t=>t.projectFileReducer.instances,Th=d.createSelector([Fh],t=>g(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),mg=t=>e=>e.projectFileReducer.instances[t],pg=t=>t.projectFileReducer.activeProjectFileId,Ag=t=>t.projectFileReducer.isImportingProjectFile,Ih=Gi.reducer,qe=I(t=>t.uuid),_h=qe.getInitialState({}),Ni=d.createSlice({name:"projects",initialState:_h,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,_h)),reducers:{initializeProjects:qe.initialize,setProjects:qe.setMany,setProject:qe.setOne,addProjects:qe.addMany,addProject:qe.addOne,updateProjects:qe.updateMany,updateProject:qe.updateOne,deleteProject:qe.deleteOne,deleteProjects:qe.deleteMany}}),{initializeProjects:Oh,setProjects:yg,setProject:fg,addProjects:Sg,addProject:Rh,updateProjects:gg,updateProject:vh,deleteProject:Hi,deleteProjects:bg}=Ni.actions,wh=Ni.reducer,Mh=t=>t.projectReducer.instances,Wi=d.createSelector([Mh],t=>g(Object.values(t))),Eh=t=>e=>e.projectReducer.instances[t],Pg=f(d.createSelector([Wi,kt,(t,e)=>e],(t,e,s)=>{const i=new Set(e.filter(c=>c.user===s).map(c=>c.project));return g(t.filter(c=>i.has(c.uuid)))})),Fg=f(d.createSelector([Wi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization_owner===e)))),Tg={isRehydrated:!1},Ki=d.createSlice({name:"rehydrated",initialState:Tg,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:Ig}=Ki.actions,_g=t=>t.rehydratedReducer.isRehydrated,jh=Ki.reducer,Ve=I(t=>t.uuid),qh=Ve.getInitialState({}),Yi=d.createSlice({name:"teamMemberships",initialState:qh,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,qh)),reducers:{initializeTeamMemberships:Ve.initialize,addTeamMembership:Ve.addOne,addTeamMemberships:Ve.addMany,setTeamMembership:Ve.setOne,setTeamMemberships:Ve.setMany,updateTeamMembership:Ve.updateOne,updateTeamMemberships:Ve.updateMany,deleteTeamMembership:Ve.deleteOne,deleteTeamMemberships:Ve.deleteMany}}),{initializeTeamMemberships:Vh,addTeamMembership:zh,addTeamMemberships:Og,setTeamMembership:Ji,setTeamMemberships:Rg,updateTeamMembership:vg,updateTeamMemberships:wg,deleteTeamMembership:Zi,deleteTeamMemberships:Mg}=Yi.actions,Uh=Yi.reducer,Dh=t=>t.teamMembershipReducer.instances,Xi=d.createSelector([Dh],t=>Object.values(t)),Ch=t=>e=>e.teamMembershipReducer.instances[t],Eg=f(d.createSelector([Xi,(t,e)=>e],(t,e)=>{const s={};for(const i of t.filter(c=>c.team===e))s[i.user]=i;return s})),jg=f(d.createSelector([wi,Xi,(t,e)=>e],(t,e,s)=>{const i=new Set(e.filter(c=>c.team===s).map(c=>c.user));return g(t.filter(c=>i.has(c.id)))})),ze=I(t=>t.uuid),kh=ze.getInitialState({}),Qi=d.createSlice({name:"teams",initialState:kh,extraReducers:t=>t.addMatcher(d.isAnyOf(F,O),e=>Object.assign(e,kh)),reducers:{initializeTeams:ze.initialize,addTeam:ze.addOne,addTeams:ze.addMany,setTeam:ze.setOne,setTeams:ze.setMany,updateTeam:ze.updateOne,updateTeams:ze.updateMany,deleteTeam:ze.deleteOne,deleteTeams:ze.deleteMany}}),{initializeTeams:Bh,addTeam:$h,addTeams:qg,setTeam:ut,setTeams:Vg,updateTeam:Gh,updateTeams:zg,deleteTeam:xi,deleteTeams:Ug}=Qi.actions,ec=t=>t.teamReducer.instances,Lh=d.createSelector([ec],t=>Object.values(t)),tc=t=>e=>e.teamReducer.instances[t],Dg=f(d.createSelector([ec,(t,e)=>e],(t,e)=>{const s=[];for(const i of e){const c=t[i];c?s.push(c):console.warn("selectTeamsByIds: No team exists with the id",i)}return g(s)})),Cg=f(d.createSelector([Lh,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Nh=Qi.reducer,kg={version:0},Hh=d.createSlice({name:"versioning",initialState:kg,reducers:{}}),Wh=Hh.reducer,sc={outboxReducer:Jl,fileReducer:tu,authReducer:gd},Bg=d.combineReducers(sc),Kh={...sc,[Je]:Wh,categoryReducer:_d,assetReducer:Ar,assetAttachmentReducer:Dc,assetStageCompletionReducer:br,assetStageReducer:Or,assetTypeReducer:yd,assetTypeAttachmentReducer:Dr,issueReducer:vo,issueAttachmentReducer:uo,issueTypeReducer:fl,issueTypeAttachmentReducer:Co,organizationReducer:Ll,projectReducer:wh,projectAttachmentReducer:mh,projectAccessReducer:eh,organizationAccessReducer:Cl,projectFileReducer:Ih,rehydratedReducer:jh,formReducer:gu,formRevisionReducer:yu,formRevisionAttachmentReducer:du,formSubmissionAttachmentReducer:vu,formSubmissionReducer:zu,userReducer:El,emailDomainsReducer:Zd,documentsReducer:Ld,documentAttachmentReducer:Ud,teamReducer:Nh,agentsReducer:vc,issueCommentReducer:To,issueCommentAttachmentReducer:go,issueUpdateReducer:Ol,geoImageReducer:Hu,issueAssociationReducer:xu,issueTypeFieldsReducer:al,issueTypeFieldValuesReducer:Zo,issueTypeFieldsAttachmentReducer:Wo,issueTypeFieldValuesAttachmentReducer:ol,assetTypeFieldsReducer:Qr,assetTypeFieldValuesReducer:hd,assetTypeFieldsAttachmentReducer:Hr,assetTypeFieldValuesAttachmentReducer:cd,assetProcedureReducer:Vn,assetProcedureInstanceReducer:Mn,assetProcedureFieldsReducer:on,assetProcedureFieldValuesReducer:In,assetProcedureFieldsAttachmentReducer:sn,assetProcedureFieldValuesAttachmentReducer:fn,assetProcedureAttachmentReducer:Yc,assetProcedureStepFieldsAttachmentReducer:Gn,assetProcedureStepFieldsReducer:Hn,assetProcedureStepFieldValuesAttachmentReducer:Qn,assetProcedureStepFieldValuesReducer:cr,assetProcedureStepReducer:ur,teamMembershipReducer:Uh},$g=d.combineReducers(Kh);let Yh;function Gg(t){Yh=t}function ot(){return Yh}let Jh;function Lg(t){Jh=t}function Ng(){return Jh}const Zh={};class Xh{constructor(e){S(this,"client");Zh[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 Qh=()=>tm.length-1,xh=t=>(t[Je]={version:Qh()},t),em=()=>xh({}),Hg=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Wg=t=>e=>{var s;return e===void 0&&(e={}),((s=e[Je])==null?void 0:s.version)===Qh()?e:t(e)},tm=[xh,em,em,Hg],Kg=Object.fromEntries(tm.map((t,e)=>[e,Wg(t)]));let ac=null;function ke(){const t=ot();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(ac)return ac;const e=t.getState().offline.outbox,s=Ke._fromOutbox(e);return ac=s,s}const Yg=t=>{if(t)throw t;const e=ot();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},sm=(t,e,s)=>{const i=ke();return i?(i.addRequest(e),i.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},am=(t,e,s)=>{const i=ke();if(!i)return console.warn("Outbox coordinator not set; cannot dequeue request yet."),[];const n=e.meta.offlineAction.payload.uuid;return i.remove(n),i.getQueue()};async function Jg(t,e){if(!e.payload)throw new Error("Received empty payload");return ib(e)}const Zg={...uc,effect:Jg,discard:cc,returnPromises:!0,persistCallback:Yg,retry:nb,persistOptions:{storage:lm},queue:{...uc.queue,enqueue:sm,dequeue:am,peek:(...t)=>cb(...t)}},Xg=hm(Kg,Je),Qg=d.compose(om.offline(Zg),Xg);function xg(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(c=>c 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 ic(t,e){const s=Zh[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const i=s instanceof R;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");i&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const n={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:o,headers:m,method:u,queryParams:l,attachmentHash:p,isExternalUrl:A,isAuthNeeded:y,isResponseBlob:b}={...n,...r.request},P=r.request;let _=P.url;const w=p?await e.files.fetchCache(p):void 0;if(p&&!w)throw new Error(`Cannot upload file ${p} because it's not cached.`);!A&&!_.startsWith("http")&&(!_.startsWith("/")&&!_.startsWith("blob:")&&(_="/"+_),_=t.meta.offline.effect.BASE_URL+_);const q=V=>{if(p){const Ue=P.s3url;if(!Ue)throw new Error(`No S3 URL for file ${p}`);if("warning"in Ue)throw new Error(`S3 URL warning for file ${p}`);if(!w)throw new Error(`No file for file ${p}`);const lt=Ue.fields["x-amz-checksum-sha1"];if(!lt)throw new Error(`No checksum for file ${p}`);return V.set("x-amz-checksum-sha1",lt).field({...o,...Ue.fields}).attach("file",w)}return V.send(o)},SP={[h.GET]:()=>b?Ge.get(_.toString()).responseType("blob"):Ge.get(_.toString()),[h.POST]:()=>{const V=Ge.post(_.toString());return q(V)},[h.PATCH]:()=>{const V=Ge.patch(_.toString());return q(V)},[h.PUT]:()=>{const V=Ge.put(_.toString());return q(V)},[h.DELETE]:()=>{const V=Ge.delete(_.toString());return q(V)}}[u];let $e=SP();if(y&&i){const V=s.auth.getAuthHeader();$e=$e.set("Authorization",V)}m&&($e=$e.set(m));try{return await $e.query(l)}catch(V){const Ue=xg(V),lt=Ue==null?void 0:Ue.status;if(i&<===401)return await s.auth.handleUnauthorized($e,Ue),$e.query(l);throw new U({response:Ue,innerError:V,discard:cm.includes(lt)})}}class eb{constructor(e){S(this,"_all");S(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 im{constructor(){S(this,"next");this.next=null}then(e){return new eb(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!ot())throw new Error("Client store not set");const i=Ng();if(!i)throw new Error("Client SDK not set");return ic(e,i)}}}class tb extends im{async run(e){return super.run(e)}}class sb extends im{async run(e){return super.run(e)}}const ab=new tb().then(new sb).compile();function ib(t){var e;return(e=ab[0])==null?void 0:e.run(t)}const cm=[400,409,403,404,405,500];function cc(t,e,s=0){var u;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 i=ot(),n=i.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function o(){i.dispatch(
|
|
5
|
-
Action:`,e);const p=ke();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=ke();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cb(t,e,s){var i;return(i=ke())==null?void 0:i.peek()}function nb(t,e){return ot().dispatch(
|
|
4
|
+
Retries:`,s),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ERROR:",t,"(throwing immediately, which may lead to unexpected behavior)"),t;const i=ot(),n=i.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function o(){i.dispatch(Kl(r));const l=ke();if(!l)throw new Error("Outbox coordinator not set");l.remove(e.payload.uuid);const p=e.meta.offline.rollback;throw p&&(console.warn("Rolling back request due to SDK error:",e),i.dispatch(p)),t}if(t instanceof U&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),o();if(n.includes(r))return console.debug("Discarding request due to deletion:",e),o();if(t instanceof U){const l=t.status||((u=t.response)==null?void 0:u.status);if(l||console.warn("Error has no status code:",t),l!==void 0&&cm.includes(l)){console.warn("Discarding request due to error:",t,`
|
|
5
|
+
Action:`,e);const p=ke();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=ke();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cb(t,e,s){var i;return(i=ke())==null?void 0:i.peek()}function nb(t,e){return ot().dispatch(Yl(new Date().getTime())),pc}const We="An unknown error occurred",rb=500,nm=["non_field_errors","detail"];function db(t,e){let s;if(t!=null&&t.body)if(typeof t.body=="object"){const i=t.body;if(typeof i.error=="string")s=i.error;else if(typeof i.message=="string")s=i.message;else try{s=Object.entries(i).map(([c,n])=>typeof n=="string"?nm.includes(c)?n:`${c}: ${n}`:Array.isArray(n)?nm.includes(c)?n.join(`
|
|
6
6
|
`):n.map(r=>`${c}: ${r}`).join(`
|
|
7
7
|
`):`${c}: ${JSON.stringify(n)}`).join(`
|
|
8
|
-
`)}catch(c){console.error("Failed to extract error message from response body",c)}}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>rb?We:s}class D extends Error{constructor(s){super(We);S(this,"status");S(this,"response");S(this,"message");S(this,"options");const{response:i,innerError:c}=s;this.message=s.message??db(i,c)??We,this.status=(i==null?void 0:i.status)??0,this.response=i,s.discard=s.discard??!1,this.options=s}}class ub extends tm{constructor(e){super(e)}}class R extends tm{constructor(s,i){super(s);S(this,"auth");this.auth=i}}class ob extends R{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(i=>(this.dispatch(Rc(i)),i))}async continueConversation(e,s,i){return this.enqueueRequest({description:"Prompt agent",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:i},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(c=>{this.dispatch(wc(c))})}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(vc(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:"/agents/conversations/",queryParams:{project:e},blockers:["agent-conversations"],blocks:["agent-conversations"]});return this.dispatch(Oc(s)),s}}class j extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:i,assetTypeAttachmentReducer:c,documentAttachmentReducer:n,projectAttachmentReducer:r,formRevisionAttachmentReducer:o,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:l,assetTypeFieldValuesAttachmentReducer:p,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(i.instances),Object.values(c.instances),Object.values(n.instances),Object.values(r.instances),Object.values(o.instances),Object.values(m.instances),Object.values(d.instances),Object.values(l.instances),Object.values(p.instances),Object.values(A.instances),Object.values(y.instances)).filter(F=>F.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[i,c]of Object.entries(e))s[i]=this.enqueueRequest({url:c.url,description:"Upload file to S3",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:i,blockers:[`s3-${c.fields.key}`],blocks:[i],s3url:c});return s}async getFilePayload(e){const s=await Ne(e),i={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),i}}class Ue extends j{async _bulkAdd(e){var d;const{store:s}=this.client,i=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=new Date().toISOString(),n=[],r=[],o={};for(const l of e){const{modelUuid:p,file:A}=l,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:c,created_by:i,description:"",modelUuid:p});n.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(n));const m=this.enqueueRequest({description:`Add ${this.name}`,method:h.POST,url:`${this.url}/bulk/`,payload:{submitted_at:c,attachments:r,files:Object.values(o)},blocks:n.map(l=>l.uuid),blockers:n.map(l=>l.file_sha1)});return m.then(({attachments:l,presigned_urls:p})=>{this.dispatch(this.updateAttachments(l)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(n.map(l=>l.uuid)))}),[n,m.then(({attachments:l})=>l)]}async _delete(e){const{store:s}=this.client,i=this.selectAttachment(e)(s.getState());if(!i)throw new Error(`Attempting to delete attachment with uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(i.uuid));const c=this.enqueueRequest({description:`Delete ${this.name}`,method:h.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return c.then(()=>{this.getNumberOfAttachmentsWithSha1(i.file_sha1)===0&&this.client.files.removeCache(i.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(i))}),c}}class lb extends Ue{constructor(){super(...arguments);S(this,"name","Asset Attachment");S(this,"url","/asset-attachments");S(this,"initializeAttachments",Xt);S(this,"addAttachments",Qt);S(this,"updateAttachments",qc);S(this,"removeAttachments",xt);S(this,"removeAttachment",Vc);S(this,"setAttachment",jc);S(this,"selectAttachment",Cc)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.assetUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset__project:s},blocks:[],blockers:[]});return this.dispatch(Xt(i)),i}}class hb extends Ue{constructor(){super(...arguments);S(this,"name","Asset Procedure Attachment");S(this,"url","/asset-procedure-attachments");S(this,"addAttachments",Gc);S(this,"updateAttachments",Nc);S(this,"removeAttachments",Wc);S(this,"removeAttachment",Hc);S(this,"setAttachment",Lc);S(this,"selectAttachment",Jc)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.assetProcedureUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset procedure attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_procedure__organization:s},blocks:[],blockers:[]});return this.dispatch($c(i)),i}}class mb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(b);const F={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(F)}this.dispatch(xc(n));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(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(en(d.attachments))}).catch(()=>{this.dispatch(tn(n.map(d=>d.uuid)))}),[n,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:{fields_revision__asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(Qc(s)),s}}class pb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(dn(n));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:h.POST,url:"/asset-procedure-fields/",payload:w(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(un(m))}).catch(m=>{throw this.dispatch(on(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:h.GET,url:"/asset-procedure-fields/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(rn(s)),s}}function Be(t,e){const s=[];let i=0;const c=t.length;for(;i<c;)s.push(t.slice(i,i+=e));return s}class Ab extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=Be(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:b,fieldIdentifier:F,file:_}=y,v=await this.getFilePayload(_);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:v.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:F});r.push(q);const Ye={uuid:q.uuid,file_name:_.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:F,field_values:b};A.push(Ye)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(mt(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:h.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(An(p))}).catch(l=>{throw this.dispatch(pt(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=fn(e)(i);this.dispatch(pt(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:h.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:e,blockers:e,blocks:[]})}catch(n){throw this.dispatch(mt(c)),n}}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:{field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(pn(s)),s}}class yb extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(rs(c)),n.then(o=>(this.dispatch(Ze(o)),o)).catch(()=>{this.dispatch(ds(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=Be(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),l.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:i,values:e.values,field_values:l})}this.dispatch(Pn(c));const o=[];for(const d of r){const l=d.field_values.map(F=>F.asset),p=d.field_values.map(F=>F.fields_revision),A=d.field_values.map(F=>F.asset_procedure_instance),y=d.field_values.map(F=>F.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/bulk/",payload:d,blockers:[...l,...p,...A],blocks:y});o.push(b)}return Promise.all(o).then(d=>{this.dispatch(Tn(d.flat()))}).catch(()=>{this.dispatch(In(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.getState(),c=os(e.uuid)(i);if(!c)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(Ze(n));const r=this.enqueueRequest({description:"Update asset procedure field values",method:h.PATCH,url:`/asset-procedure-field-values/${e.uuid}/`,payload:e,blockers:[n.fields_revision,n.asset,n.asset_procedure_instance],blocks:[n.uuid]});return r.then(o=>{this.dispatch(Ze(o))}).catch(()=>{this.dispatch(Ze(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=os(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=Sn(e)(i);this.dispatch(ds(e)),this.dispatch(pt(n.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(rs(c)),this.dispatch(mt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:h.GET,url:"/asset-procedure-field-values/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(Fn(s)),s}}class fb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(hs(n));const r=this.enqueueRequest({description:"Create asset procedure instance",method:h.POST,url:"/asset-procedure-instances/",payload:w(n),blockers:[e.asset_procedure,e.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Xe(m))}).catch(()=>{this.dispatch(ms(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=ys(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Xe(c));const n=this.enqueueRequest({description:"Update asset procedure instance",method:h.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Xe(r))}).catch(()=>{this.dispatch(Xe(i))}),[c,n]}async remove(e){const{store:s}=this.client,i=s.getState(),c=ys(e)(i);if(!c)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(ms(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:h.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(hs(c)),n})}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:[]});return this.dispatch(vn(s)),s}}class Sb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Ss(n));const r=this.enqueueRequest({description:"Create asset procedure",method:h.POST,url:"/asset-procedures/",payload:w(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Qe(m))}).catch(()=>{this.dispatch(gs(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Fs(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Qe(c));const n=this.enqueueRequest({description:"Update asset procedure",method:h.PATCH,url:`/asset-procedures/${e.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Qe(r))}).catch(()=>{this.dispatch(Qe(i))}),[c,n]}async remove(e){const{store:s}=this.client,i=s.getState(),c=Fs(e)(i);if(!c)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const n=En(e)(i);return this.dispatch(gs(e)),this.dispatch(Mn(n.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(Ss(c)),this.dispatch(wn(n)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:h.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(Vn(s)),s}}class gb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(b);const F={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(F)}this.dispatch(kn(n));const o=this.enqueueRequest({description:"Add asset procedure step fields attachments",method:h.POST,url:"/asset-procedure-step-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Bn(d.attachments))}).catch(()=>{this.dispatch($n(n.map(d=>d.uuid)))}),[n,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step fields attachments",method:h.GET,url:"/asset-procedure-step-fields-attachments/",queryParams:{fields_revision__asset_procedure_step__organization:e},blockers:[],blocks:[]});return this.dispatch(Un(s)),s}}class bb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Is(n));const r=this.enqueueRequest({description:"Add Asset Procedure Step Fields",method:h.POST,url:"/asset-procedure-step-fields/",payload:w(n),blockers:[n.asset_procedure_step],blocks:[n.uuid]});return r.then(m=>{this.dispatch(xe(m))}).catch(m=>{throw this.dispatch(_s(n.uuid)),m}),[n,r]}update(e){const{store:s}=this.client,i=s.getState().assetProcedureStepFieldsReducer.instances[e.uuid];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e.uuid} not found`);const c={...i,...e};this.dispatch(xe(c));const n=this.enqueueRequest({description:"Update Asset Procedure Step Fields",method:h.PATCH,url:`/asset-procedure-step-fields/${i.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(xe(r))}).catch(r=>{throw this.dispatch(xe(i)),r}),[c,n]}delete(e){const{store:s}=this.client,i=s.getState().assetProcedureStepFieldsReducer.instances[e];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e} not found`);this.dispatch(_s(e));const c=this.enqueueRequest({description:"Delete Asset Procedure Step Fields",method:h.DELETE,url:`/asset-procedure-step-fields/${e}/`,blockers:[e],blocks:[e]});return c.catch(n=>{throw this.dispatch(Is(i)),n}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Step Fields",method:h.GET,url:"/asset-procedure-step-fields/",queryParams:{asset_procedure_step__asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(Wn(s)),s}}class Fb extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=Be(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:b,fieldIdentifier:F,file:_}=y,v=await this.getFilePayload(_);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:v.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:F});r.push(q);const Ye={uuid:q.uuid,file_name:_.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:F,field_values:b};A.push(Ye)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(At(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset procedure step field values attachments",method:h.POST,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(Zn(p))}).catch(l=>{throw this.dispatch(yt(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=Qn(e)(i);this.dispatch(yt(e));try{await this.enqueueRequest({description:"Delete asset procedure step field values attachments",method:h.DELETE,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:e,blockers:e,blocks:[]})}catch(n){throw this.dispatch(At(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step field values attachments",method:h.GET,url:"/asset-procedure-step-field-values-attachments/",queryParams:{field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(Jn(s)),s}}class Pb extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(Es(c)),n.then(o=>(this.dispatch(et(o)),o)).catch(()=>{this.dispatch(js(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=Be(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),l.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,asset_procedure_step:p.asset_procedure_step,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:l})}this.dispatch(ar(c));const o=[];for(const d of r){const l=d.field_values.map(F=>F.asset),p=d.field_values.map(F=>F.fields_revision),A=d.field_values.map(F=>F.asset_procedure_instance),y=d.field_values.map(F=>F.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/bulk/",payload:d,blockers:[...l,...p,...A],blocks:y});o.push(b)}return Promise.all(o).then(d=>{this.dispatch(ir(d.flat()))}).catch(()=>{this.dispatch(cr(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.getState(),c=qs(e.uuid)(i);if(!c)throw new Error(`Expected AssetProcedureStepFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(et(n));const r=this.enqueueRequest({description:"Update asset procedure step field values",method:h.PATCH,url:`/asset-procedure-step-field-values/${e.uuid}/`,payload:e,blockers:[n.fields_revision,n.asset,n.asset_procedure_instance],blocks:[n.uuid]});return r.then(o=>{this.dispatch(et(o))}).catch(()=>{this.dispatch(et(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=qs(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=xn(e)(i);this.dispatch(js(e)),this.dispatch(yt(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure step field values",method:h.DELETE,url:`/asset-procedure-step-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Es(c)),this.dispatch(At(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step field values",method:h.GET,url:"/asset-procedure-step-field-values/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(sr(s)),s}}class Tb extends R{bulkAdd(e,s){var m;const i=new Date().toISOString(),c=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n=e.map(d=>T(d)),r=n.map(d=>({...d,asset_procedure:s,created_by:c,submitted_at:i}));this.dispatch(zs(r));const o=this.enqueueRequest({description:"Add asset procedure steps",method:h.POST,url:"/asset-procedure-steps/bulk/",payload:{submitted_at:i,asset_procedure:s,steps:n},blockers:[s],blocks:n.map(({uuid:d})=>d)});return o.then(d=>{this.dispatch(St(d))}).catch(()=>{this.dispatch(Cs(r.map(({uuid:d})=>d)))}),[r,o]}async bulkUpdate(e,s){const c=this.client.store.getState(),n=Us(e.map(({uuid:r})=>r))(c);return this.dispatch(St(e)),this.enqueueRequest({description:"Edit asset procedure steps",method:h.PATCH,url:`/asset-procedures/${s}/bulk-update-steps/`,payload:{steps:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(St(n)),r})}async bulkDelete(e){const{store:s}=this.client,i=Us(e)(s.getState());this.dispatch(Cs(e));const c=this.enqueueRequest({description:"Delete asset procedure steps",method:h.DELETE,url:"/asset-procedure-steps/bulk/",payload:e,blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(zs(i))}),c}update(e){const{store:s}=this.client,i=hr(e.uuid)(s.getState());if(!i)throw new Error(`No asset procedure step with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(Ds(c));const n=this.enqueueRequest({description:"Update asset procedure step",method:h.PATCH,url:`/asset-procedure-steps/${i.uuid}/`,payload:{name:e.name,description:e.description,priority:e.order,color:e.color},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Ds(r))}).catch(()=>{this.dispatch(or(i))}),[c,n]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure steps",method:h.GET,url:"/asset-procedure-steps/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(ur(s)),s}}class Ib extends R{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 i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Bs(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/assets/",payload:w(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(tt(m))}).catch(()=>{this.dispatch($s(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Hs(e.uuid)(s.getState());if(!i)throw new Error(`No asset with uuid ${e.uuid} found in the store`);const c={...i,...e};if(!c.canvas_marker&&!c.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(tt(c));const n=this.enqueueRequest({description:"Edit asset",method:h.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(tt(r))}).catch(()=>{this.dispatch(tt(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Hs(e)(i);if(!c)throw new Error(`No asset with uuid ${e} found in the store`);const n=Uc(e)(i),r=Uu(e)(i),o=so(e)(i);if(this.dispatch($s(e)),n.length>0){const m=n.map(({uuid:d})=>d);this.dispatch(xt(m))}if(r.length>0){const m=r.map(({uuid:d})=>d);this.dispatch(jt(m))}if(o.length>0){const m=o.map(({uuid:d})=>d);this.dispatch(Xa(m))}return this.enqueueRequest({description:"Delete asset",method:h.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(Bs(c)),this.dispatch(Qt(n)),this.dispatch(Et(r)),this.dispatch(Ja(o)),m})}bulkAdd(e,s,i,c){const n=new Date().toISOString(),r=Le.v4(),o=Be(e,c).map(l=>{const p=l.map(A=>T(A));return{batchId:Le.v4(),payload:{transaction_id:r,submitted_at:n,asset_type:s,project:i,assets:p}}}),m=[];let d=null;for(const l of o){const{batchId:p,payload:A}=l,y=A.assets.map(v=>v.uuid),b=[s];d&&b.push(d);const F=y;F.push(p);const _=this.enqueueRequest({description:"Batch create assets",method:h.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:F});d=l.batchId,m.push(_)}return Promise.all(m).then(l=>{const p=l.flat();this.dispatch(bt(p))}),m}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=fr(e)(i);this.dispatch(Gs(e));try{await this.enqueueRequest({description:"Bulk delete assets",method:h.DELETE,url:"/assets/bulk/",payload:e,blockers:e,blocks:[]})}catch(n){throw this.dispatch(bt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:h.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(Ar(s)),s}}class _b extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Ks(n));const r=this.enqueueRequest({description:"Add asset stage completion",method:h.POST,url:"/asset-stage-completions/",payload:w(n),blockers:[e.asset,e.stage],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Fr(m))}).catch(()=>{this.dispatch(Js(n.uuid))}),[n,r]}delete(e){const{store:s}=this.client,i=Ir(e)(s.getState());if(!i)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(Js(e));const c=this.enqueueRequest({description:"Delete asset stage completion",method:h.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(Ks(i))}),c}bulkAdd(e){var d;const{store:s}=this.client,i=new Date().toISOString(),c=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,n=e.map(l=>T(l)),r=n.map(l=>({...l,created_by:c,submitted_at:i})),o=r.map(({uuid:l})=>l);this.dispatch(Ys(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:h.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:i,completions:n},blockers:[...e.map(l=>l.asset_procedure_instance),...e.map(l=>l.stage),...e.map(l=>l.asset)],blocks:o});return m.then(l=>{this.dispatch(Pr(l))}).catch(()=>{this.dispatch(Zs(o))}),[r,m]}bulkDelete(e){const{store:s}=this.client,i=_r(e)(s.getState());this.dispatch(Zs(e));const c=this.enqueueRequest({description:"Deleting asset stage completions",method:h.DELETE,url:"/asset-stage-completions/bulk/",payload:e,blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(Ys(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:h.GET,url:"/asset-stage-completions/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(br(s)),s}}class Ob extends R{bulkAdd(e,s){var m;const i=new Date().toISOString(),c=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n=e.map(d=>T(d)),r=n.map(d=>({...d,asset_procedure:s,created_by:c,submitted_at:i}));this.dispatch(xs(r));const o=this.enqueueRequest({description:"Add asset stages",method:h.POST,url:"/asset-stages/bulk/",payload:{submitted_at:i,asset_procedure:s,stages:n},blockers:[s],blocks:n.map(({uuid:d})=>d)});return o.then(d=>{this.dispatch(Ft(d))}).catch(()=>{this.dispatch(ta(r.map(({uuid:d})=>d)))}),[r,o]}async bulkUpdate(e,s){const c=this.client.store.getState(),n=sa(e.map(({uuid:r})=>r))(c);return this.dispatch(Ft(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(Ft(n)),r})}async bulkDelete(e){const{store:s}=this.client,i=sa(e)(s.getState());this.dispatch(ta(e));const c=this.enqueueRequest({description:"Delete asset stages",method:h.DELETE,url:"/asset-stages/bulk/",payload:e,blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(xs(i))}),c}update(e){const{store:s}=this.client,i=Mr(e.uuid)(s.getState());if(!i)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(ea(c));const n=this.enqueueRequest({description:"Update asset stage",method:h.PATCH,url:`/asset-stages/${i.uuid}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(ea(r))}).catch(()=>{this.dispatch(vr(i))}),[c,n]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:h.GET,url:"/asset-stages/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(Rr(s)),s}}class Rb extends Ue{constructor(){super(...arguments);S(this,"name","Asset Type Attachment");S(this,"url","/asset-type-attachments");S(this,"addAttachments",ia);S(this,"updateAttachments",zr);S(this,"removeAttachments",ca);S(this,"removeAttachment",Dr);S(this,"setAttachment",Vr);S(this,"selectAttachment",kr)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.assetTypeUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset type attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_type__organization:s},blocks:[],blockers:[]});return this.dispatch(qr(i)),i}}class vb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(b);const F={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(F)}this.dispatch(Nr(n));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(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Hr(d.attachments))}).catch(()=>{this.dispatch(Wr(n.map(d=>d.uuid)))}),[n,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:{fields_revision__asset_type__organization:e},blockers:[e],blocks:[]});return this.dispatch(Lr(s)),s}}class wb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Qr(n));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:h.POST,url:"/asset-type-fields/",payload:w(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(xr(m))}).catch(m=>{throw this.dispatch(ed(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:h.GET,url:"/asset-type-fields/",queryParams:{asset_type__organization:e},blockers:[],blocks:[]});return this.dispatch(Xr(s)),s}}class Mb extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=Be(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:b,fieldIdentifier:F,file:_}=y,v=await this.getFilePayload(_);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:v.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:F});r.push(q);const Ye={uuid:q.uuid,file_name:_.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:F,field_values:b};A.push(Ye)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(It(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset type field values attachments",method:h.POST,url:"/asset-type-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(cd(p))}).catch(l=>{throw this.dispatch(_t(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=rd(e)(i);this.dispatch(_t(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:h.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:e,blockers:e,blocks:[]})}catch(n){throw this.dispatch(It(c)),n}}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:{field_values__asset__project:e},blockers:[],blocks:[]});return this.dispatch(id(s)),s}}class Eb extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset type field values",method:h.POST,url:"/asset-type-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision],blocks:[c.uuid]});return this.dispatch(la(c)),n.then(o=>(this.dispatch(st(o)),o)).catch(()=>{this.dispatch(ha(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=Be(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),l.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:l})}this.dispatch(hd(c));const o=[];for(const d of r){const l=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:[...l,...p],blocks:A});o.push(y)}return Promise.all(o).then(d=>{this.dispatch(md(d.flat()))}).catch(()=>{this.dispatch(pd(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.getState(),c=pa(e.uuid)(i);if(!c)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(st(n));const r=this.enqueueRequest({description:"Delete asset type field values",method:h.PATCH,url:`/asset-type-field-values/${e.uuid}/`,payload:e,blockers:[n.uuid,n.fields_revision,n.asset],blocks:[n.uuid]});return r.then(o=>{this.dispatch(st(o))}).catch(()=>{this.dispatch(st(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=pa(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=dd(e)(i);this.dispatch(ha(e)),this.dispatch(_t(n.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(la(c)),this.dispatch(It(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:h.GET,url:"/asset-type-field-values/",queryParams:{asset__project:e},blockers:[],blocks:[]});return this.dispatch(ld(s)),s}}class jb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(ya(n));const r=this.enqueueRequest({description:"Create asset type",method:h.POST,url:"/asset-types/",payload:w(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(at(m))}).catch(()=>{this.dispatch(fa(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=ga(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(at(c));const n=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:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(at(r))}).catch(()=>{this.dispatch(at(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=ga(e)(i);if(!c)throw new Error(`Expected asset type with uuid ${e} to exist`);const n=Ns(e)(i),r=Br(e)(i);return this.dispatch(fa(e)),this.dispatch(Gs(n.map(o=>o.uuid))),this.dispatch(ca(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(ya(c)),this.dispatch(bt(n)),this.dispatch(ia(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:[]});return this.dispatch(Sd(s)),s}}class qb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Fa(n));const r=this.enqueueRequest({description:"Create Category",method:h.POST,url:"/categories/",payload:w(n),blockers:[e.project],blocks:[n.uuid]});return[n,r]}update(e){const s=this.client.store.getState(),i=Ta(e.uuid)(s);if(!i)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const c={...i,...e};this.dispatch(Od(c));const n=this.enqueueRequest({description:"Edit Category",method:h.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[c,n]}remove(e){const{store:s}=this.client,i=Ta(e)(s.getState());if(!i)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(Rd(e));const c=this.enqueueRequest({description:"Delete Category",method:h.DELETE,url:`/categories/${i.uuid}/`,blockers:[i.uuid],blocks:[]});return c.catch(()=>{this.dispatch(Fa(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:h.GET,url:"/categories/",queryParams:{project__organization_owner:e},blocks:[],blockers:[]});return this.dispatch(_d(s)),s}}class Vb extends Ue{constructor(){super(...arguments);S(this,"name","Document Attachment");S(this,"url","/document-attachments");S(this,"addAttachments",jd);S(this,"updateAttachments",Vd);S(this,"removeAttachments",Dd);S(this,"removeAttachment",zd);S(this,"setAttachment",qd);S(this,"selectAttachment",kd)}buildOfflineAttachment(s){return T({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:i}=this.client,c=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,n=new Date().toISOString(),r=[],o=[],m={},d={};for(const A of s){const{documentUuid:y,file:b}=A,F=await this.getFilePayload(b);F.sha1 in m||(m[F.sha1]=F,d[F.sha1]=[]);const _=this.buildOfflineAttachment({file:b,file_sha1:F.sha1,submitted_at:n,created_by:c,description:"",modelUuid:y});r.push(_),o.push({uuid:_.uuid,file_name:_.file_name,file_sha1:_.file_sha1,file_extension:F.extension,description:_.description,document:y}),d[F.sha1].push(_.uuid)}this.dispatch(this.addAttachments(r));const l=this.enqueueRequest({description:"Attach files to document",method:h.POST,url:"/document-attachments/bulk/",payload:{submitted_at:n,attachments:o,files:Object.values(m)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return l.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const b=this.processPresignedUrls(y);for(const[F,_]of Object.entries(b))_.then(()=>{const v=d[F];for(const q of v)this.makeReadable(q)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,l.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,i){const c=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Ed(c));const n=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/organizations/${i}/document-attachments/`,blocks:[],blockers:[]});return this.dispatch(this.addAttachments(n)),[...c,...n]}}class zb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Ld([n]));const r=this.enqueueRequest({description:"Create Document",method:h.POST,url:"/documents/",payload:w(n),queryParams:{parent_document:n.parent_document??void 0},blockers:n.parent_document?[n.parent_document]:[],blocks:[n.uuid]});return r.catch(()=>{this.dispatch(Oa([n.uuid]))}),[n,r]}update(e){const{store:s}=this.client,i=s.getState().documentsReducer.documents[e.uuid];if(!i)throw new Error(`attempting to update a document with uuid ${e.uuid} that does not exist in store.documents`);const c={...i,...e};this.dispatch(Ce([c]));const n=this.enqueueRequest({description:"Update Document",method:h.PATCH,url:`/documents/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.catch(()=>{Ce([i])}),[c,n]}move(e,s,i){const{store:c}=this.client,n=He(c.getState()),r=[],o=n[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(n[o.parent_document]),s){const d=n[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(n[d.parent_document])}this.dispatch(Nd({documentId:e,targetDocumentId:s,position:i}));const m=this.enqueueRequest({description:"Move Document",method:h.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:i},blockers:[e],blocks:[]});return m.then(d=>{this.dispatch(Ce(d))}).catch(()=>{this.dispatch(Ce(r))}),m}delete(e){const{store:s}=this.client,i=He(s.getState()),c=Wd(e)(s.getState());if(!c)throw new Error(`attempting to delete a document with uuid ${e} that does not exist in store.documents`);const n=c.parent_document?i[c.parent_document]:void 0;this.dispatch(Oa([e]));const r=this.enqueueRequest({description:"Delete Document",method:h.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(o=>{this.dispatch(Ce(o))}).catch(()=>{this.dispatch(Ce([c])),n&&this.dispatch(Ce([n]))}),r}async refreshStore(e,s){const i=this.enqueueRequest({description:"Get project documents",method:h.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),c=this.enqueueRequest({description:"Get organization documents",method:h.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]}),n=[...await i,...await c];return this.dispatch(Gd(n)),n}}class Db extends R{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(Xd(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(Zd(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:[]});return this.dispatch(Jd(s)),s}}class Cb extends R{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 Bt={},dc=new Set;let $t=0,uc=0,oc=0;const Ub=20;class kb extends R{constructor(){super(...arguments);S(this,"host");S(this,"_dbPromise",fm.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const i=await this.fetchCache(s);if(!i)throw new Error(`File with sha1 ${s} not found in cache`);const c=await Kt(i,s),n=await this.enqueueRequest({description:"Get S3 URL",method:h.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await Ne(i),file_type:i.type,extension:i.name.split(".").pop(),size:i.size.toString()},blockers:[],blocks:[`s3-${c}`]});return"url"in n&&this.dispatch(au({sha1:s,...n})),n}async addCache(s,i){if(dc.has(i))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 c=await this._dbPromise;!!await c.get("files",i)?(console.error("File already cached (this is unexpected at this point):",s.name,i),$t++):(await c.put("files",s,i),uc++),dc.add(i),oc++,oc%Ub===0&&console.debug(`File cache summary: ${$t} hits and ${uc} misses, ${$t/($t+uc)*100}% hit rate over ${oc} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),dc.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const i=this.client.store.getState();return iu(s)(i)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const i=await this.fetchCache(s);if(!i)throw new Error(`File with sha1 ${s} not found in cache`);const c=await Kt(i,s),n={file_name:i.name,file_sha1:s,file:c},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[n,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-${c}`],blocks:[s],s3url:r});return[n,m]}async fetchFileFromUrl(s,i,c){const n=s.split("?")[0]??s,r=await this.fetchCache(i);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const l=await bc(s),p=new File([l],c??i,{type:l.type});return await this.addCache(p,i),p}let o=Bt[n],m=!0;o?m=!1:(o=new Promise(l=>{this.enqueueRequest({description:"Download file",method:h.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[i],blocks:[i]}).then(p=>{const A=new File([p],c??i,{type:p.type});l(A)})}),Bt[n]=o);let d;try{d=await o}catch(l){throw m&&l instanceof D&&delete Bt[n],l}if(m){const l=await Ne(d);if(l!==i){const y=`The hash of the file returned from the server (${l}) does not match the
|
|
8
|
+
`)}catch(c){console.error("Failed to extract error message from response body",c)}}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>rb?We:s}class U extends Error{constructor(s){super(We);S(this,"status");S(this,"response");S(this,"message");S(this,"options");const{response:i,innerError:c}=s;this.message=s.message??db(i,c)??We,this.status=(i==null?void 0:i.status)??0,this.response=i,s.discard=s.discard??!1,this.options=s}}class ub extends Xh{constructor(e){super(e)}}class R extends Xh{constructor(s,i){super(s);S(this,"auth");this.auth=i}}class ob extends R{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(i=>(this.dispatch(_c(i)),i))}async continueConversation(e,s,i){return this.enqueueRequest({description:"Prompt agent",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:i},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(c=>{this.dispatch(Rc(c))})}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(Oc(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:"/agents/conversations/",queryParams:{project:e},blockers:["agent-conversations"],blocks:["agent-conversations"]});return this.dispatch(Ic(s)),s}}class j extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:i,assetTypeAttachmentReducer:c,documentAttachmentReducer:n,projectAttachmentReducer:r,formRevisionAttachmentReducer:o,formSubmissionAttachmentReducer:m,geoImageReducer:u,assetTypeFieldsAttachmentReducer:l,assetTypeFieldValuesAttachmentReducer:p,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(i.instances),Object.values(c.instances),Object.values(n.instances),Object.values(r.instances),Object.values(o.instances),Object.values(m.instances),Object.values(u.instances),Object.values(l.instances),Object.values(p.instances),Object.values(A.instances),Object.values(y.instances)).filter(P=>P.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[i,c]of Object.entries(e))s[i]=this.enqueueRequest({url:c.url,description:"Upload file to S3",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:i,blockers:[`s3-${c.fields.key}`],blocks:[i],s3url:c});return s}async getFilePayload(e){const s=await Ne(e),i={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),i}}class Ce extends j{async _bulkAdd(e){var u;const{store:s}=this.client,i=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,c=new Date().toISOString(),n=[],r=[],o={};for(const l of e){const{modelUuid:p,file:A}=l,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:c,created_by:i,description:"",modelUuid:p});n.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(n));const m=this.enqueueRequest({description:`Add ${this.name}`,method:h.POST,url:`${this.url}/bulk/`,payload:{submitted_at:c,attachments:r,files:Object.values(o)},blocks:n.map(l=>l.uuid),blockers:n.map(l=>l.file_sha1)});return m.then(({attachments:l,presigned_urls:p})=>{this.dispatch(this.updateAttachments(l)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(n.map(l=>l.uuid)))}),[n,m.then(({attachments:l})=>l)]}async _delete(e){const{store:s}=this.client,i=this.selectAttachment(e)(s.getState());if(!i)throw new Error(`Attempting to delete attachment with uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(i.uuid));const c=this.enqueueRequest({description:`Delete ${this.name}`,method:h.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return c.then(()=>{this.getNumberOfAttachmentsWithSha1(i.file_sha1)===0&&this.client.files.removeCache(i.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(i))}),c}}class lb extends Ce{constructor(){super(...arguments);S(this,"name","Asset Attachment");S(this,"url","/asset-attachments");S(this,"initializeAttachments",Xt);S(this,"addAttachments",Qt);S(this,"updateAttachments",Ec);S(this,"removeAttachments",xt);S(this,"removeAttachment",jc);S(this,"setAttachment",Mc);S(this,"selectAttachment",zc)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.assetUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset__project:s},blocks:[],blockers:[]});return this.dispatch(Xt(i)),i}}class hb extends Ce{constructor(){super(...arguments);S(this,"name","Asset Procedure Attachment");S(this,"url","/asset-procedure-attachments");S(this,"addAttachments",Bc);S(this,"updateAttachments",Gc);S(this,"removeAttachments",Nc);S(this,"removeAttachment",Lc);S(this,"setAttachment",$c);S(this,"selectAttachment",Kc)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.assetProcedureUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset procedure attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_procedure__organization:s},blocks:[],blockers:[]});return this.dispatch(kc(i)),i}}class mb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(Xc(n));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(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return o.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Qc(u.attachments))}).catch(()=>{this.dispatch(xc(n.map(u=>u.uuid)))}),[n,o.then(({attachments:u})=>u)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:h.GET,url:"/asset-procedure-fields-attachments/",queryParams:{fields_revision__asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(Zc(s)),s}}class pb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(nn(n));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:h.POST,url:"/asset-procedure-fields/",payload:v(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(rn(m))}).catch(m=>{throw this.dispatch(dn(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:h.GET,url:"/asset-procedure-fields/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(cn(s)),s}}function Be(t,e){const s=[];let i=0;const c=t.length;for(;i<c;)s.push(t.slice(i,i+=e));return s}class Ab extends j{async bulkAdd(e,s){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=Be(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,w=await this.getFilePayload(_);w.sha1 in p||(p[w.sha1]=w);const q=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:w.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(q);const Ye={uuid:q.uuid,file_name:_.name,file_sha1:w.sha1,file_extension:w.extension,field_identifier:P,field_values:b};A.push(Ye)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(mt(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:h.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(mn(p))}).catch(l=>{throw this.dispatch(pt(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=An(e)(i);this.dispatch(pt(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:h.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(mt(c)),n}}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:{field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(hn(s)),s}}class yb extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/",payload:v(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(rs(c)),n.then(o=>(this.dispatch(Ze(o)),o)).catch(()=>{this.dispatch(ds(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=Be(e.payloads,s??e.payloads.length),r=[];for(const u of n){const l=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),l.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:i,values:e.values,field_values:l})}this.dispatch(bn(c));const o=[];for(const u of r){const l=u.field_values.map(P=>P.asset),p=u.field_values.map(P=>P.fields_revision),A=u.field_values.map(P=>P.asset_procedure_instance),y=u.field_values.map(P=>P.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/bulk/",payload:u,blockers:[...l,...p,...A],blocks:y});o.push(b)}return Promise.all(o).then(u=>{this.dispatch(Pn(u.flat()))}).catch(()=>{this.dispatch(Fn(c.map(u=>u.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.getState(),c=os(e.uuid)(i);if(!c)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(Ze(n));const r=this.enqueueRequest({description:"Update asset procedure field values",method:h.PATCH,url:`/asset-procedure-field-values/${e.uuid}/`,payload:e,blockers:[n.fields_revision,n.asset,n.asset_procedure_instance],blocks:[n.uuid]});return r.then(o=>{this.dispatch(Ze(o))}).catch(()=>{this.dispatch(Ze(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=os(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=yn(e)(i);this.dispatch(ds(e)),this.dispatch(pt(n.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(rs(c)),this.dispatch(mt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:h.GET,url:"/asset-procedure-field-values/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(gn(s)),s}}class fb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(hs(n));const r=this.enqueueRequest({description:"Create asset procedure instance",method:h.POST,url:"/asset-procedure-instances/",payload:v(n),blockers:[e.asset_procedure,e.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Xe(m))}).catch(()=>{this.dispatch(ms(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=ys(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Xe(c));const n=this.enqueueRequest({description:"Update asset procedure instance",method:h.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Xe(r))}).catch(()=>{this.dispatch(Xe(i))}),[c,n]}async remove(e){const{store:s}=this.client,i=s.getState(),c=ys(e)(i);if(!c)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(ms(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:h.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(hs(c)),n})}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:[]});return this.dispatch(On(s)),s}}class Sb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Ss(n));const r=this.enqueueRequest({description:"Create asset procedure",method:h.POST,url:"/asset-procedures/",payload:v(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Qe(m))}).catch(()=>{this.dispatch(gs(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Ps(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Qe(c));const n=this.enqueueRequest({description:"Update asset procedure",method:h.PATCH,url:`/asset-procedures/${e.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Qe(r))}).catch(()=>{this.dispatch(Qe(i))}),[c,n]}async remove(e){const{store:s}=this.client,i=s.getState(),c=Ps(e)(i);if(!c)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const n=wn(e)(i);return this.dispatch(gs(e)),this.dispatch(vn(n.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(Ss(c)),this.dispatch(Rn(n)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:h.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(jn(s)),s}}class gb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(Dn(n));const o=this.enqueueRequest({description:"Add asset procedure step fields attachments",method:h.POST,url:"/asset-procedure-step-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return o.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Cn(u.attachments))}).catch(()=>{this.dispatch(kn(n.map(u=>u.uuid)))}),[n,o.then(({attachments:u})=>u)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step fields attachments",method:h.GET,url:"/asset-procedure-step-fields-attachments/",queryParams:{fields_revision__asset_procedure_step__organization:e},blockers:[],blocks:[]});return this.dispatch(Un(s)),s}}class bb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Is(n));const r=this.enqueueRequest({description:"Add Asset Procedure Step Fields",method:h.POST,url:"/asset-procedure-step-fields/",payload:v(n),blockers:[n.asset_procedure_step],blocks:[n.uuid]});return r.then(m=>{this.dispatch(xe(m))}).catch(m=>{throw this.dispatch(_s(n.uuid)),m}),[n,r]}update(e){const{store:s}=this.client,i=s.getState().assetProcedureStepFieldsReducer.instances[e.uuid];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e.uuid} not found`);const c={...i,...e};this.dispatch(xe(c));const n=this.enqueueRequest({description:"Update Asset Procedure Step Fields",method:h.PATCH,url:`/asset-procedure-step-fields/${i.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(xe(r))}).catch(r=>{throw this.dispatch(xe(i)),r}),[c,n]}delete(e){const{store:s}=this.client,i=s.getState().assetProcedureStepFieldsReducer.instances[e];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e} not found`);this.dispatch(_s(e));const c=this.enqueueRequest({description:"Delete Asset Procedure Step Fields",method:h.DELETE,url:`/asset-procedure-step-fields/${e}/`,blockers:[e],blocks:[e]});return c.catch(n=>{throw this.dispatch(Is(i)),n}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Step Fields",method:h.GET,url:"/asset-procedure-step-fields/",queryParams:{asset_procedure_step__asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(Nn(s)),s}}class Pb extends j{async bulkAdd(e,s){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=Be(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,w=await this.getFilePayload(_);w.sha1 in p||(p[w.sha1]=w);const q=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:w.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(q);const Ye={uuid:q.uuid,file_name:_.name,file_sha1:w.sha1,file_extension:w.extension,field_identifier:P,field_values:b};A.push(Ye)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(At(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset procedure step field values attachments",method:h.POST,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(Yn(p))}).catch(l=>{throw this.dispatch(yt(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=Zn(e)(i);this.dispatch(yt(e));try{await this.enqueueRequest({description:"Delete asset procedure step field values attachments",method:h.DELETE,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(At(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step field values attachments",method:h.GET,url:"/asset-procedure-step-field-values-attachments/",queryParams:{field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(Kn(s)),s}}class Fb extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/",payload:v(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(Es(c)),n.then(o=>(this.dispatch(et(o)),o)).catch(()=>{this.dispatch(js(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=Be(e.payloads,s??e.payloads.length),r=[];for(const u of n){const l=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),l.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,asset_procedure_step:p.asset_procedure_step,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:l})}this.dispatch(tr(c));const o=[];for(const u of r){const l=u.field_values.map(P=>P.asset),p=u.field_values.map(P=>P.fields_revision),A=u.field_values.map(P=>P.asset_procedure_instance),y=u.field_values.map(P=>P.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/bulk/",payload:u,blockers:[...l,...p,...A],blocks:y});o.push(b)}return Promise.all(o).then(u=>{this.dispatch(sr(u.flat()))}).catch(()=>{this.dispatch(ar(c.map(u=>u.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.getState(),c=qs(e.uuid)(i);if(!c)throw new Error(`Expected AssetProcedureStepFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(et(n));const r=this.enqueueRequest({description:"Update asset procedure step field values",method:h.PATCH,url:`/asset-procedure-step-field-values/${e.uuid}/`,payload:e,blockers:[n.fields_revision,n.asset,n.asset_procedure_instance],blocks:[n.uuid]});return r.then(o=>{this.dispatch(et(o))}).catch(()=>{this.dispatch(et(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=qs(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=Xn(e)(i);this.dispatch(js(e)),this.dispatch(yt(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure step field values",method:h.DELETE,url:`/asset-procedure-step-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Es(c)),this.dispatch(At(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step field values",method:h.GET,url:"/asset-procedure-step-field-values/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(er(s)),s}}class Tb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(zs(n));const r=this.enqueueRequest({description:"Create asset procedure step",method:h.POST,url:"/asset-procedure-steps/",payload:v(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(St(m))}).catch(()=>{this.dispatch(Us(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Ds(e.uuid)(s.getState());if(!i)throw new Error(`No asset procedure step with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(St(c));const n=this.enqueueRequest({description:"Update asset procedure step",method:h.PATCH,url:`/asset-procedure-steps/${i.uuid}/`,payload:{name:e.name,description:e.description,priority:e.order,color:e.color},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(St(r))}).catch(()=>{this.dispatch(dr(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Ds(e)(i);if(!c)throw new Error(`No asset procedure step with uuid ${e} found in the store`);return this.dispatch(Us(e)),this.enqueueRequest({description:"Delete asset stage",method:h.DELETE,url:`/asset-stages/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(zs(c)),n})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure steps",method:h.GET,url:"/asset-procedure-steps/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(rr(s)),s}}class Ib extends R{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 i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(ks(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/assets/",payload:v(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(tt(m))}).catch(()=>{this.dispatch(Bs(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Ns(e.uuid)(s.getState());if(!i)throw new Error(`No asset with uuid ${e.uuid} found in the store`);const c={...i,...e};if(!c.canvas_marker&&!c.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(tt(c));const n=this.enqueueRequest({description:"Edit asset",method:h.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(tt(r))}).catch(()=>{this.dispatch(tt(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Ns(e)(i);if(!c)throw new Error(`No asset with uuid ${e} found in the store`);const n=Uc(e)(i),r=Vu(e)(i),o=Qu(e)(i);if(this.dispatch(Bs(e)),n.length>0){const m=n.map(({uuid:u})=>u);this.dispatch(xt(m))}if(r.length>0){const m=r.map(({uuid:u})=>u);this.dispatch(jt(m))}if(o.length>0){const m=o.map(({uuid:u})=>u);this.dispatch(Ja(m))}return this.enqueueRequest({description:"Delete asset",method:h.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(ks(c)),this.dispatch(Qt(n)),this.dispatch(Et(r)),this.dispatch(Ka(o)),m})}bulkAdd(e,s,i,c){const n=new Date().toISOString(),r=Le.v4(),o=Be(e,c).map(l=>{const p=l.map(A=>T(A));return{batchId:Le.v4(),payload:{transaction_id:r,submitted_at:n,asset_type:s,project:i,assets:p}}}),m=[];let u=null;for(const l of o){const{batchId:p,payload:A}=l,y=A.assets.map(w=>w.uuid),b=[s];u&&b.push(u);const P=y;P.push(p);const _=this.enqueueRequest({description:"Batch create assets",method:h.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:P});u=l.batchId,m.push(_)}return Promise.all(m).then(l=>{const p=l.flat();this.dispatch(bt(p))}),m}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=pr(e)(i);this.dispatch($s(e));try{await this.enqueueRequest({description:"Bulk delete assets",method:h.DELETE,url:"/assets/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(bt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:h.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(hr(s)),s}}class _b extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Ws(n));const r=this.enqueueRequest({description:"Add asset stage completion",method:h.POST,url:"/asset-stage-completions/",payload:v(n),blockers:[e.asset,e.stage],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Sr(m))}).catch(()=>{this.dispatch(Ys(n.uuid))}),[n,r]}delete(e){const{store:s}=this.client,i=Pr(e)(s.getState());if(!i)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(Ys(e));const c=this.enqueueRequest({description:"Delete asset stage completion",method:h.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(Ws(i))}),c}bulkAdd(e){var u;const{store:s}=this.client,i=new Date().toISOString(),c=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,n=e.map(l=>T(l)),r=n.map(l=>({...l,created_by:c,submitted_at:i})),o=r.map(({uuid:l})=>l);this.dispatch(Ks(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:h.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:i,completions:n},blockers:[...e.map(l=>l.asset_procedure_instance),...e.map(l=>l.stage),...e.map(l=>l.asset)],blocks:o});return m.then(l=>{this.dispatch(gr(l))}).catch(()=>{this.dispatch(Js(o))}),[r,m]}bulkDelete(e){const{store:s}=this.client,i=Fr(e)(s.getState());this.dispatch(Js(e));const c=this.enqueueRequest({description:"Deleting asset stage completions",method:h.DELETE,url:"/asset-stage-completions/bulk/",payload:{uuids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(Ks(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:h.GET,url:"/asset-stage-completions/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(fr(s)),s}}class Ob extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Qs(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/asset-stages/",payload:v(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Pt(m))}).catch(()=>{this.dispatch(xs(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=ea(e.uuid)(s.getState());if(!i)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(Pt(c));const n=this.enqueueRequest({description:"Update asset stage",method:h.PATCH,url:`/asset-stages/${i.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Pt(r))}).catch(()=>{this.dispatch(_r(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=ea(e)(i);if(!c)throw new Error(`No asset stage with uuid ${e} found in the store`);return this.dispatch(xs(e)),this.enqueueRequest({description:"Delete asset stage",method:h.DELETE,url:`/asset-stages/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(Qs(c)),n})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:h.GET,url:"/asset-stages/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(Ir(s)),s}}class Rb extends Ce{constructor(){super(...arguments);S(this,"name","Asset Type Attachment");S(this,"url","/asset-type-attachments");S(this,"addAttachments",sa);S(this,"updateAttachments",Er);S(this,"removeAttachments",aa);S(this,"removeAttachment",jr);S(this,"setAttachment",Mr);S(this,"selectAttachment",zr)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.assetTypeUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset type attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_type__organization:s},blocks:[],blockers:[]});return this.dispatch(wr(i)),i}}class vb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(Br(n));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(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return o.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch($r(u.attachments))}).catch(()=>{this.dispatch(Gr(n.map(u=>u.uuid)))}),[n,o.then(({attachments:u})=>u)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:h.GET,url:"/asset-type-fields-attachments/",queryParams:{fields_revision__asset_type__organization:e},blockers:[e],blocks:[]});return this.dispatch(kr(s)),s}}class wb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Yr(n));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:h.POST,url:"/asset-type-fields/",payload:v(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Jr(m))}).catch(m=>{throw this.dispatch(Zr(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:h.GET,url:"/asset-type-fields/",queryParams:{asset_type__organization:e},blockers:[],blocks:[]});return this.dispatch(Kr(s)),s}}class Mb extends j{async bulkAdd(e,s){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=Be(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,w=await this.getFilePayload(_);w.sha1 in p||(p[w.sha1]=w);const q=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:w.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(q);const Ye={uuid:q.uuid,file_name:_.name,file_sha1:w.sha1,file_extension:w.extension,field_identifier:P,field_values:b};A.push(Ye)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(It(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset type field values attachments",method:h.POST,url:"/asset-type-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(td(p))}).catch(l=>{throw this.dispatch(_t(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=ad(e)(i);this.dispatch(_t(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:h.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(It(c)),n}}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:{field_values__asset__project:e},blockers:[],blocks:[]});return this.dispatch(ed(s)),s}}class Eb extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset type field values",method:h.POST,url:"/asset-type-field-values/",payload:v(c),blockers:[e.asset,e.fields_revision],blocks:[c.uuid]});return this.dispatch(ua(c)),n.then(o=>(this.dispatch(st(o)),o)).catch(()=>{this.dispatch(oa(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=Be(e.payloads,s??e.payloads.length),r=[];for(const u of n){const l=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),l.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:l})}this.dispatch(dd(c));const o=[];for(const u of r){const l=u.field_values.map(b=>b.asset),p=u.field_values.map(b=>b.fields_revision),A=u.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:u,blockers:[...l,...p],blocks:A});o.push(y)}return Promise.all(o).then(u=>{this.dispatch(ud(u.flat()))}).catch(()=>{this.dispatch(od(c.map(u=>u.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.getState(),c=ha(e.uuid)(i);if(!c)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(st(n));const r=this.enqueueRequest({description:"Delete asset type field values",method:h.PATCH,url:`/asset-type-field-values/${e.uuid}/`,payload:e,blockers:[n.uuid,n.fields_revision,n.asset],blocks:[n.uuid]});return r.then(o=>{this.dispatch(st(o))}).catch(()=>{this.dispatch(st(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=ha(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=id(e)(i);this.dispatch(oa(e)),this.dispatch(_t(n.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(ua(c)),this.dispatch(It(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:h.GET,url:"/asset-type-field-values/",queryParams:{asset__project:e},blockers:[],blocks:[]});return this.dispatch(rd(s)),s}}class jb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(pa(n));const r=this.enqueueRequest({description:"Create asset type",method:h.POST,url:"/asset-types/",payload:v(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(at(m))}).catch(()=>{this.dispatch(Aa(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=fa(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(at(c));const n=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:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(at(r))}).catch(()=>{this.dispatch(at(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=fa(e)(i);if(!c)throw new Error(`Expected asset type with uuid ${e} to exist`);const n=Ls(e)(i),r=Ur(e)(i);return this.dispatch(Aa(e)),this.dispatch($s(n.map(o=>o.uuid))),this.dispatch(aa(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(pa(c)),this.dispatch(bt(n)),this.dispatch(sa(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:[]});return this.dispatch(pd(s)),s}}class qb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(ga(n));const r=this.enqueueRequest({description:"Create Category",method:h.POST,url:"/categories/",payload:v(n),blockers:[e.project],blocks:[n.uuid]});return[n,r]}update(e){const s=this.client.store.getState(),i=Pa(e.uuid)(s);if(!i)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const c={...i,...e};this.dispatch(Fd(c));const n=this.enqueueRequest({description:"Edit Category",method:h.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[c,n]}remove(e){const{store:s}=this.client,i=Pa(e)(s.getState());if(!i)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(Td(e));const c=this.enqueueRequest({description:"Delete Category",method:h.DELETE,url:`/categories/${i.uuid}/`,blockers:[i.uuid],blocks:[]});return c.catch(()=>{this.dispatch(ga(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:h.GET,url:"/categories/",queryParams:{project__organization_owner:e},blocks:[],blockers:[]});return this.dispatch(Pd(s)),s}}class Vb extends Ce{constructor(){super(...arguments);S(this,"name","Document Attachment");S(this,"url","/document-attachments");S(this,"addAttachments",vd);S(this,"updateAttachments",Md);S(this,"removeAttachments",jd);S(this,"removeAttachment",Ed);S(this,"setAttachment",wd);S(this,"selectAttachment",zd)}buildOfflineAttachment(s){return T({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:i}=this.client,c=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,n=new Date().toISOString(),r=[],o=[],m={},u={};for(const A of s){const{documentUuid:y,file:b}=A,P=await this.getFilePayload(b);P.sha1 in m||(m[P.sha1]=P,u[P.sha1]=[]);const _=this.buildOfflineAttachment({file:b,file_sha1:P.sha1,submitted_at:n,created_by:c,description:"",modelUuid:y});r.push(_),o.push({uuid:_.uuid,file_name:_.file_name,file_sha1:_.file_sha1,file_extension:P.extension,description:_.description,document:y}),u[P.sha1].push(_.uuid)}this.dispatch(this.addAttachments(r));const l=this.enqueueRequest({description:"Attach files to document",method:h.POST,url:"/document-attachments/bulk/",payload:{submitted_at:n,attachments:o,files:Object.values(m)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return l.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const b=this.processPresignedUrls(y);for(const[P,_]of Object.entries(b))_.then(()=>{const w=u[P];for(const q of w)this.makeReadable(q)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,l.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,i){const c=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Rd(c));const n=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/organizations/${i}/document-attachments/`,blocks:[],blockers:[]});return this.dispatch(this.addAttachments(n)),[...c,...n]}}class zb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(kd([n]));const r=this.enqueueRequest({description:"Create Document",method:h.POST,url:"/documents/",payload:v(n),queryParams:{parent_document:n.parent_document??void 0},blockers:n.parent_document?[n.parent_document]:[],blocks:[n.uuid]});return r.catch(()=>{this.dispatch(Ia([n.uuid]))}),[n,r]}update(e){const{store:s}=this.client,i=s.getState().documentsReducer.documents[e.uuid];if(!i)throw new Error(`attempting to update a document with uuid ${e.uuid} that does not exist in store.documents`);const c={...i,...e};this.dispatch(De([c]));const n=this.enqueueRequest({description:"Update Document",method:h.PATCH,url:`/documents/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.catch(()=>{De([i])}),[c,n]}move(e,s,i){const{store:c}=this.client,n=He(c.getState()),r=[],o=n[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(n[o.parent_document]),s){const u=n[s];if(!u)throw new Error(`attempting to move a document to target with uuid ${s} that does not exist in store.documents`);r.push(u),u.parent_document&&r.push(n[u.parent_document])}this.dispatch(Bd({documentId:e,targetDocumentId:s,position:i}));const m=this.enqueueRequest({description:"Move Document",method:h.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:i},blockers:[e],blocks:[]});return m.then(u=>{this.dispatch(De(u))}).catch(()=>{this.dispatch(De(r))}),m}delete(e){const{store:s}=this.client,i=He(s.getState()),c=Gd(e)(s.getState());if(!c)throw new Error(`attempting to delete a document with uuid ${e} that does not exist in store.documents`);const n=c.parent_document?i[c.parent_document]:void 0;this.dispatch(Ia([e]));const r=this.enqueueRequest({description:"Delete Document",method:h.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(o=>{this.dispatch(De(o))}).catch(()=>{this.dispatch(De([c])),n&&this.dispatch(De([n]))}),r}async refreshStore(e,s){const i=this.enqueueRequest({description:"Get project documents",method:h.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),c=this.enqueueRequest({description:"Get organization documents",method:h.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]}),n=[...await i,...await c];return this.dispatch(Cd(n)),n}}class Ub extends R{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(Kd(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(Wd(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:[]});return this.dispatch(Hd(s)),s}}class Db extends R{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 Bt={},nc=new Set;let $t=0,rc=0,dc=0;const Cb=20;class kb extends R{constructor(){super(...arguments);S(this,"host");S(this,"_dbPromise",mm.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const i=await this.fetchCache(s);if(!i)throw new Error(`File with sha1 ${s} not found in cache`);const c=await Kt(i,s),n=await this.enqueueRequest({description:"Get S3 URL",method:h.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await Ne(i),file_type:i.type,extension:i.name.split(".").pop(),size:i.size.toString()},blockers:[],blocks:[`s3-${c}`]});return"url"in n&&this.dispatch(xd({sha1:s,...n})),n}async addCache(s,i){if(nc.has(i))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 c=await this._dbPromise;!!await c.get("files",i)?(console.error("File already cached (this is unexpected at this point):",s.name,i),$t++):(await c.put("files",s,i),rc++),nc.add(i),dc++,dc%Cb===0&&console.debug(`File cache summary: ${$t} hits and ${rc} misses, ${$t/($t+rc)*100}% hit rate over ${dc} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),nc.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const i=this.client.store.getState();return eu(s)(i)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const i=await this.fetchCache(s);if(!i)throw new Error(`File with sha1 ${s} not found in cache`);const c=await Kt(i,s),n={file_name:i.name,file_sha1:s,file:c},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[n,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-${c}`],blocks:[s],s3url:r});return[n,m]}async fetchFileFromUrl(s,i,c){const n=s.split("?")[0]??s,r=await this.fetchCache(i);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const l=await Sc(s),p=new File([l],c??i,{type:l.type});return await this.addCache(p,i),p}let o=Bt[n],m=!0;o?m=!1:(o=new Promise(l=>{this.enqueueRequest({description:"Download file",method:h.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[i],blocks:[i]}).then(p=>{const A=new File([p],c??i,{type:p.type});l(A)})}),Bt[n]=o);let u;try{u=await o}catch(l){throw m&&l instanceof U&&delete Bt[n],l}if(m){const l=await Ne(u);if(l!==i){const y=`The hash of the file returned from the server (${l}) does not match the
|
|
9
9
|
expected hash (${i}). 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=c??l+"."+p;if(d=gc(d,A),!d.name)throw new Error("Failed to set file's name");await this.addCache(d,l),Bt[n]=new Promise(y=>{y(d)})}return d}}class Bb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{revisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,form_revision:l,submitted_at:s,field_identifier:p});n.push(b);const F={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,form_revision:l};r.push(F)}this.dispatch(du(n));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(c)},blockers:n.map(d=>d.form_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(uu(d.attachments))}).catch(()=>{this.dispatch(ou(n.map(d=>d.uuid)))}),[n,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:{form_revision__form__organization:e},blockers:[e],blocks:[]});return this.dispatch(ru(s)),s}}class $b extends j{add(e){var o;const{store:s}=this.client,c=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=T({...e,created_by:c,submitted_at:new Date().toISOString()});this.dispatch(Ea(n));const r=this.enqueueRequest({description:"Create form revision",method:h.POST,url:"/form-revisions/",payload:w(n),blockers:[e.form],blocks:[n.uuid]});return r.then(m=>{this.dispatch(yu(m))}).catch(()=>{this.dispatch(ja(n.uuid))}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:h.GET,url:"/form-revisions/",queryParams:{form__organization:e},blockers:[e],blocks:[]});return this.dispatch(pu(s)),s}}class Gb extends j{add(e,s){var d;const{store:i}=this.client,c=new Date().toISOString(),n=(d=i.getState().userReducer.currentUser)==null?void 0:d.id,r=T({...e,submitted_at:c,created_by:n}),o=T({...s,form:r.uuid,submitted_at:c,created_by:n});this.dispatch(Va(r)),this.dispatch(Ea(o));const m=this.enqueueRequest({description:"Create form",method:h.POST,url:"/forms/",payload:{...w(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(l=>{throw this.dispatch(za(r.uuid)),this.dispatch(ja(o.uuid)),l}),[r,o,m]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Ou(e)(i);if(!c)throw new Error("Expected form to exist");const n=Du(e)(i);n.length>0&&this.dispatch(jt(n.map(({uuid:o})=>o)));const r=gu(e)(i);r.length>0&&this.dispatch(fu(r.map(({uuid:o})=>o))),this.dispatch(za(e));try{return await this.enqueueRequest({description:"Delete form",method:h.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(Va(c)),r.length>0&&this.dispatch(Au(r)),n.length>0&&this.dispatch(Et(n)),o}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:h.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]});return this.dispatch(Pu(s)),s}}class Lb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{submissionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,form_submission:l,submitted_at:s,field_identifier:p});n.push(b);const F={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,form_submission:l};r.push(F)}this.dispatch(vt(n));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(c)},blockers:n.map(d=>d.form_submission),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(wu(d.attachments))}).catch(d=>{throw this.dispatch(wt(n.map(l=>l.uuid))),d}),[n,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=Mu(e)(i);this.dispatch(wt(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:h.DELETE,url:"/form-submission-attachments/bulk/",payload:e,blockers:e,blocks:[]})}catch(n){throw this.dispatch(vt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:h.GET,url:"/form-submission-attachments/",queryParams:{form_submission__project:e},blockers:[],blocks:[]});return this.dispatch(vu(s)),s}}class Nb extends j{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add form submission",method:h.POST,url:"/form-submissions/",payload:w(c),blockers:[e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.uuid]});return this.dispatch(ka(c)),n.then(o=>(this.dispatch(Mt(o)),o)).catch(()=>{this.dispatch(Ba(c.uuid))}),[c,n]}update(e){const{store:s}=this.client,i=s.getState(),c=La(e.uuid)(i);if(!c)throw new Error(`Expected submission with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(zu(n));const r=this.enqueueRequest({description:"Delete user form submissions",method:h.PATCH,url:`/form-submissions/${n.uuid}/`,payload:e,blockers:[n.uuid],blocks:[n.uuid]});return r.then(o=>{this.dispatch(Mt(o))}).catch(()=>{this.dispatch(Mt(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=La(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=Eu(e)(i);this.dispatch(Ba(e)),this.dispatch(wt(n.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(ka(c)),this.dispatch(vt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:h.GET,url:"/form-submissions/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(Vu(s)),s}}class Hb extends j{async add(e){var p;const{store:s}=this.client,{file:i,...c}=e,n=new Date().toISOString(),r=(p=s.getState().userReducer.currentUser)==null?void 0:p.id,o=c.project,m=await this.getFilePayload(i),d=T({...c,file_name:i.name,file_sha1:m.sha1,file:URL.createObjectURL(i),submitted_at:n,created_by:r});this.dispatch(Lu(d));const l=this.enqueueRequest({description:"Add geo image",method:h.POST,url:"/geo-images/",payload:{uuid:d.uuid,submitted_at:n,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 l.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(it(A.geo_image))}).catch(()=>{this.dispatch(Ha(d.uuid))}),[d,l.then(A=>A.geo_image)]}async bulkAdd(e,s){var p;const{store:i}=this.client,c=new Date().toISOString(),n=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,r=[],o=[],m=[],d={};for(const A of e){const{file:y,...b}=A,F=await this.getFilePayload(y);F.sha1 in d||(d[F.sha1]=F);const _=T({...b,file_name:y.name,file_sha1:F.sha1,file:URL.createObjectURL(y),submitted_at:c,created_by:n,project:s});r.push(_),o.push(_.uuid),m.push({uuid:_.uuid,sha1:_.file_sha1,file_name:_.file_name,title:_.title,description:_.description,geo_marker:_.geo_marker,canvas_marker:_.canvas_marker,direction:_.direction,original_date:_.original_date})}this.dispatch(Nu(r));const l=this.enqueueRequest({description:"Bulk add geo images",method:h.POST,url:"/geo-images/bulk/",payload:{submitted_at:c,project:s,geo_images:m,files:Object.values(d)},blocks:[s],blockers:o});return l.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(Gu(A.geo_images))}).catch(()=>{this.dispatch(Wu(o))}),[r,l.then(A=>A.geo_images)]}update(e){const{store:s}=this.client,i=s.getState(),c=Wa(e.uuid)(i);if(!c)throw new Error(`Map image with uuid ${e.uuid} does not exist in the store`);const n={...c,...e};this.dispatch(Hu(n));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(it(o))}).catch(()=>{this.dispatch(it(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Wa(e)(i);if(!c)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(Ha(e));const n=this.enqueueRequest({description:"Delete geo image",method:h.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return n.catch(()=>{this.dispatch(it(c))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:h.GET,url:"/geo-images/",queryParams:{project:e},blocks:[e],blockers:[]});return this.dispatch($u(s)),s}}class Wb extends R{add(e){var o;const{store:s}=this.client,i=new Date().toISOString(),c=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=T({...e,submitted_at:i,created_by:c});this.dispatch(Ya(n));const r=this.enqueueRequest({description:"Add issue association",method:h.POST,url:"/issue-associations/",payload:w(n),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Qu(m))}).catch(()=>{this.dispatch(Za(n.uuid))}),[n,r]}async delete(e){const{store:s}=this.client,i=xu(e)(s.getState());if(!i)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(Za(e));const c=this.enqueueRequest({description:"Delete issue association",method:h.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(Ya(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:h.GET,url:"/issue-associations/",queryParams:{associated_issue__project:e},blockers:[],blocks:[]});return this.dispatch(Xu(s)),s}}class Kb extends Ue{constructor(){super(...arguments);S(this,"name","Issue Attachment");S(this,"url","/issue-attachments");S(this,"initializeAttachments",xa);S(this,"addAttachments",ei);S(this,"updateAttachments",no);S(this,"removeAttachments",ti);S(this,"removeAttachment",ro);S(this,"setAttachment",co);S(this,"selectAttachment",ho)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.issueUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get issue attachments",method:h.GET,url:`${this.url}/`,queryParams:{issue__project:s},blocks:[],blockers:[]});return this.dispatch(xa(i)),i}}class Yb extends Ue{constructor(){super(...arguments);S(this,"name","Issue Comment Attachment");S(this,"url","/issue-comment-attachments");S(this,"initializeAttachments",ai);S(this,"addAttachments",Ao);S(this,"updateAttachments",fo);S(this,"removeAttachments",go);S(this,"removeAttachment",So);S(this,"setAttachment",yo);S(this,"selectAttachment",Po)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.issueCommentUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get issue comment attachments",method:h.GET,url:`${this.url}/`,queryParams:{issue_comment__issue__project:s},blocks:[],blockers:[]});return this.dispatch(ai(i)),i}}class Jb extends R{add(e){var n;const{store:s}=this.client,i=T({...e,author:(n=s.getState().userReducer.currentUser)==null?void 0:n.id,submitted_at:new Date().toISOString()});this.dispatch(ci(i));const c=this.enqueueRequest({description:"Add issue comment",method:h.POST,url:"/issue-comments/",payload:w(i),blockers:[e.issue],blocks:[i.uuid]});return c.catch(()=>{this.dispatch(ri(i.uuid))}),[i,c]}update(e){const{store:s}=this.client,i=di(e.uuid)(s.getState());if(!i)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const c={...i,...e};this.dispatch(ni(c));const n=this.enqueueRequest({description:"Edit issue comment",method:h.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.catch(()=>{this.dispatch(ni(i))}),[c,n]}remove(e){const{store:s}=this.client,i=di(e)(s.getState());if(!i)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(ri(e));const c=this.enqueueRequest({description:"Delete comment",method:h.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(ci(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:h.GET,url:"/issue-comments/",queryParams:{issue__project:e},blockers:[],blocks:[]});return this.dispatch(_o(s)),s}}class Zb extends R{add(e){var m;const{store:s}=this.client,i=s.getState(),c=new Date().toISOString(),n=(m=i.userReducer.currentUser)==null?void 0:m.id,r=T({...e,submitted_at:c,created_by:n});this.dispatch(oi(r));const o=this.enqueueRequest({description:"Create issue",method:h.POST,url:"/issues/",payload:w(r),blockers:[r.project,r.issue_type,...r.category?[r.category]:[]],blocks:[r.uuid]});return o.then(d=>{this.dispatch(qt(d))}).catch(d=>{throw this.dispatch(li(r.uuid)),d}),[r,o]}update(e){var m;const s=this.client.store.getState(),i=mi(e.uuid)(s);if(!i)throw new Error(`Attempting to update an issue with uuid ${e.uuid} that doesn't exist in the store`);const c={...i,...e};this.dispatch(qt(c));const n={};for(const d of[E.TITLE,E.DESCRIPTION,E.STATUS,E.CATEGORY,E.PRIORITY,E.ASSIGNED_TO,E.DUE_DATE])if(d in e&&e[d]!==i[d])switch(d){case E.PRIORITY:case E.STATUS:{const l=e[d];n[d]=l!==void 0?Number(l):null;break}case E.DUE_DATE:case E.DESCRIPTION:case E.TITLE:n[d]=e[d]??null;break;case E.CATEGORY:{let l=null;const p=e[d];if(p&&(l=s.categoryReducer.instances[p]??null,!l))throw new Error(`Trying to update issue category to ${p} which does not exist in store`);n[d]=l?{name:l.name,color:l.color,uuid:l.uuid}:null;break}case E.ASSIGNED_TO:{let l=null;const p=e[d];if(p&&(l=s.userReducer.instances[p]??null,!l))throw new Error(`Trying to update issue assigned_to to ${p} which does not exist in store`);n[d]=l?{full_name:l.username,id:l.id}:null;break}}const r=T({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:i.uuid,changes:n});this.dispatch(Il(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(qt(i)),this.dispatch(Ol(r.uuid))}),[c,o]}async remove(e){const{store:s}=this.client,i=s.getState(),c=mi(e)(i);if(!c)throw new Error(`No issue with uuid ${e} found in the store`);const n=lo(e)(i),r=wl(e)(i),o=Cu(e)(i),m={};for(const l of eo(e)(i))m[l.uuid]=l;for(const l of to(e)(i))m[l.uuid]=l;const d=Object.values(m);this.dispatch(li(e)),n.length>0&&this.dispatch(ti(n.map(({uuid:l})=>l))),r.length>0&&this.dispatch(Rl(r.map(({uuid:l})=>l))),o.length>0&&this.dispatch(jt(o.map(({uuid:l})=>l))),d.length>0&&this.dispatch(Xa(d.map(({uuid:l})=>l)));try{return await this.enqueueRequest({description:"Delete issue",method:h.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(l){throw this.dispatch(oi(c)),this.dispatch(ei(n)),this.dispatch(_l(r)),this.dispatch(Et(o)),this.dispatch(Ja(d)),l}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:h.GET,url:"/issues/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(wo(s)),s}}class Xb extends Ue{constructor(){super(...arguments);S(this,"name","Issue Type Attachment");S(this,"url","/issue-type-attachments");S(this,"initializeAttachments",Ai);S(this,"addAttachments",Vo);S(this,"updateAttachments",Do);S(this,"removeAttachments",Uo);S(this,"removeAttachment",Co);S(this,"setAttachment",zo);S(this,"selectAttachment",$o)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.issueTypeUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get issue type attachments",method:h.GET,url:`${this.url}/`,queryParams:{issue_type__organization:s},blocks:[],blockers:[]});return this.dispatch(Ai(i)),i}}class Qb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(b);const F={uuid:b.uuid,file_name:A.name,file_extension:y.extension,field_identifier:p,file_sha1:y.sha1,fields_revision:l};r.push(F)}this.dispatch(Ho(n));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(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Wo(d.attachments))}).catch(()=>{this.dispatch(Ko(n.map(d=>d.uuid)))}),[n,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:{fields_revision__issue_type__organization:e},blockers:[e],blocks:[]});return this.dispatch(No(s)),s}}class xb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(al(n));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:h.POST,url:"/issue-type-fields/",payload:w(n),blockers:[n.issue_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(il(m))}).catch(m=>{throw this.dispatch(cl(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:h.GET,url:"/issue-type-fields/",queryParams:{issue_type__organization:e},blockers:[],blocks:[]});return this.dispatch(sl(s)),s}}class eF extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldValuesUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,field_values:l,submitted_at:s,field_identifier:p});n.push(b);const F={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,field_values:l};r.push(F)}this.dispatch(zt(n));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(c)},blockers:n.map(d=>d.field_values),blocks:n.map(d=>d.uuid)});return o.then(({presigned_urls:d,attachments:l})=>{this.processPresignedUrls(d),this.dispatch(ol(l))}).catch(d=>{throw this.dispatch(Dt(n.map(l=>l.uuid))),d}),[n,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=hl(e)(i);this.dispatch(Dt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:h.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:e,blockers:e,blocks:[]})}catch(n){throw this.dispatch(zt(c)),n}}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:{field_values__issue__project:e},blockers:[],blocks:[]});return this.dispatch(ul(s)),s}}class tF extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add issue type field values",method:h.POST,url:"/issue-type-field-values/",payload:w(c),blockers:[e.issue,e.fields_revision],blocks:[c.uuid]});return this.dispatch(Si(c)),n.then(o=>(this.dispatch(nt(o)),o)).catch(()=>{this.dispatch(gi(c.uuid))}),[c,n]}update(e){const{store:s}=this.client,i=s.getState(),c=Fi(e.uuid)(i);if(!c)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(nt(n));const r=this.enqueueRequest({description:"Update issue type field values",method:h.PATCH,url:`/issue-type-field-values/${e.uuid}/`,payload:e,blockers:[n.uuid,n.fields_revision,n.issue],blocks:[n.uuid]});return r.then(o=>{this.dispatch(nt(o))}).catch(()=>{this.dispatch(nt(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Fi(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=ml(e)(i);this.dispatch(gi(e)),this.dispatch(Dt(n.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(Si(c)),this.dispatch(zt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:h.GET,url:"/issue-type-field-values/",queryParams:{issue__project:e},blockers:[],blocks:[]});return this.dispatch(Qo(s)),s}}class sF extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,submitted_at:new Date().toISOString(),created_by:(r=i.userReducer.currentUser)==null?void 0:r.id});this.dispatch(fl(c));const n=this.enqueueRequest({method:h.POST,url:"/issue-types/",payload:w(c),blockers:[],blocks:[c.uuid]});return n.then(o=>{this.dispatch(rt(o))}).catch(()=>{this.dispatch(Oi(c.uuid))}),[c,n]}update(e){const{store:s}=this.client,i=s.getState(),c=Ri(e.uuid)(i);if(!c)throw new Error(`IssueType with uuid ${e.uuid} does not exist in the store.`);const n={...c,...e};this.dispatch(Sl(n));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(rt(o))}).catch(()=>{this.dispatch(rt(c))}),[n,r]}delete(e){const{store:s}=this.client,i=s.getState(),c=Ri(e)(i);if(!c)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const n=vi(e)(i);this.dispatch(Oi(e)),this.dispatch(Eo(n.map(o=>o.uuid)));const r=this.enqueueRequest({method:h.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(rt(c)),this.dispatch(Mo(n))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:h.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(yl(s)),s}}class aF extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:h.GET,url:"/issue-updates/",queryParams:{issue__project:e},blockers:[],blocks:[]});return this.dispatch(Tl(s)),s}}const iF=1800;function cF(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 nF extends ub{constructor(){super(...arguments);S(this,"_getRenewedTokens",async s=>{const i=this.enqueueRequest({description:"Get renewed tokens",method:h.POST,url:this.refreshTokensUrl,payload:{refresh:s},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let c;try{c=await i}catch(n){console.error("Could not renew tokens; clearing auth",n),this.clearAuth();return}if(!c.access)throw new Error("Missing access token");return{accessToken:c.access,refreshToken:c.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Pd(!1)),this.clearTokens(),this.dispatch(P),this.dispatch(P)}async renewTokens(){const s=this.getRefreshToken();if(!s)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const i=await this._getRenewedTokens(s);if(!i)return;console.log("Got renewed tokens"),this.setTokens(i)}catch(i){throw console.error("Could not renew tokens; clearing auth",i),this.clearAuth(),i}}tokenIsExpiringSoon(){const s=this.getAccessToken();if(!s)return!1;const i=Date.now()/1e3;let c;try{c=Sm(s).exp??i}catch{c=i}return c-i<iF}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 D&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??We).toString()))}}}async handleUnauthorized(s,i){const c=this.client.store.getState();if(s.url.endsWith("/token/refresh/"))throw c.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new D({message:"You have been signed out due to inactivity.",response:i,discard:!0});if(c.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new D({message:"Incorrect username or password.",response:i,discard:!0})}async initAuth(s){const i=Le.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:i,description:"Get token pair",method:h.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(c=>{this.setTokens(cF(c))})}}class rF extends R{update(e){const{store:s}=this.client,i=Vi(e.uuid)(s.getState()),c={...i,...e};this.dispatch(Ut(c));const n=this.enqueueRequest({description:"Edit organization access",method:h.PATCH,url:`/organization-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(Ut(r))}).catch(r=>{throw this.dispatch(Ut(i)),r}),[c,n]}async remove(e){const{store:s}=this.client,i=s.getState(),c=Vi(e)(i),n=Cl(c.user)(i);this.dispatch($l(c.uuid)),this.dispatch(Vl(c.user));try{await this.enqueueRequest({description:"Remove organization access",method:h.DELETE,url:`/organization-accesses/${c.uuid}/`,blockers:[c.uuid],blocks:[]})}catch(r){throw this.dispatch(Bl(c)),this.dispatch(ql(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:h.GET,url:"/organization-accesses/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(kl(s)),s}}class dF extends R{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(){const e=await this.enqueueRequest({description:"Fetch organizations",method:h.GET,url:"/organizations/",blockers:[],blocks:[]});return this.dispatch(Hl(e)),e}}class uF extends R{add(e){const s=T(e);this.dispatch(Ui(s));const i=this.enqueueRequest({description:"Add project access",method:h.POST,url:"/project-accesses/",payload:w(s),blockers:[s.organization_access,s.project],blocks:[s.uuid]});return i.then(c=>{this.dispatch(dt(c))}).catch(c=>{throw this.dispatch(ki(s.uuid)),c}),[s,i]}update(e){const{store:s}=this.client,i=$i(e.uuid)(s.getState()),c={...i,...e};this.dispatch(dt(c));const n=this.enqueueRequest({description:"Edit project access",method:h.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[]});return n.then(r=>{this.dispatch(dt(r))}).catch(r=>{throw this.dispatch(dt(i)),r}),[c,n]}async remove(e){const{store:s}=this.client,i=$i(e)(s.getState());this.dispatch(ki(e));try{await this.enqueueRequest({description:"Delete project access",method:h.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}catch(c){throw this.dispatch(Ui(i)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:h.GET,url:"/project-accesses/",queryParams:{project__organization_owner:e},blockers:[],blocks:[]});return this.dispatch(th(s)),s}}class oF extends Ue{constructor(){super(...arguments);S(this,"name","Project Attachment");S(this,"url","/project-attachments");S(this,"addAttachments",dh);S(this,"updateAttachments",lh);S(this,"removeAttachments",Li);S(this,"removeAttachment",hh);S(this,"setAttachment",uh);S(this,"selectAttachment",Ah)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.projectUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get project attachments",method:h.GET,url:`${this.url}/`,queryParams:{project__organization_owner:s},blockers:[],blocks:[]});return this.dispatch(rh(i)),i}}class lF extends R{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 i=this.enqueueRequest({method:h.PATCH,url:`/project-files/${e.uuid}/`,payload:s,blockers:[e.uuid],blocks:[e.uuid]});return i.then(c=>{this.dispatch(Hi(c))}),i}saveActive(){const{store:e}=this.client,s=e.getState(),i=s.projectFileReducer.activeProjectFileId;if(!i)throw new Error("No active project file");const c=s.projectFileReducer.instances[i];if(!c)throw new Error("No active project file");if(!c.bounds&&!c.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let n;if(typeof c.file=="string"&&!c.file.startsWith("blob:")){const m={...c};delete m.file,n={method:h.PATCH,url:`/project-files/${i}/`,payload:m,blockers:[i],blocks:[i]}}else n=new Promise((m,d)=>{this.client.files.uploadFileToS3(c.file_sha1).then(([l])=>{m({method:h.POST,url:`/project-files${c.project}/`,payload:{...c,...l},blockers:[i],blocks:[i]})}).catch(d)});const o=Promise.resolve(n).then(m=>this.enqueueRequest(m));return o.then(m=>{this.dispatch(Hi(m))}),this.dispatch(_h),this.dispatch(Ih(null)),this.dispatch(Th(!1)),[c,o]}delete(e){return this.dispatch(Fh(e)),this.enqueueRequest({method:h.DELETE,url:`/project-files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:h.GET,url:"/project-files/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(gh(s)),s}}class hF extends R{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(jh(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,i=s.getState(),c=zh(e)(i);if(!c)throw new Error("Expected project to exist");const n=Rh(i).filter(m=>m.project===e);this.dispatch(Ph(n.map(({uuid:m})=>m)));const r=yh(c.uuid)(i);this.dispatch(Li(r.map(({uuid:m})=>m)));const o=ch(e)(i);this.dispatch(ah(o.map(({uuid:m})=>m))),this.dispatch(Ki(c.uuid));try{await this.enqueueRequest({description:"Delete project",method:h.DELETE,url:`/projects/${e}/`,blockers:[e],blocks:[]}),this.dispatch(Ki(c.uuid))}catch(m){throw this.dispatch(Eh(c)),this.dispatch(sh(Object.values(o))),this.dispatch(bh(n)),this.dispatch(oh(r)),m}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch projects",method:h.GET,url:"/projects/",queryParams:{organization_owner:e},blockers:[],blocks:[]});return this.dispatch(Mh(s)),s}}class mF extends R{add(e){const s=T(e);this.dispatch(kh(s));const i=this.enqueueRequest({description:"Create team membership",method:h.POST,url:"/team-memberships/",payload:w(s),blockers:[e.team],blocks:[s.uuid]});return i.then(c=>{this.dispatch(Xi(c))}).catch(()=>{this.dispatch(Qi(s.uuid))}),[s,i]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Gh(e)(i);if(!c)throw new Error(`Expected team membership with uuid ${e} to exist`);this.dispatch(Qi(e));try{return await this.enqueueRequest({description:"Delete team membership",method:h.DELETE,url:`/team-memberships/${e}/`,blockers:[e],blocks:[e]})}catch(n){throw this.dispatch(Xi(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch team memberships",method:h.GET,url:"/team-memberships/",queryParams:{team__organization:e},blockers:[],blocks:[]});return this.dispatch(Uh(s)),s}}class pF extends R{add(e){const s=T({...e,submitted_at:new Date().toISOString()});this.dispatch(Hh(s));const i=this.enqueueRequest({description:"Create team",method:h.POST,url:"/teams/",payload:w(s),blockers:[],blocks:[s.uuid]});return i.then(c=>{this.dispatch(ut(c))}).catch(()=>{this.dispatch(tc(s.uuid))}),[s,i]}update(e){const{store:s}=this.client,i=ac(e.uuid)(s.getState());if(!i)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Wh(c));const n=this.enqueueRequest({description:"Update team",method:h.PATCH,url:`/teams/${e.uuid}/`,payload:w(e),blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(ut(r))}).catch(()=>{this.dispatch(ut(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=ac(e)(i);if(!c)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(tc(e));try{return await this.enqueueRequest({description:"Delete team",method:h.DELETE,url:`/teams/${e}/`,blockers:[e],blocks:[e]})}catch(n){throw this.dispatch(ut(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:h.GET,url:"/teams/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(Nh(s)),s}}class AF extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization users",method:h.GET,url:`/organizations/${e}/users/`,blockers:[],blocks:[]});return this.dispatch(jl(s)),s}}class yF{constructor(e){S(this,"store");this.store=e}async enqueueRequest(e,s,i){return this._enqueueRequest(e,s,i).then(c=>{if(c instanceof D)throw c;return c})}_enqueueRequest(e,s,i){const c=new fc,n={...e,BASE_URL:s,serviceName:i};if(e.immediate){const r={...n,uuid:e.uuid??Le.v4()},o={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:i}}}};nc(o,this).then(m=>{c.resolve(m.body)}).catch(m=>{rc(m,o),m instanceof Error?c.reject(m):c.reject(new Error((m??We).toString()))})}else{const r=this.store.dispatch(Zl(n)),o=d=>{if(d)c.resolve(d.body);else{const l=new D({message:"Could not get a response from the server.",response:d,discard:!0});c.reject(l)}},m=d=>{d instanceof D?d.options.discard=!0:(console.error("Received an unexpected error while processing a request:",d,`
|
|
15
|
-
Converting error to APIError and discarding.`),d=new D({message:"An error occurred while processing the request.",innerError:d,discard:!0})),c.reject(d)};r.then(o,m)}return c}}class Ke{constructor(){S(this,"graph");S(this,"requestAttemptCounter");this.graph=new gm.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Ke;for(let i=0;i<e.length;i++){const c=e[i];if(!c){console.error("Outbox item was undefined");continue}s.sneakRequest(c);for(let n=0;n<i;n++){const r=e[n];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==c.payload.uuid&&r.payload.blocks.some(o=>c.payload.blockers.includes(o))&&Ke._addDependency(c.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){Ke._addDependency(e,s,this.graph)}static _addDependency(e,s,i){if(e===s)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!i.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${s})`);if(!i.hasNode(s))throw new Error(`Tried to add dependency to non-existent node: ${s} (from node: ${e})`);i.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 i=this.graph.getNodeData(s);e.payload.blockers.some(c=>i.payload.blocks.includes(c))&&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(c=>e.payload.blocks.includes(c))&&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,i;for(const c of e){const n=this.requestAttemptCounter[c]||0;n<s&&(s=n,i=c)}return i}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(i=>this.graph.getNodeData(i)),s=this._getNextNode();if(s){const i=this.graph.getNodeData(s),c=e.findIndex(n=>n.payload.uuid===i.payload.uuid);c!==-1&&(e.splice(c,1),e.unshift(i))}return e}getReady(){let e=this.graph.overallOrder(!0).map(s=>this.graph.getNodeData(s));return e=e.sort((s,i)=>s.meta.offline.effect.timestamp.localeCompare(i.meta.offline.effect.timestamp)),e=e.sort((s,i)=>{const c=this.requestAttemptCounter[s.payload.uuid]||0,n=this.requestAttemptCounter[i.payload.uuid]||0;return c-n}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const fF=(t,e)=>{const s=new e(t);return Lg(s),Gg(t),s};var lm=(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))(lm||{});a.APIError=D,a.AgentService=ob,a.AssetAttachmentService=lb,a.AssetProcedureAttachmentService=hb,a.AssetProcedureFieldValuesAttachmentService=Ab,a.AssetProcedureFieldValuesService=yb,a.AssetProcedureFieldsAttachmentService=mb,a.AssetProcedureFieldsService=pb,a.AssetProcedureInstanceService=fb,a.AssetProcedureService=Sb,a.AssetProcedureStepFieldValuesAttachmentService=Fb,a.AssetProcedureStepFieldValuesService=Pb,a.AssetProcedureStepFieldsAttachmentService=gb,a.AssetProcedureStepFieldsService=bb,a.AssetProcedureStepService=Tb,a.AssetService=Ib,a.AssetStageCompletionService=_b,a.AssetStageService=Ob,a.AssetTypeAttachmentService=Rb,a.AssetTypeFieldValuesAttachmentService=Mb,a.AssetTypeFieldValuesService=Eb,a.AssetTypeFieldsAttachmentService=vb,a.AssetTypeFieldsService=wb,a.AssetTypeService=jb,a.AttachmentModel=Ac,a.BaseApiService=R,a.BaseSDK=yF,a.COMMON_AUTO_FIELDS=Pc,a.CategoryService=qb,a.DEFAULT_ISSUE_PRIORITY=Fm,a.DEFAULT_ISSUE_STATUS=bm,a.DeferredPromise=fc,a.DocumentAttachmentService=Vb,a.DocumentService=zb,a.EMPTY_ARRAY=hc,a.EMPTY_OBJECT=mc,a.EmailDomainsService=Db,a.EmailVerificationService=Cb,a.FileService=kb,a.FormRevisionAttachmentService=Bb,a.FormRevisionService=$b,a.FormService=Gb,a.FormSubmissionAttachmentService=Lb,a.FormSubmissionService=Nb,a.GeoImageService=Hb,a.HttpMethod=h,a.IssueAssociationService=Wb,a.IssueAttachmentService=Kb,a.IssueCommentAttachmentService=Yb,a.IssueCommentService=Jb,a.IssuePriority=Gt,a.IssueService=Zb,a.IssueStatus=Lt,a.IssueTypeAttachmentService=Xb,a.IssueTypeFieldValuesAttachmentService=eF,a.IssueTypeFieldValuesService=tF,a.IssueTypeFieldsAttachmentService=Qb,a.IssueTypeFieldsService=xb,a.IssueTypeService=sF,a.IssueUpdateChange=E,a.IssueUpdateService=aF,a.JWTService=nF,a.OUTBOX_RETRY_DELAY=yc,a.OrganizationAccessLevel=pc,a.OrganizationAccessService=rF,a.OrganizationService=dF,a.OutboxCoordinator=Ke,a.ProjectAccessService=uF,a.ProjectAttachmentService=oF,a.ProjectFileService=lF,a.ProjectService=hF,a.RESET_ORGANIZATION_STATE=O,a.RESET_PROJECT_STATE=M,a.RESET_STATE=P,a.TeamMembershipService=mF,a.TeamService=pF,a.UNKNOWN_ERROR_MESSAGE=We,a.UserService=AF,a.VERSION_REDUCER_KEY=Je,a.VerificationCodeType=lm,a._setLatestRetryTime=Ql,a.addAsset=Bs,a.addAssetAttachment=Qm,a.addAssetAttachments=Qt,a.addAssetProcedure=Ss,a.addAssetProcedureAttachment=tp,a.addAssetProcedureAttachments=Gc,a.addAssetProcedureFieldValues=rs,a.addAssetProcedureFieldValuesAttachment=bp,a.addAssetProcedureFieldValuesAttachments=mt,a.addAssetProcedureFieldValuesMany=Pn,a.addAssetProcedureFields=dn,a.addAssetProcedureFieldsAttachment=cp,a.addAssetProcedureFieldsAttachments=xc,a.addAssetProcedureFieldsMany=hp,a.addAssetProcedureInstance=hs,a.addAssetProcedureInstances=wn,a.addAssetProcedureStep=yA,a.addAssetProcedureStepFieldValues=Es,a.addAssetProcedureStepFieldValuesAttachment=iA,a.addAssetProcedureStepFieldValuesAttachments=At,a.addAssetProcedureStepFieldValuesMany=ar,a.addAssetProcedureStepFields=Is,a.addAssetProcedureStepFieldsAttachment=Gp,a.addAssetProcedureStepFieldsAttachments=kn,a.addAssetProcedureStepFieldsMany=Jp,a.addAssetProcedureSteps=zs,a.addAssetProcedures=zp,a.addAssetStage=vA,a.addAssetStageCompletion=Ks,a.addAssetStageCompletions=Ys,a.addAssetStages=xs,a.addAssetType=ya,a.addAssetTypeAttachment=jA,a.addAssetTypeAttachments=ia,a.addAssetTypeFieldValues=la,a.addAssetTypeFieldValuesAttachment=ZA,a.addAssetTypeFieldValuesAttachments=It,a.addAssetTypeFieldValuesMany=hd,a.addAssetTypeFields=Qr,a.addAssetTypeFieldsAttachment=zA,a.addAssetTypeFieldsAttachments=Nr,a.addAssetTypeFieldsMany=GA,a.addAssetTypes=dy,a.addAssets=bt,a.addCategories=fy,a.addCategory=Fa,a.addConversation=Rc,a.addConversations=Hm,a.addDocumentAttachment=Iy,a.addDocumentAttachments=jd,a.addDocuments=Ld,a.addEmailDomain=Zd,a.addEmailDomains=Ey,a.addForm=Va,a.addFormRevision=Ea,a.addFormRevisionAttachment=ky,a.addFormRevisionAttachments=du,a.addFormRevisions=Au,a.addFormSubmission=ka,a.addFormSubmissionAttachment=cf,a.addFormSubmissionAttachments=vt,a.addFormSubmissions=Et,a.addForms=Xy,a.addGeoImage=Lu,a.addGeoImages=Nu,a.addIssue=oi,a.addIssueAssociation=Ya,a.addIssueAssociations=Ja,a.addIssueAttachment=Sf,a.addIssueAttachments=ei,a.addIssueComment=ci,a.addIssueCommentAttachment=Ff,a.addIssueCommentAttachments=Ao,a.addIssueComments=Of,a.addIssueType=fl,a.addIssueTypeAttachment=Df,a.addIssueTypeAttachments=Vo,a.addIssueTypeFieldValues=Si,a.addIssueTypeFieldValuesAttachment=dS,a.addIssueTypeFieldValuesAttachments=zt,a.addIssueTypeFieldValuesMany=Kf,a.addIssueTypeFields=al,a.addIssueTypeFieldsAttachment=Bf,a.addIssueTypeFieldsAttachments=Ho,a.addIssueTypeFieldsMany=xf,a.addIssueTypes=pS,a.addIssueUpdate=Il,a.addIssueUpdates=_l,a.addIssues=Mo,a.addOrganization=HS,a.addOrganizationAccess=Bl,a.addOrganizationAccesses=zS,a.addOrganizations=NS,a.addProject=Eh,a.addProjectAccess=Ui,a.addProjectAccesses=sh,a.addProjectAttachment=ng,a.addProjectAttachments=dh,a.addProjectFile=og,a.addProjectFiles=bh,a.addProjects=Sg,a.addTeam=Hh,a.addTeamMembership=kh,a.addTeamMemberships=Og,a.addTeams=qg,a.addUser=ql,a.addUsers=vS,a.agentsReducer=Mc,a.agentsSlice=Yt,a.areArraysEqual=Rm,a.assetAttachmentReducer=kc,a.assetAttachmentSlice=Zt,a.assetProcedureAttachmentReducer=Zc,a.assetProcedureAttachmentSlice=es,a.assetProcedureFieldValuesAttachmentReducer=gn,a.assetProcedureFieldValuesAttachmentSlice=is,a.assetProcedureFieldValuesReducer=On,a.assetProcedureFieldValuesSlice=ns,a.assetProcedureFieldsAttachmentReducer=cn,a.assetProcedureFieldsAttachmentSlice=ts,a.assetProcedureFieldsReducer=hn,a.assetProcedureFieldsSlice=ss,a.assetProcedureInstanceReducer=jn,a.assetProcedureInstanceSlice=ls,a.assetProcedureReducer=Dn,a.assetProcedureSlice=fs,a.assetProcedureStepFieldValuesAttachmentReducer=er,a.assetProcedureStepFieldValuesAttachmentSlice=vs,a.assetProcedureStepFieldValuesReducer=rr,a.assetProcedureStepFieldValuesSlice=Ms,a.assetProcedureStepFieldsAttachmentReducer=Nn,a.assetProcedureStepFieldsAttachmentSlice=Ps,a.assetProcedureStepFieldsReducer=Kn,a.assetProcedureStepFieldsSlice=Ts,a.assetProcedureStepReducer=lr,a.assetProcedureStepSlice=Vs,a.assetReducer=Sr,a.assetSlice=ks,a.assetStageCompletionReducer=Tr,a.assetStageCompletionSlice=Ws,a.assetStageReducer=wr,a.assetStageSlice=Qs,a.assetTypeAttachmentReducer=$r,a.assetTypeAttachmentSlice=aa,a.assetTypeFieldValuesAttachmentReducer=ud,a.assetTypeFieldValuesAttachmentSlice=da,a.assetTypeFieldValuesReducer=yd,a.assetTypeFieldValuesSlice=oa,a.assetTypeFieldsAttachmentReducer=Jr,a.assetTypeFieldsAttachmentSlice=na,a.assetTypeFieldsReducer=sd,a.assetTypeFieldsSlice=ra,a.assetTypeReducer=bd,a.assetTypeSlice=Aa,a.authReducer=Td,a.authSlice=Ot,a.baseReducer=Bg,a.baseReducers=ic,a.blobToBase64=Dm,a.categoryReducer=wd,a.categorySlice=ba,a.clearTokens=py,a.constructUploadedFilePayloads=zm,a.coordinatesAreEqual=_m,a.createModelAdapter=I,a.createMultiPointGeometry=Im,a.createOfflineAction=Yl,a.createPayload=w,a.createPointGeometry=Tm,a.createSelectionAdapter=Pm,a.deleteAsset=$s,a.deleteAssetAttachment=Vc,a.deleteAssetAttachments=xt,a.deleteAssetProcedure=gs,a.deleteAssetProcedureAttachment=Hc,a.deleteAssetProcedureAttachments=Wc,a.deleteAssetProcedureFieldValues=ds,a.deleteAssetProcedureFieldValuesAttachment=Ip,a.deleteAssetProcedureFieldValuesAttachments=pt,a.deleteAssetProcedureFieldValuesMany=In,a.deleteAssetProcedureFields=on,a.deleteAssetProcedureFieldsAttachment=up,a.deleteAssetProcedureFieldsAttachments=tn,a.deleteAssetProcedureFieldsMany=yp,a.deleteAssetProcedureInstance=ms,a.deleteAssetProcedureInstances=Mn,a.deleteAssetProcedureStep=fA,a.deleteAssetProcedureStepFieldValues=js,a.deleteAssetProcedureStepFieldValuesAttachment=dA,a.deleteAssetProcedureStepFieldValuesAttachments=yt,a.deleteAssetProcedureStepFieldValuesMany=cr,a.deleteAssetProcedureStepFields=_s,a.deleteAssetProcedureStepFieldsAttachment=Wp,a.deleteAssetProcedureStepFieldsAttachments=$n,a.deleteAssetProcedureStepFieldsMany=xp,a.deleteAssetProcedureSteps=Cs,a.deleteAssetProcedures=Cp,a.deleteAssetStage=wA,a.deleteAssetStageCompletion=Js,a.deleteAssetStageCompletions=Zs,a.deleteAssetStages=ta,a.deleteAssetType=fa,a.deleteAssetTypeAttachment=Dr,a.deleteAssetTypeAttachments=ca,a.deleteAssetTypeFieldValues=ha,a.deleteAssetTypeFieldValuesAttachment=ey,a.deleteAssetTypeFieldValuesAttachments=_t,a.deleteAssetTypeFieldValuesMany=pd,a.deleteAssetTypeFields=ed,a.deleteAssetTypeFieldsAttachment=kA,a.deleteAssetTypeFieldsAttachments=Wr,a.deleteAssetTypeFieldsMany=WA,a.deleteAssetTypes=oy,a.deleteAssets=Gs,a.deleteCategories=Fy,a.deleteCategory=Rd,a.deleteConversation=Ym,a.deleteConversations=Jm,a.deleteDocumentAttachment=zd,a.deleteDocumentAttachments=Dd,a.deleteEmailDomain=Xd,a.deleteEmailDomains=Dy,a.deleteForm=za,a.deleteFormRevision=ja,a.deleteFormRevisionAttachment=Ly,a.deleteFormRevisionAttachments=ou,a.deleteFormRevisions=fu,a.deleteFormSubmission=Ba,a.deleteFormSubmissionAttachment=uf,a.deleteFormSubmissionAttachments=wt,a.deleteFormSubmissions=jt,a.deleteForms=sf,a.deleteGeoImage=Ha,a.deleteGeoImages=Wu,a.deleteIssue=li,a.deleteIssueAssociation=Za,a.deleteIssueAssociations=Xa,a.deleteIssueAttachment=ro,a.deleteIssueAttachments=ti,a.deleteIssueComment=ri,a.deleteIssueCommentAttachment=So,a.deleteIssueCommentAttachments=go,a.deleteIssueComments=wf,a.deleteIssueType=fS,a.deleteIssueTypeAttachment=Co,a.deleteIssueTypeAttachments=Uo,a.deleteIssueTypeFieldValues=gi,a.deleteIssueTypeFieldValuesAttachment=hS,a.deleteIssueTypeFieldValuesAttachments=Dt,a.deleteIssueTypeFieldValuesMany=Xf,a.deleteIssueTypeFields=cl,a.deleteIssueTypeFieldsAttachment=Nf,a.deleteIssueTypeFieldsAttachments=Ko,a.deleteIssueTypeFieldsMany=aS,a.deleteIssueTypes=SS,a.deleteIssueUpdate=Ol,a.deleteIssueUpdates=Rl,a.deleteIssues=Eo,a.deleteOrganization=YS,a.deleteOrganizationAccess=$l,a.deleteOrganizationAccesses=kS,a.deleteOrganizations=JS,a.deleteProject=Ki,a.deleteProjectAccess=ki,a.deleteProjectAccesses=ah,a.deleteProjectAttachment=hh,a.deleteProjectAttachments=Li,a.deleteProjectFile=Fh,a.deleteProjectFiles=Ph,a.deleteProjects=bg,a.deleteTeam=tc,a.deleteTeamMembership=Qi,a.deleteTeamMemberships=Mg,a.deleteTeams=Dg,a.deleteUser=Vl,a.deleteUsers=ES,a.dequeue=rm,a.discard=rc,a.documentAttachmentReducer=Bd,a.documentAttachmentSlice=Ia,a.documentSlice=_a,a.documentsReducer=Kd,a.downloadFile=Cm,a.downloadInMemoryFile=Vm,a.emailDomainsReducer=eu,a.emailDomainsSlice=Ra,a.emailRegex=Nm,a.enqueue=nm,a.enqueueRequest=Zl,a.fallbackToEmptyArray=g,a.fallbackToEmptyObject=ht,a.fileReducer=cu,a.fileSlice=va,a.fileToBlob=bc,a.formReducer=Tu,a.formRevisionAttachmentReducer=hu,a.formRevisionAttachmentSlice=wa,a.formRevisionReducer=bu,a.formRevisionsSlice=Ma,a.formSlice=qa,a.formSubmissionAttachmentReducer=ju,a.formSubmissionAttachmentSlice=Da,a.formSubmissionReducer=ku,a.formSubmissionSlice=Ua,a.geoImageReducer=Ju,a.geoImageSlice=Na,a.getFileIdentifier=qm,a.getFileS3Key=Kt,a.getLocalDateString=Sc,a.getLocalRelativeDateString=Em,a.getOutboxCoordinator=ke,a.getRenamedFile=gc,a.hashFile=Ne,a.initSDK=fF,a.initializeAssetAttachments=Xt,a.initializeAssetProcedureAttachments=$c,a.initializeAssetProcedureFieldValues=Fn,a.initializeAssetProcedureFieldValuesAttachments=pn,a.initializeAssetProcedureFields=rn,a.initializeAssetProcedureFieldsAttachments=Qc,a.initializeAssetProcedureInstances=vn,a.initializeAssetProcedureStepFieldValues=sr,a.initializeAssetProcedureStepFieldValuesAttachments=Jn,a.initializeAssetProcedureStepFields=Wn,a.initializeAssetProcedureStepFieldsAttachments=Un,a.initializeAssetProcedureSteps=ur,a.initializeAssetProcedures=Vn,a.initializeAssetStageCompletions=br,a.initializeAssetStages=Rr,a.initializeAssetTypeAttachments=qr,a.initializeAssetTypeFieldValues=ld,a.initializeAssetTypeFieldValuesAttachments=id,a.initializeAssetTypeFields=Xr,a.initializeAssetTypeFieldsAttachments=Lr,a.initializeAssetTypes=Sd,a.initializeAssets=Ar,a.initializeCategories=_d,a.initializeConversations=Oc,a.initializeDocumentAttachments=Ed,a.initializeEmailDomains=Jd,a.initializeFormRevisionAttachments=ru,a.initializeFormRevisions=pu,a.initializeFormSubmissionAttachments=vu,a.initializeFormSubmissions=Vu,a.initializeForms=Pu,a.initializeGeoImages=$u,a.initializeIssueAssociations=Xu,a.initializeIssueAttachments=xa,a.initializeIssueCommentAttachments=ai,a.initializeIssueComments=_f,a.initializeIssueTypeAttachments=Ai,a.initializeIssueTypeFieldValues=Qo,a.initializeIssueTypeFieldValuesAttachments=ul,a.initializeIssueTypeFields=sl,a.initializeIssueTypeFieldsAttachments=No,a.initializeIssueTypes=yl,a.initializeIssueUpdates=Tl,a.initializeIssues=wo,a.initializeOrganizationAccesses=kl,a.initializeOrganizations=GS,a.initializeProjectAccesses=th,a.initializeProjectAttachments=rh,a.initializeProjectFiles=gh,a.initializeProjects=Mh,a.initializeTeamMemberships=Uh,a.initializeTeams=Nh,a.initializeUsers=jl,a.isToday=Mm,a.issueAssociationReducer=ao,a.issueAssociationSlice=Ka,a.issueAttachmentReducer=mo,a.issueAttachmentSlice=Qa,a.issueCommentAttachmentReducer=To,a.issueCommentAttachmentSlice=si,a.issueCommentReducer=Ro,a.issueCommentSlice=ii,a.issueReducer=jo,a.issueSlice=ui,a.issueTypeAttachmentReducer=Go,a.issueTypeAttachmentSlice=pi,a.issueTypeFieldValuesAttachmentReducer=pl,a.issueTypeFieldValuesAttachmentSlice=Ti,a.issueTypeFieldValuesReducer=el,a.issueTypeFieldValuesSlice=fi,a.issueTypeFieldsAttachmentReducer=Zo,a.issueTypeFieldsAttachmentSlice=yi,a.issueTypeFieldsReducer=rl,a.issueTypeFieldsSlice=Pi,a.issueTypeReducer=Fl,a.issueTypeSlice=_i,a.issueUpdateReducer=Ml,a.issueUpdateSlice=wi,a.logOnlyOnce=Um,a.markAsDeleted=Xl,a.markForDeletion=eg,a.memoize=Ht,a.moveDocument=Nd,a.offline=T,a.onlyUniqueHashes=Lm,a.onlyUniqueOfflineIds=Ic,a.organizationAccessReducer=Gl,a.organizationAccessSlice=ji,a.organizationReducer=Kl,a.organizationSlice=zi,a.outboxReducer=xl,a.outboxSlice=Di,a.overmapEnhancer=Qg,a.overmapReducer=$g,a.overmapReducers=Xh,a.performRequest=nc,a.projectAccessReducer=ih,a.projectAccessSlice=Ci,a.projectAttachmentReducer=fh,a.projectAttachmentSlice=Gi,a.projectFileReducer=vh,a.projectFileSlice=Ni,a.projectReducer=qh,a.projectSlice=Wi,a.rehydratedReducer=Dh,a.rehydratedSlice=Ji,a.removeDocuments=Oa,a.removeIssueType=Oi,a.resetProjectFileObjectUrls=hg,a.restructureCreateSelectorWithArgs=f,a.saveActiveProjectFileBounds=_h,a.selectAccessToken=Ay,a.selectAccessesByUserOfProject=ig,a.selectAccessibleProjects=Fg,a.selectActiveOrganizationAccess=BS,a.selectActiveProjectFileId=pg,a.selectAllDocumentAttachments=Ud,a.selectAllProjectAttachments=ph,a.selectAncestorIdsOfDocument=wy,a.selectAssetAttachmentById=Cc,a.selectAssetAttachmentMapping=zc,a.selectAssetAttachments=Dc,a.selectAssetById=Hs,a.selectAssetProcedureAttachmentById=Jc,a.selectAssetProcedureAttachmentMapping=Kc,a.selectAssetProcedureAttachments=Yc,a.selectAssetProcedureById=Fs,a.selectAssetProcedureFieldValues=us,a.selectAssetProcedureFieldValuesAttachmentById=_p,a.selectAssetProcedureFieldValuesAttachments=yn,a.selectAssetProcedureFieldValuesAttachmentsByIds=fn,a.selectAssetProcedureFieldValuesAttachmentsMapping=cs,a.selectAssetProcedureFieldValuesById=os,a.selectAssetProcedureFieldValuesMapping=_n,a.selectAssetProcedureFieldValuesOfAsset=vp,a.selectAssetProcedureFields=as,a.selectAssetProcedureFieldsAttachmentById=lp,a.selectAssetProcedureFieldsAttachments=an,a.selectAssetProcedureFieldsAttachmentsMapping=sn,a.selectAssetProcedureFieldsById=gp,a.selectAssetProcedureFieldsMapping=ln,a.selectAssetProcedureFieldsOfAssetProcedure=fp,a.selectAssetProcedureInstanceById=ys,a.selectAssetProcedureInstances=As,a.selectAssetProcedureInstancesByIds=Vp,a.selectAssetProcedureInstancesMapping=ps,a.selectAssetProcedureInstancesOfAssetProcedure=En,a.selectAssetProcedureInstancesOfAssetType=qp,a.selectAssetProcedureStepById=hr,a.selectAssetProcedureStepFieldValues=ft,a.selectAssetProcedureStepFieldValuesAttachmentById=uA,a.selectAssetProcedureStepFieldValuesAttachments=Xn,a.selectAssetProcedureStepFieldValuesAttachmentsByIds=Qn,a.selectAssetProcedureStepFieldValuesAttachmentsMapping=ws,a.selectAssetProcedureStepFieldValuesById=qs,a.selectAssetProcedureStepFieldValuesMapping=nr,a.selectAssetProcedureStepFieldValuesOfAsset=hA,a.selectAssetProcedureStepFieldValuesOfAssetProcedureInstance=mA,a.selectAssetProcedureStepFieldValuesOfAssetProcedureStep=pA,a.selectAssetProcedureStepFields=Rs,a.selectAssetProcedureStepFieldsAttachmentById=Yp,a.selectAssetProcedureStepFieldsAttachments=Ln,a.selectAssetProcedureStepFieldsAttachmentsMapping=Gn,a.selectAssetProcedureStepFieldsById=aA,a.selectAssetProcedureStepFieldsMapping=Os,a.selectAssetProcedureStepFieldsOfAssetProcedureStep=eA,a.selectAssetProcedureStepMapping=gt,a.selectAssetProcedureSteps=mr,a.selectAssetProcedureStepsByIds=Us,a.selectAssetProcedureStepsMappingOfAssetProcedure=SA,a.selectAssetProcedureStepsOfAssetProcedure=gA,a.selectAssetProcedures=zn,a.selectAssetProceduresByIds=Bp,a.selectAssetProceduresMapping=bs,a.selectAssetProceduresOfOrganization=$p,a.selectAssetStageById=Mr,a.selectAssetStageCompletionById=Ir,a.selectAssetStageCompletionMapping=Xs,a.selectAssetStageCompletions=OA,a.selectAssetStageCompletionsByIds=_r,a.selectAssetStages=Er,a.selectAssetStagesByIds=sa,a.selectAssetStagesMappingOfAssetProcedure=MA,a.selectAssetStagesOfAssetProcedure=EA,a.selectAssetTypeAttachmentById=kr,a.selectAssetTypeAttachmentMapping=Cr,a.selectAssetTypeAttachments=Ur,a.selectAssetTypeById=ga,a.selectAssetTypeFieldValues=ma,a.selectAssetTypeFieldValuesAttachmentById=ty,a.selectAssetTypeFieldValuesAttachments=nd,a.selectAssetTypeFieldValuesAttachmentsByIds=rd,a.selectAssetTypeFieldValuesAttachmentsMapping=ua,a.selectAssetTypeFieldValuesById=pa,a.selectAssetTypeFieldValuesMapping=Ad,a.selectAssetTypeFieldValuesOfAsset=iy,a.selectAssetTypeFields=Tt,a.selectAssetTypeFieldsAttachmentById=$A,a.selectAssetTypeFieldsAttachments=Yr,a.selectAssetTypeFieldsAttachmentsMapping=Kr,a.selectAssetTypeFieldsById=JA,a.selectAssetTypeFieldsMapping=td,a.selectAssetTypeFieldsOfAssetType=KA,a.selectAssetTypeValuesOfAssetType=cy,a.selectAssetTypes=gd,a.selectAssetTypesByIds=ly,a.selectAssetTypesMapping=Sa,a.selectAssetTypesOfOrganization=hy,a.selectAssets=yr,a.selectAssetsByIds=fr,a.selectAssetsMapping=Ls,a.selectAssetsOfAssetType=Ns,a.selectAttachmentsOfAsset=Uc,a.selectAttachmentsOfAssetProcedure=ip,a.selectAttachmentsOfAssetProcedureFieldValues=Sn,a.selectAttachmentsOfAssetProcedureFields=op,a.selectAttachmentsOfAssetProcedureStepFieldValues=xn,a.selectAttachmentsOfAssetProcedureStepFields=Kp,a.selectAttachmentsOfAssetType=Br,a.selectAttachmentsOfAssetTypeFieldValues=dd,a.selectAttachmentsOfAssetTypeFields=BA,a.selectAttachmentsOfDocument=Ry,a.selectAttachmentsOfFormRevision=Ny,a.selectAttachmentsOfFormSubmission=Eu,a.selectAttachmentsOfIssue=lo,a.selectAttachmentsOfIssueComment=If,a.selectAttachmentsOfIssueType=kf,a.selectAttachmentsOfIssueTypeFieldValues=ml,a.selectAttachmentsOfIssueTypeFields=Hf,a.selectAttachmentsOfProject=yh,a.selectCategories=vd,a.selectCategoriesByIds=Py,a.selectCategoriesOfProject=Ty,a.selectCategoryById=Ta,a.selectCategoryMapping=Pa,a.selectCommentsOfIssue=Mf,a.selectConversation=Xm,a.selectConversationMapping=Jt,a.selectConversations=Zm,a.selectCurrentUser=Dl,a.selectDeletedRequests=QS,a.selectDocumentAttachmentById=kd,a.selectDocumentAttachmentMapping=Cd,a.selectDocumentById=Wd,a.selectDocuments=Hd,a.selectDocumentsByIds=vy,a.selectDocumentsMapping=He,a.selectEmailDomains=xd,a.selectEmailDomainsAsMapping=Qd,a.selectEmailDomainsOfOrganization=Cy,a.selectFieldValuesOfAssetProcedureInstance=wp,a.selectFormById=Ou,a.selectFormMapping=Iu,a.selectFormRevisionAttachmentsMapping=lu,a.selectFormRevisionById=Jy,a.selectFormRevisionMapping=Rt,a.selectFormRevisions=Su,a.selectFormRevisionsOfForm=gu,a.selectFormSubmissionAttachemntsByIds=Mu,a.selectFormSubmissionAttachmentsMapping=Ca,a.selectFormSubmissionById=La,a.selectFormSubmissions=Ga,a.selectFormSubmissionsMapping=$a,a.selectFormSubmissionsOfAsset=Uu,a.selectFormSubmissionsOfForm=Du,a.selectFormSubmissionsOfIssue=Cu,a.selectForms=_u,a.selectFormsOfOrganization=af,a.selectGeoImageById=Wa,a.selectGeoImageMapping=Ku,a.selectGeoImages=Yu,a.selectGeoImagesOfProject=mf,a.selectIsImportingProjectFile=Ag,a.selectIsLoggedIn=yy,a.selectIssueAssociationById=xu,a.selectIssueAssociationMapping=ct,a.selectIssueAssociations=ff,a.selectIssueAssociationsOfAsset=so,a.selectIssueAssociationsOfIssue=to,a.selectIssueAssociationsToIssue=eo,a.selectIssueAttachmentById=ho,a.selectIssueAttachmentMapping=uo,a.selectIssueAttachments=oo,a.selectIssueById=mi,a.selectIssueCommentAttachmentById=Po,a.selectIssueCommentAttachmentMapping=bo,a.selectIssueCommentAttachments=Fo,a.selectIssueCommentById=di,a.selectIssueCommentMapping=Oo,a.selectIssueMapping=hi,a.selectIssueTypeAttachmentById=$o,a.selectIssueTypeAttachmentMapping=ko,a.selectIssueTypeAttachments=Bo,a.selectIssueTypeById=Ri,a.selectIssueTypeFieldValues=bi,a.selectIssueTypeFieldValuesAttachmentById=mS,a.selectIssueTypeFieldValuesAttachments=ll,a.selectIssueTypeFieldValuesAttachmentsByIds=hl,a.selectIssueTypeFieldValuesAttachmentsMapping=Ii,a.selectIssueTypeFieldValuesById=Fi,a.selectIssueTypeFieldValuesMapping=xo,a.selectIssueTypeFieldValuesOfIssue=Qf,a.selectIssueTypeFields=Vt,a.selectIssueTypeFieldsAttachmentById=Wf,a.selectIssueTypeFieldsAttachments=Jo,a.selectIssueTypeFieldsAttachmentsMapping=Yo,a.selectIssueTypeFieldsById=rS,a.selectIssueTypeFieldsMapping=nl,a.selectIssueTypeFieldsOfIssueType=iS,a.selectIssueTypeMapping=gl,a.selectIssueTypeValuesOfIssueType=nS,a.selectIssueTypes=bl,a.selectIssueTypesByIds=gS,a.selectIssueTypesOfOrganization=bS,a.selectIssueUpdateMapping=vl,a.selectIssueUpdatesOfIssue=wl,a.selectIssues=Vf,a.selectIssuesByIds=zf,a.selectIssuesOfIssueType=vi,a.selectIssuesOfIssueTypeCount=FS,a.selectLatestAssetProcedureFieldsOfAssetProcedure=Sp,a.selectLatestAssetProcedureStepFieldsOfAssetProcedureStep=tA,a.selectLatestAssetTypeFieldsOfAssetType=YA,a.selectLatestFieldsByAssetProcedureStep=sA,a.selectLatestFormRevisionOfForm=Zy,a.selectLatestIssueTypeFieldsOfIssueType=cS,a.selectLatestRetryTime=xS,a.selectMembershipsByUserOfTeam=Eg,a.selectNumberOfAssetsOfAssetType=TA,a.selectOrganizationAccessById=Vi,a.selectOrganizationAccessMapping=qi,a.selectOrganizationAccessUserMapping=Ll,a.selectOrganizationById=XS,a.selectOrganizations=ZS,a.selectOrganizationsMapping=Wl,a.selectProjectAccessById=$i,a.selectProjectAccessMapping=Bi,a.selectProjectAccesses=kt,a.selectProjectAccessesOfProject=ch,a.selectProjectAttachmentById=Ah,a.selectProjectAttachmentMapping=mh,a.selectProjectById=zh,a.selectProjectFileById=mg,a.selectProjectFileMapping=Oh,a.selectProjectFiles=Rh,a.selectProjectMapping=Vh,a.selectProjects=Yi,a.selectProjectsOfOrganization=Pg,a.selectRehydrated=_g,a.selectRootDocuments=My,a.selectStageMapping=Pt,a.selectTeamById=ac,a.selectTeamMembershipById=Gh,a.selectTeamMemberships=xi,a.selectTeamMembershipsMapping=$h,a.selectTeams=Kh,a.selectTeamsByIds=Cg,a.selectTeamsMapping=sc,a.selectTeamsOfOrganization=Ug,a.selectUploadUrl=iu,a.selectUserById=Cl,a.selectUsers=Ei,a.selectUsersByIds=VS,a.selectUsersMapping=Ct,a.selectUsersOfOrganization=$S,a.selectUsersOfProject=cg,a.selectUsersOfTeam=jg,a.setActiveProjectFileId=Ih,a.setAsset=FA,a.setAssetAttachment=jc,a.setAssetAttachments=xm,a.setAssetProcedure=Up,a.setAssetProcedureAttachment=Lc,a.setAssetProcedureAttachments=sp,a.setAssetProcedureFieldValues=Op,a.setAssetProcedureFieldValuesAttachment=Fp,a.setAssetProcedureFieldValuesAttachments=Pp,a.setAssetProcedureFieldValuesMany=Rp,a.setAssetProcedureFields=mp,a.setAssetProcedureFieldsAttachment=np,a.setAssetProcedureFieldsAttachments=rp,a.setAssetProcedureFieldsMany=pp,a.setAssetProcedureInstance=Ep,a.setAssetProcedureInstances=jp,a.setAssetProcedureStep=or,a.setAssetProcedureStepFieldValues=oA,a.setAssetProcedureStepFieldValuesAttachment=cA,a.setAssetProcedureStepFieldValuesAttachments=nA,a.setAssetProcedureStepFieldValuesMany=lA,a.setAssetProcedureStepFields=Zp,a.setAssetProcedureStepFieldsAttachment=Lp,a.setAssetProcedureStepFieldsAttachments=Np,a.setAssetProcedureStepFieldsMany=Xp,a.setAssetProcedureSteps=AA,a.setAssetProcedures=kp,a.setAssetStage=vr,a.setAssetStageCompletion=IA,a.setAssetStageCompletions=_A,a.setAssetStages=RA,a.setAssetType=ny,a.setAssetTypeAttachment=Vr,a.setAssetTypeAttachments=qA,a.setAssetTypeFieldValues=sy,a.setAssetTypeFieldValuesAttachment=XA,a.setAssetTypeFieldValuesAttachments=QA,a.setAssetTypeFieldValuesMany=ay,a.setAssetTypeFields=LA,a.setAssetTypeFieldsAttachment=DA,a.setAssetTypeFieldsAttachments=CA,a.setAssetTypeFieldsMany=NA,a.setAssetTypes=ry,a.setAssets=PA,a.setCategories=gy,a.setCategory=Sy,a.setConversation=vc,a.setConversations=Wm,a.setCurrentUser=jS,a.setDocumentAttachment=qd,a.setDocumentAttachments=_y,a.setDocuments=Gd,a.setEmailDomain=jy,a.setEmailDomains=qy,a.setForm=Qy,a.setFormRevision=yu,a.setFormRevisionAttachment=By,a.setFormRevisionAttachments=$y,a.setFormRevisions=Wy,a.setFormSubmission=Mt,a.setFormSubmissionAttachment=nf,a.setFormSubmissionAttachments=rf,a.setFormSubmissions=of,a.setForms=xy,a.setGeoImage=it,a.setGeoImages=Gu,a.setIsImportingProjectFile=Th,a.setIssue=Ef,a.setIssueAssociation=Af,a.setIssueAssociations=pf,a.setIssueAttachment=co,a.setIssueAttachments=gf,a.setIssueComment=ni,a.setIssueCommentAttachment=yo,a.setIssueCommentAttachments=Pf,a.setIssueComments=_o,a.setIssueType=rt,a.setIssueTypeAttachment=zo,a.setIssueTypeAttachments=Cf,a.setIssueTypeFieldValues=Yf,a.setIssueTypeFieldValuesAttachment=uS,a.setIssueTypeFieldValuesAttachments=oS,a.setIssueTypeFieldValuesMany=Jf,a.setIssueTypeFields=eS,a.setIssueTypeFieldsAttachment=$f,a.setIssueTypeFieldsAttachments=Gf,a.setIssueTypeFieldsMany=tS,a.setIssueTypes=AS,a.setIssueUpdate=PS,a.setIssueUpdates=TS,a.setIssues=jf,a.setLoggedIn=Pd,a.setOrganization=LS,a.setOrganizationAccess=DS,a.setOrganizationAccesses=CS,a.setOrganizations=Hl,a.setProfilePicture=qS,a.setProject=fg,a.setProjectAccess=tg,a.setProjectAccesses=sg,a.setProjectAttachment=uh,a.setProjectAttachments=oh,a.setProjectFile=dg,a.setProjectFiles=ug,a.setProjects=yg,a.setRehydrated=Ig,a.setTeam=ut,a.setTeamMembership=Xi,a.setTeamMemberships=Rg,a.setTeams=Vg,a.setTokens=my,a.setUploadUrl=au,a.setUser=RS,a.setUsers=OS,a.shallowEqual=Om,a.slugify=$m,a.spacesToDashesLower=Bm,a.teamMembershipReducer=Bh,a.teamMembershipSlice=Zi,a.teamReducer=Yh,a.teamSlice=ec,a.toFileNameSafeString=km,a.toOfflineIdRecord=Tc,a.truncate=Gm,a.updateAsset=tt,a.updateAssetAttachment=ep,a.updateAssetAttachments=qc,a.updateAssetProcedure=Qe,a.updateAssetProcedureAttachment=ap,a.updateAssetProcedureAttachments=Nc,a.updateAssetProcedureFieldValues=Ze,a.updateAssetProcedureFieldValuesAttachment=Tp,a.updateAssetProcedureFieldValuesAttachments=An,a.updateAssetProcedureFieldValuesMany=Tn,a.updateAssetProcedureFields=un,a.updateAssetProcedureFieldsAttachment=dp,a.updateAssetProcedureFieldsAttachments=en,a.updateAssetProcedureFieldsMany=Ap,a.updateAssetProcedureInstance=Xe,a.updateAssetProcedureInstances=Mp,a.updateAssetProcedureStep=Ds,a.updateAssetProcedureStepFieldValues=et,a.updateAssetProcedureStepFieldValuesAttachment=rA,a.updateAssetProcedureStepFieldValuesAttachments=Zn,a.updateAssetProcedureStepFieldValuesMany=ir,a.updateAssetProcedureStepFields=xe,a.updateAssetProcedureStepFieldsAttachment=Hp,a.updateAssetProcedureStepFieldsAttachments=Bn,a.updateAssetProcedureStepFieldsMany=Qp,a.updateAssetProcedureSteps=St,a.updateAssetProcedures=Dp,a.updateAssetStage=ea,a.updateAssetStageCompletion=Fr,a.updateAssetStageCompletions=Pr,a.updateAssetStages=Ft,a.updateAssetType=at,a.updateAssetTypeAttachment=VA,a.updateAssetTypeAttachments=zr,a.updateAssetTypeFieldValues=st,a.updateAssetTypeFieldValuesAttachment=xA,a.updateAssetTypeFieldValuesAttachments=cd,a.updateAssetTypeFieldValuesMany=md,a.updateAssetTypeFields=xr,a.updateAssetTypeFieldsAttachment=UA,a.updateAssetTypeFieldsAttachments=Hr,a.updateAssetTypeFieldsMany=HA,a.updateAssetTypes=uy,a.updateAssets=bA,a.updateCategories=by,a.updateCategory=Od,a.updateConversation=wc,a.updateConversations=Km,a.updateDocumentAttachment=Oy,a.updateDocumentAttachments=Vd,a.updateDocuments=Ce,a.updateEmailDomain=Vy,a.updateEmailDomains=zy,a.updateForm=ef,a.updateFormRevision=Ky,a.updateFormRevisionAttachment=Gy,a.updateFormRevisionAttachments=uu,a.updateFormRevisions=Yy,a.updateFormSubmission=zu,a.updateFormSubmissionAttachment=df,a.updateFormSubmissionAttachments=wu,a.updateFormSubmissions=lf,a.updateForms=tf,a.updateGeoImage=Hu,a.updateGeoImages=hf,a.updateIssue=qt,a.updateIssueAssociation=Qu,a.updateIssueAssociations=yf,a.updateIssueAttachment=bf,a.updateIssueAttachments=no,a.updateIssueComment=Rf,a.updateIssueCommentAttachment=Tf,a.updateIssueCommentAttachments=fo,a.updateIssueComments=vf,a.updateIssueType=Sl,a.updateIssueTypeAttachment=Uf,a.updateIssueTypeAttachments=Do,a.updateIssueTypeFieldValues=nt,a.updateIssueTypeFieldValuesAttachment=lS,a.updateIssueTypeFieldValuesAttachments=ol,a.updateIssueTypeFieldValuesMany=Zf,a.updateIssueTypeFields=il,a.updateIssueTypeFieldsAttachment=Lf,a.updateIssueTypeFieldsAttachments=Wo,a.updateIssueTypeFieldsMany=sS,a.updateIssueTypes=yS,a.updateIssueUpdate=IS,a.updateIssueUpdates=_S,a.updateIssues=qf,a.updateOrganization=KS,a.updateOrganizationAccess=Ut,a.updateOrganizationAccesses=US,a.updateOrganizations=WS,a.updateProject=jh,a.updateProjectAccess=dt,a.updateProjectAccesses=ag,a.updateProjectAttachment=rg,a.updateProjectAttachments=lh,a.updateProjectFile=Hi,a.updateProjectFiles=lg,a.updateProjects=gg,a.updateTeam=Wh,a.updateTeamMembership=vg,a.updateTeamMemberships=wg,a.updateTeams=zg,a.updateUser=MS,a.updateUsers=wS,a.userReducer=zl,a.userSlice=Mi,a.versioningReducer=Zh,a.versioningSlice=Jh,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
14
|
+
external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(y)}const p=u.type.split("/")[1];if(!p)throw new Error("File has no extension");const A=c??l+"."+p;if(u=fc(u,A),!u.name)throw new Error("Failed to set file's name");await this.addCache(u,l),Bt[n]=new Promise(y=>{y(u)})}return u}}class Bb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{revisionUuid:l,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,form_revision:l,submitted_at:s,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,form_revision:l};r.push(P)}this.dispatch(iu(n));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(c)},blockers:n.map(u=>u.form_revision),blocks:n.map(u=>u.uuid)});return o.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(cu(u.attachments))}).catch(()=>{this.dispatch(nu(n.map(u=>u.uuid)))}),[n,o.then(({attachments:u})=>u)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:h.GET,url:"/form-revision-attachments/",queryParams:{form_revision__form__organization:e},blockers:[e],blocks:[]});return this.dispatch(au(s)),s}}class $b extends j{add(e){var o;const{store:s}=this.client,c=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=T({...e,created_by:c,submitted_at:new Date().toISOString()});this.dispatch(wa(n));const r=this.enqueueRequest({description:"Create form revision",method:h.POST,url:"/form-revisions/",payload:v(n),blockers:[e.form],blocks:[n.uuid]});return r.then(m=>{this.dispatch(hu(m))}).catch(()=>{this.dispatch(Ma(n.uuid))}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:h.GET,url:"/form-revisions/",queryParams:{form__organization:e},blockers:[e],blocks:[]});return this.dispatch(ou(s)),s}}class Gb extends j{add(e,s){var u;const{store:i}=this.client,c=new Date().toISOString(),n=(u=i.getState().userReducer.currentUser)==null?void 0:u.id,r=T({...e,submitted_at:c,created_by:n}),o=T({...s,form:r.uuid,submitted_at:c,created_by:n});this.dispatch(ja(r)),this.dispatch(wa(o));const m=this.enqueueRequest({description:"Create form",method:h.POST,url:"/forms/",payload:{...v(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(l=>{throw this.dispatch(qa(r.uuid)),this.dispatch(Ma(o.uuid)),l}),[r,o,m]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Fu(e)(i);if(!c)throw new Error("Expected form to exist");const n=ju(e)(i);n.length>0&&this.dispatch(jt(n.map(({uuid:o})=>o)));const r=Au(e)(i);r.length>0&&this.dispatch(mu(r.map(({uuid:o})=>o))),this.dispatch(qa(e));try{return await this.enqueueRequest({description:"Delete form",method:h.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(ja(c)),r.length>0&&this.dispatch(lu(r)),n.length>0&&this.dispatch(Et(n)),o}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:h.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]});return this.dispatch(Su(s)),s}}class Lb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{submissionUuid:l,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,form_submission:l,submitted_at:s,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,form_submission:l};r.push(P)}this.dispatch(vt(n));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(c)},blockers:n.map(u=>u.form_submission),blocks:n.map(u=>u.uuid)});return o.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(_u(u.attachments))}).catch(u=>{throw this.dispatch(wt(n.map(l=>l.uuid))),u}),[n,o.then(({attachments:u})=>u)]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=Ou(e)(i);this.dispatch(wt(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:h.DELETE,url:"/form-submission-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(vt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:h.GET,url:"/form-submission-attachments/",queryParams:{form_submission__project:e},blockers:[],blocks:[]});return this.dispatch(Iu(s)),s}}class Nb extends j{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add form submission",method:h.POST,url:"/form-submissions/",payload:v(c),blockers:[e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.uuid]});return this.dispatch(Da(c)),n.then(o=>(this.dispatch(Mt(o)),o)).catch(()=>{this.dispatch(Ca(c.uuid))}),[c,n]}update(e){const{store:s}=this.client,i=s.getState(),c=$a(e.uuid)(i);if(!c)throw new Error(`Expected submission with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(Eu(n));const r=this.enqueueRequest({description:"Delete user form submissions",method:h.PATCH,url:`/form-submissions/${n.uuid}/`,payload:e,blockers:[n.uuid],blocks:[n.uuid]});return r.then(o=>{this.dispatch(Mt(o))}).catch(()=>{this.dispatch(Mt(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=$a(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=Ru(e)(i);this.dispatch(Ca(e)),this.dispatch(wt(n.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(Da(c)),this.dispatch(vt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:h.GET,url:"/form-submissions/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(Mu(s)),s}}class Hb extends j{async add(e){var p;const{store:s}=this.client,{file:i,...c}=e,n=new Date().toISOString(),r=(p=s.getState().userReducer.currentUser)==null?void 0:p.id,o=c.project,m=await this.getFilePayload(i),u=T({...c,file_name:i.name,file_sha1:m.sha1,file:URL.createObjectURL(i),submitted_at:n,created_by:r});this.dispatch(ku(u));const l=this.enqueueRequest({description:"Add geo image",method:h.POST,url:"/geo-images/",payload:{uuid:u.uuid,submitted_at:n,title:u.title,description:u.description,geo_marker:u.geo_marker,canvas_marker:u.canvas_marker,sha1:u.file_sha1,project:u.project,file_name:u.file_name,direction:u.direction,original_date:u.original_date,file:m},blocks:[o],blockers:[o]});return l.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(it(A.geo_image))}).catch(()=>{this.dispatch(La(u.uuid))}),[u,l.then(A=>A.geo_image)]}async bulkAdd(e,s){var p;const{store:i}=this.client,c=new Date().toISOString(),n=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,r=[],o=[],m=[],u={};for(const A of e){const{file:y,...b}=A,P=await this.getFilePayload(y);P.sha1 in u||(u[P.sha1]=P);const _=T({...b,file_name:y.name,file_sha1:P.sha1,file:URL.createObjectURL(y),submitted_at:c,created_by:n,project:s});r.push(_),o.push(_.uuid),m.push({uuid:_.uuid,sha1:_.file_sha1,file_name:_.file_name,title:_.title,description:_.description,geo_marker:_.geo_marker,canvas_marker:_.canvas_marker,direction:_.direction,original_date:_.original_date})}this.dispatch(Bu(r));const l=this.enqueueRequest({description:"Bulk add geo images",method:h.POST,url:"/geo-images/bulk/",payload:{submitted_at:c,project:s,geo_images:m,files:Object.values(u)},blocks:[s],blockers:o});return l.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(Cu(A.geo_images))}).catch(()=>{this.dispatch(Gu(o))}),[r,l.then(A=>A.geo_images)]}update(e){const{store:s}=this.client,i=s.getState(),c=Na(e.uuid)(i);if(!c)throw new Error(`Map image with uuid ${e.uuid} does not exist in the store`);const n={...c,...e};this.dispatch($u(n));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(it(o))}).catch(()=>{this.dispatch(it(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Na(e)(i);if(!c)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(La(e));const n=this.enqueueRequest({description:"Delete geo image",method:h.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return n.catch(()=>{this.dispatch(it(c))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:h.GET,url:"/geo-images/",queryParams:{project:e},blocks:[e],blockers:[]});return this.dispatch(Du(s)),s}}class Wb extends R{add(e){var o;const{store:s}=this.client,i=new Date().toISOString(),c=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,n=T({...e,submitted_at:i,created_by:c});this.dispatch(Wa(n));const r=this.enqueueRequest({description:"Add issue association",method:h.POST,url:"/issue-associations/",payload:v(n),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Yu(m))}).catch(()=>{this.dispatch(Ya(n.uuid))}),[n,r]}async delete(e){const{store:s}=this.client,i=Ju(e)(s.getState());if(!i)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(Ya(e));const c=this.enqueueRequest({description:"Delete issue association",method:h.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(Wa(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:h.GET,url:"/issue-associations/",queryParams:{associated_issue__project:e},blockers:[],blocks:[]});return this.dispatch(Ku(s)),s}}class Kb extends Ce{constructor(){super(...arguments);S(this,"name","Issue Attachment");S(this,"url","/issue-attachments");S(this,"initializeAttachments",Xa);S(this,"addAttachments",Qa);S(this,"updateAttachments",so);S(this,"removeAttachments",xa);S(this,"removeAttachment",ao);S(this,"setAttachment",to);S(this,"selectAttachment",ro)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.issueUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get issue attachments",method:h.GET,url:`${this.url}/`,queryParams:{issue__project:s},blocks:[],blockers:[]});return this.dispatch(Xa(i)),i}}class Yb extends Ce{constructor(){super(...arguments);S(this,"name","Issue Comment Attachment");S(this,"url","/issue-comment-attachments");S(this,"initializeAttachments",ti);S(this,"addAttachments",lo);S(this,"updateAttachments",mo);S(this,"removeAttachments",Ao);S(this,"removeAttachment",po);S(this,"setAttachment",ho);S(this,"selectAttachment",So)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.issueCommentUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get issue comment attachments",method:h.GET,url:`${this.url}/`,queryParams:{issue_comment__issue__project:s},blocks:[],blockers:[]});return this.dispatch(ti(i)),i}}class Jb extends R{add(e){var n;const{store:s}=this.client,i=T({...e,author:(n=s.getState().userReducer.currentUser)==null?void 0:n.id,submitted_at:new Date().toISOString()});this.dispatch(ai(i));const c=this.enqueueRequest({description:"Add issue comment",method:h.POST,url:"/issue-comments/",payload:v(i),blockers:[e.issue],blocks:[i.uuid]});return c.catch(()=>{this.dispatch(ci(i.uuid))}),[i,c]}update(e){const{store:s}=this.client,i=ni(e.uuid)(s.getState());if(!i)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const c={...i,...e};this.dispatch(ii(c));const n=this.enqueueRequest({description:"Edit issue comment",method:h.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.catch(()=>{this.dispatch(ii(i))}),[c,n]}remove(e){const{store:s}=this.client,i=ni(e)(s.getState());if(!i)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(ci(e));const c=this.enqueueRequest({description:"Delete comment",method:h.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(ai(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:h.GET,url:"/issue-comments/",queryParams:{issue__project:e},blockers:[],blocks:[]});return this.dispatch(Po(s)),s}}class Zb extends R{add(e){var m;const{store:s}=this.client,i=s.getState(),c=new Date().toISOString(),n=(m=i.userReducer.currentUser)==null?void 0:m.id,r=T({...e,submitted_at:c,created_by:n});this.dispatch(di(r));const o=this.enqueueRequest({description:"Create issue",method:h.POST,url:"/issues/",payload:v(r),blockers:[r.project,r.issue_type,...r.category?[r.category]:[]],blocks:[r.uuid]});return o.then(u=>{this.dispatch(qt(u))}).catch(u=>{throw this.dispatch(ui(r.uuid)),u}),[r,o]}update(e){var m;const s=this.client.store.getState(),i=li(e.uuid)(s);if(!i)throw new Error(`Attempting to update an issue with uuid ${e.uuid} that doesn't exist in the store`);const c={...i,...e};this.dispatch(qt(c));const n={};for(const u of[E.TITLE,E.DESCRIPTION,E.STATUS,E.CATEGORY,E.PRIORITY,E.ASSIGNED_TO,E.DUE_DATE])if(u in e&&e[u]!==i[u])switch(u){case E.PRIORITY:case E.STATUS:{const l=e[u];n[u]=l!==void 0?Number(l):null;break}case E.DUE_DATE:case E.DESCRIPTION:case E.TITLE:n[u]=e[u]??null;break;case E.CATEGORY:{let l=null;const p=e[u];if(p&&(l=s.categoryReducer.instances[p]??null,!l))throw new Error(`Trying to update issue category to ${p} which does not exist in store`);n[u]=l?{name:l.name,color:l.color,uuid:l.uuid}:null;break}case E.ASSIGNED_TO:{let l=null;const p=e[u];if(p&&(l=s.userReducer.instances[p]??null,!l))throw new Error(`Trying to update issue assigned_to to ${p} which does not exist in store`);n[u]=l?{full_name:l.username,id:l.id}:null;break}}const r=T({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:i.uuid,changes:n});this.dispatch(bl(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(qt(i)),this.dispatch(Fl(r.uuid))}),[c,o]}async remove(e){const{store:s}=this.client,i=s.getState(),c=li(e)(i);if(!c)throw new Error(`No issue with uuid ${e} found in the store`);const n=no(e)(i),r=_l(e)(i),o=qu(e)(i),m={};for(const l of Zu(e)(i))m[l.uuid]=l;for(const l of Xu(e)(i))m[l.uuid]=l;const u=Object.values(m);this.dispatch(ui(e)),n.length>0&&this.dispatch(xa(n.map(({uuid:l})=>l))),r.length>0&&this.dispatch(Tl(r.map(({uuid:l})=>l))),o.length>0&&this.dispatch(jt(o.map(({uuid:l})=>l))),u.length>0&&this.dispatch(Ja(u.map(({uuid:l})=>l)));try{return await this.enqueueRequest({description:"Delete issue",method:h.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(l){throw this.dispatch(di(c)),this.dispatch(Qa(n)),this.dispatch(Pl(r)),this.dispatch(Et(o)),this.dispatch(Ka(u)),l}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:h.GET,url:"/issues/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(_o(s)),s}}class Xb extends Ce{constructor(){super(...arguments);S(this,"name","Issue Type Attachment");S(this,"url","/issue-type-attachments");S(this,"initializeAttachments",mi);S(this,"addAttachments",Mo);S(this,"updateAttachments",jo);S(this,"removeAttachments",Vo);S(this,"removeAttachment",qo);S(this,"setAttachment",Eo);S(this,"selectAttachment",Do)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.issueTypeUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get issue type attachments",method:h.GET,url:`${this.url}/`,queryParams:{issue_type__organization:s},blocks:[],blockers:[]});return this.dispatch(mi(i)),i}}class Qb extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_extension:y.extension,field_identifier:p,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch($o(n));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(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return o.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Go(u.attachments))}).catch(()=>{this.dispatch(Lo(n.map(u=>u.uuid)))}),[n,o.then(({attachments:u})=>u)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:h.GET,url:"/issue-type-fields-attachments/",queryParams:{fields_revision__issue_type__organization:e},blockers:[e],blocks:[]});return this.dispatch(Bo(s)),s}}class xb extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(xo(n));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:h.POST,url:"/issue-type-fields/",payload:v(n),blockers:[n.issue_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(el(m))}).catch(m=>{throw this.dispatch(tl(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:h.GET,url:"/issue-type-fields/",queryParams:{issue_type__organization:e},blockers:[],blocks:[]});return this.dispatch(Qo(s)),s}}class eP extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldValuesUuid:l,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,field_values:l,submitted_at:s,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,field_values:l};r.push(P)}this.dispatch(zt(n));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(c)},blockers:n.map(u=>u.field_values),blocks:n.map(u=>u.uuid)});return o.then(({presigned_urls:u,attachments:l})=>{this.processPresignedUrls(u),this.dispatch(nl(l))}).catch(u=>{throw this.dispatch(Ut(n.map(l=>l.uuid))),u}),[n,o.then(({attachments:u})=>u)]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=dl(e)(i);this.dispatch(Ut(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:h.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(zt(c)),n}}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:{field_values__issue__project:e},blockers:[],blocks:[]});return this.dispatch(cl(s)),s}}class tP extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add issue type field values",method:h.POST,url:"/issue-type-field-values/",payload:v(c),blockers:[e.issue,e.fields_revision],blocks:[c.uuid]});return this.dispatch(yi(c)),n.then(o=>(this.dispatch(nt(o)),o)).catch(()=>{this.dispatch(fi(c.uuid))}),[c,n]}update(e){const{store:s}=this.client,i=s.getState(),c=gi(e.uuid)(i);if(!c)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(nt(n));const r=this.enqueueRequest({description:"Update issue type field values",method:h.PATCH,url:`/issue-type-field-values/${e.uuid}/`,payload:e,blockers:[n.uuid,n.fields_revision,n.issue],blocks:[n.uuid]});return r.then(o=>{this.dispatch(nt(o))}).catch(()=>{this.dispatch(nt(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=gi(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=ul(e)(i);this.dispatch(fi(e)),this.dispatch(Ut(n.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(yi(c)),this.dispatch(zt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:h.GET,url:"/issue-type-field-values/",queryParams:{issue__project:e},blockers:[],blocks:[]});return this.dispatch(Yo(s)),s}}class sP extends R{add(e){var r;const{store:s}=this.client,i=s.getState(),c=T({...e,submitted_at:new Date().toISOString(),created_by:(r=i.userReducer.currentUser)==null?void 0:r.id});this.dispatch(ml(c));const n=this.enqueueRequest({method:h.POST,url:"/issue-types/",payload:v(c),blockers:[],blocks:[c.uuid]});return n.then(o=>{this.dispatch(rt(o))}).catch(()=>{this.dispatch(Ii(c.uuid))}),[c,n]}update(e){const{store:s}=this.client,i=s.getState(),c=_i(e.uuid)(i);if(!c)throw new Error(`IssueType with uuid ${e.uuid} does not exist in the store.`);const n={...c,...e};this.dispatch(pl(n));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(rt(o))}).catch(()=>{this.dispatch(rt(c))}),[n,r]}delete(e){const{store:s}=this.client,i=s.getState(),c=_i(e)(i);if(!c)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const n=Oi(e)(i);this.dispatch(Ii(e)),this.dispatch(Ro(n.map(o=>o.uuid)));const r=this.enqueueRequest({method:h.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(rt(c)),this.dispatch(Oo(n))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:h.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(hl(s)),s}}class aP extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:h.GET,url:"/issue-updates/",queryParams:{issue__project:e},blockers:[],blocks:[]});return this.dispatch(gl(s)),s}}const iP=1800;function cP(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 nP extends ub{constructor(){super(...arguments);S(this,"_getRenewedTokens",async s=>{const i=this.enqueueRequest({description:"Get renewed tokens",method:h.POST,url:this.refreshTokensUrl,payload:{refresh:s},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let c;try{c=await i}catch(n){console.error("Could not renew tokens; clearing auth",n),this.clearAuth();return}if(!c.access)throw new Error("Missing access token");return{accessToken:c.access,refreshToken:c.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Sd(!1)),this.clearTokens(),this.dispatch(F),this.dispatch(F)}async renewTokens(){const s=this.getRefreshToken();if(!s)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const i=await this._getRenewedTokens(s);if(!i)return;console.log("Got renewed tokens"),this.setTokens(i)}catch(i){throw console.error("Could not renew tokens; clearing auth",i),this.clearAuth(),i}}tokenIsExpiringSoon(){const s=this.getAccessToken();if(!s)return!1;const i=Date.now()/1e3;let c;try{c=pm(s).exp??i}catch{c=i}return c-i<iP}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 U&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??We).toString()))}}}async handleUnauthorized(s,i){const c=this.client.store.getState();if(s.url.endsWith("/token/refresh/"))throw c.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new U({message:"You have been signed out due to inactivity.",response:i,discard:!0});if(c.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new U({message:"Incorrect username or password.",response:i,discard:!0})}async initAuth(s){const i=Le.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:i,description:"Get token pair",method:h.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(c=>{this.setTokens(cP(c))})}}class rP extends R{update(e){const{store:s}=this.client,i=ji(e.uuid)(s.getState()),c={...i,...e};this.dispatch(Ct(c));const n=this.enqueueRequest({description:"Edit organization access",method:h.PATCH,url:`/organization-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(Ct(r))}).catch(r=>{throw this.dispatch(Ct(i)),r}),[c,n]}async remove(e){const{store:s}=this.client,i=s.getState(),c=ji(e)(i),n=ql(c.user)(i);this.dispatch(Dl(c.uuid)),this.dispatch(Ml(c.user));try{await this.enqueueRequest({description:"Remove organization access",method:h.DELETE,url:`/organization-accesses/${c.uuid}/`,blockers:[c.uuid],blocks:[]})}catch(r){throw this.dispatch(Ul(c)),this.dispatch(wl(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:h.GET,url:"/organization-accesses/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(zl(s)),s}}class dP extends R{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(){const e=await this.enqueueRequest({description:"Fetch organizations",method:h.GET,url:"/organizations/",blockers:[],blocks:[]});return this.dispatch($l(e)),e}}class uP extends R{add(e){const s=T(e);this.dispatch(Ui(s));const i=this.enqueueRequest({description:"Add project access",method:h.POST,url:"/project-accesses/",payload:v(s),blockers:[s.organization_access,s.project],blocks:[s.uuid]});return i.then(c=>{this.dispatch(dt(c))}).catch(c=>{throw this.dispatch(Di(s.uuid)),c}),[s,i]}update(e){const{store:s}=this.client,i=ki(e.uuid)(s.getState()),c={...i,...e};this.dispatch(dt(c));const n=this.enqueueRequest({description:"Edit project access",method:h.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[]});return n.then(r=>{this.dispatch(dt(r))}).catch(r=>{throw this.dispatch(dt(i)),r}),[c,n]}async remove(e){const{store:s}=this.client,i=ki(e)(s.getState());this.dispatch(Di(e));try{await this.enqueueRequest({description:"Delete project access",method:h.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}catch(c){throw this.dispatch(Ui(i)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:h.GET,url:"/project-accesses/",queryParams:{project__organization_owner:e},blockers:[],blocks:[]});return this.dispatch(Xl(s)),s}}class oP extends Ce{constructor(){super(...arguments);S(this,"name","Project Attachment");S(this,"url","/project-attachments");S(this,"addAttachments",ih);S(this,"updateAttachments",rh);S(this,"removeAttachments",$i);S(this,"removeAttachment",dh);S(this,"setAttachment",ch);S(this,"selectAttachment",lh)}buildOfflineAttachment(s){return T({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(i=>({modelUuid:i.projectUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get project attachments",method:h.GET,url:`${this.url}/`,queryParams:{project__organization_owner:s},blockers:[],blocks:[]});return this.dispatch(ah(i)),i}}class lP extends R{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 i=this.enqueueRequest({method:h.PATCH,url:`/project-files/${e.uuid}/`,payload:s,blockers:[e.uuid],blocks:[e.uuid]});return i.then(c=>{this.dispatch(Li(c))}),i}saveActive(){const{store:e}=this.client,s=e.getState(),i=s.projectFileReducer.activeProjectFileId;if(!i)throw new Error("No active project file");const c=s.projectFileReducer.instances[i];if(!c)throw new Error("No active project file");if(!c.bounds&&!c.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let n;if(typeof c.file=="string"&&!c.file.startsWith("blob:")){const m={...c};delete m.file,n={method:h.PATCH,url:`/project-files/${i}/`,payload:m,blockers:[i],blocks:[i]}}else n=new Promise((m,u)=>{this.client.files.uploadFileToS3(c.file_sha1).then(([l])=>{m({method:h.POST,url:`/project-files${c.project}/`,payload:{...c,...l},blockers:[i],blocks:[i]})}).catch(u)});const o=Promise.resolve(n).then(m=>this.enqueueRequest(m));return o.then(m=>{this.dispatch(Li(m))}),this.dispatch(Ph),this.dispatch(bh(null)),this.dispatch(gh(!1)),[c,o]}delete(e){return this.dispatch(fh(e)),this.enqueueRequest({method:h.DELETE,url:`/project-files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:h.GET,url:"/project-files/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(Ah(s)),s}}class hP extends R{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(vh(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,i=s.getState(),c=Eh(e)(i);if(!c)throw new Error("Expected project to exist");const n=Th(i).filter(m=>m.project===e);this.dispatch(Sh(n.map(({uuid:m})=>m)));const r=hh(c.uuid)(i);this.dispatch($i(r.map(({uuid:m})=>m)));const o=th(e)(i);this.dispatch(xl(o.map(({uuid:m})=>m))),this.dispatch(Hi(c.uuid));try{await this.enqueueRequest({description:"Delete project",method:h.DELETE,url:`/projects/${e}/`,blockers:[e],blocks:[]}),this.dispatch(Hi(c.uuid))}catch(m){throw this.dispatch(Rh(c)),this.dispatch(Ql(Object.values(o))),this.dispatch(yh(n)),this.dispatch(nh(r)),m}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch projects",method:h.GET,url:"/projects/",queryParams:{organization_owner:e},blockers:[],blocks:[]});return this.dispatch(Oh(s)),s}}class mP extends R{add(e){const s=T(e);this.dispatch(zh(s));const i=this.enqueueRequest({description:"Create team membership",method:h.POST,url:"/team-memberships/",payload:v(s),blockers:[e.team],blocks:[s.uuid]});return i.then(c=>{this.dispatch(Ji(c))}).catch(()=>{this.dispatch(Zi(s.uuid))}),[s,i]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Ch(e)(i);if(!c)throw new Error(`Expected team membership with uuid ${e} to exist`);this.dispatch(Zi(e));try{return await this.enqueueRequest({description:"Delete team membership",method:h.DELETE,url:`/team-memberships/${e}/`,blockers:[e],blocks:[e]})}catch(n){throw this.dispatch(Ji(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch team memberships",method:h.GET,url:"/team-memberships/",queryParams:{team__organization:e},blockers:[],blocks:[]});return this.dispatch(Vh(s)),s}}class pP extends R{add(e){const s=T({...e,submitted_at:new Date().toISOString()});this.dispatch($h(s));const i=this.enqueueRequest({description:"Create team",method:h.POST,url:"/teams/",payload:v(s),blockers:[],blocks:[s.uuid]});return i.then(c=>{this.dispatch(ut(c))}).catch(()=>{this.dispatch(xi(s.uuid))}),[s,i]}update(e){const{store:s}=this.client,i=tc(e.uuid)(s.getState());if(!i)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Gh(c));const n=this.enqueueRequest({description:"Update team",method:h.PATCH,url:`/teams/${e.uuid}/`,payload:v(e),blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(ut(r))}).catch(()=>{this.dispatch(ut(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=tc(e)(i);if(!c)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(xi(e));try{return await this.enqueueRequest({description:"Delete team",method:h.DELETE,url:`/teams/${e}/`,blockers:[e],blocks:[e]})}catch(n){throw this.dispatch(ut(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:h.GET,url:"/teams/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(Bh(s)),s}}class AP extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization users",method:h.GET,url:`/organizations/${e}/users/`,blockers:[],blocks:[]});return this.dispatch(vl(s)),s}}class yP{constructor(e){S(this,"store");this.store=e}async enqueueRequest(e,s,i){return this._enqueueRequest(e,s,i).then(c=>{if(c instanceof U)throw c;return c})}_enqueueRequest(e,s,i){const c=new Ac,n={...e,BASE_URL:s,serviceName:i};if(e.immediate){const r={...n,uuid:e.uuid??Le.v4()},o={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:i}}}};ic(o,this).then(m=>{c.resolve(m.body)}).catch(m=>{cc(m,o),m instanceof Error?c.reject(m):c.reject(new Error((m??We).toString()))})}else{const r=this.store.dispatch(Wl(n)),o=u=>{if(u)c.resolve(u.body);else{const l=new U({message:"Could not get a response from the server.",response:u,discard:!0});c.reject(l)}},m=u=>{u instanceof U?u.options.discard=!0:(console.error("Received an unexpected error while processing a request:",u,`
|
|
15
|
+
Converting error to APIError and discarding.`),u=new U({message:"An error occurred while processing the request.",innerError:u,discard:!0})),c.reject(u)};r.then(o,m)}return c}}class Ke{constructor(){S(this,"graph");S(this,"requestAttemptCounter");this.graph=new Am.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Ke;for(let i=0;i<e.length;i++){const c=e[i];if(!c){console.error("Outbox item was undefined");continue}s.sneakRequest(c);for(let n=0;n<i;n++){const r=e[n];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==c.payload.uuid&&r.payload.blocks.some(o=>c.payload.blockers.includes(o))&&Ke._addDependency(c.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){Ke._addDependency(e,s,this.graph)}static _addDependency(e,s,i){if(e===s)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!i.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${s})`);if(!i.hasNode(s))throw new Error(`Tried to add dependency to non-existent node: ${s} (from node: ${e})`);i.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 i=this.graph.getNodeData(s);e.payload.blockers.some(c=>i.payload.blocks.includes(c))&&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(c=>e.payload.blocks.includes(c))&&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,i;for(const c of e){const n=this.requestAttemptCounter[c]||0;n<s&&(s=n,i=c)}return i}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(i=>this.graph.getNodeData(i)),s=this._getNextNode();if(s){const i=this.graph.getNodeData(s),c=e.findIndex(n=>n.payload.uuid===i.payload.uuid);c!==-1&&(e.splice(c,1),e.unshift(i))}return e}getReady(){let e=this.graph.overallOrder(!0).map(s=>this.graph.getNodeData(s));return e=e.sort((s,i)=>s.meta.offline.effect.timestamp.localeCompare(i.meta.offline.effect.timestamp)),e=e.sort((s,i)=>{const c=this.requestAttemptCounter[s.payload.uuid]||0,n=this.requestAttemptCounter[i.payload.uuid]||0;return c-n}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const fP=(t,e)=>{const s=new e(t);return Lg(s),Gg(t),s};var rm=(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))(rm||{});a.APIError=U,a.AgentService=ob,a.AssetAttachmentService=lb,a.AssetProcedureAttachmentService=hb,a.AssetProcedureFieldValuesAttachmentService=Ab,a.AssetProcedureFieldValuesService=yb,a.AssetProcedureFieldsAttachmentService=mb,a.AssetProcedureFieldsService=pb,a.AssetProcedureInstanceService=fb,a.AssetProcedureService=Sb,a.AssetProcedureStepFieldValuesAttachmentService=Pb,a.AssetProcedureStepFieldValuesService=Fb,a.AssetProcedureStepFieldsAttachmentService=gb,a.AssetProcedureStepFieldsService=bb,a.AssetProcedureStepService=Tb,a.AssetService=Ib,a.AssetStageCompletionService=_b,a.AssetStageService=Ob,a.AssetTypeAttachmentService=Rb,a.AssetTypeFieldValuesAttachmentService=Mb,a.AssetTypeFieldValuesService=Eb,a.AssetTypeFieldsAttachmentService=vb,a.AssetTypeFieldsService=wb,a.AssetTypeService=jb,a.AttachmentModel=mc,a.BaseApiService=R,a.BaseSDK=yP,a.COMMON_AUTO_FIELDS=bc,a.CategoryService=qb,a.DEFAULT_ISSUE_PRIORITY=fm,a.DEFAULT_ISSUE_STATUS=ym,a.DeferredPromise=Ac,a.DocumentAttachmentService=Vb,a.DocumentService=zb,a.EMPTY_ARRAY=oc,a.EMPTY_OBJECT=lc,a.EmailDomainsService=Ub,a.EmailVerificationService=Db,a.FileService=kb,a.FormRevisionAttachmentService=Bb,a.FormRevisionService=$b,a.FormService=Gb,a.FormSubmissionAttachmentService=Lb,a.FormSubmissionService=Nb,a.GeoImageService=Hb,a.HttpMethod=h,a.IssueAssociationService=Wb,a.IssueAttachmentService=Kb,a.IssueCommentAttachmentService=Yb,a.IssueCommentService=Jb,a.IssuePriority=Gt,a.IssueService=Zb,a.IssueStatus=Lt,a.IssueTypeAttachmentService=Xb,a.IssueTypeFieldValuesAttachmentService=eP,a.IssueTypeFieldValuesService=tP,a.IssueTypeFieldsAttachmentService=Qb,a.IssueTypeFieldsService=xb,a.IssueTypeService=sP,a.IssueUpdateChange=E,a.IssueUpdateService=aP,a.JWTService=nP,a.OUTBOX_RETRY_DELAY=pc,a.OrganizationAccessLevel=hc,a.OrganizationAccessService=rP,a.OrganizationService=dP,a.OutboxCoordinator=Ke,a.ProjectAccessService=uP,a.ProjectAttachmentService=oP,a.ProjectFileService=lP,a.ProjectService=hP,a.RESET_ORGANIZATION_STATE=O,a.RESET_PROJECT_STATE=M,a.RESET_STATE=F,a.TeamMembershipService=mP,a.TeamService=pP,a.UNKNOWN_ERROR_MESSAGE=We,a.UserService=AP,a.VERSION_REDUCER_KEY=Je,a.VerificationCodeType=rm,a._setLatestRetryTime=Yl,a.addAsset=ks,a.addAssetAttachment=Ym,a.addAssetAttachments=Qt,a.addAssetProcedure=Ss,a.addAssetProcedureAttachment=Xm,a.addAssetProcedureAttachments=Bc,a.addAssetProcedureFieldValues=rs,a.addAssetProcedureFieldValuesAttachment=yp,a.addAssetProcedureFieldValuesAttachments=mt,a.addAssetProcedureFieldValuesMany=bn,a.addAssetProcedureFields=nn,a.addAssetProcedureFieldsAttachment=tp,a.addAssetProcedureFieldsAttachments=Xc,a.addAssetProcedureFieldsMany=dp,a.addAssetProcedureInstance=hs,a.addAssetProcedureInstances=Rn,a.addAssetProcedureStep=zs,a.addAssetProcedureStepFieldValues=Es,a.addAssetProcedureStepFieldValuesAttachment=eA,a.addAssetProcedureStepFieldValuesAttachments=At,a.addAssetProcedureStepFieldValuesMany=tr,a.addAssetProcedureStepFields=Is,a.addAssetProcedureStepFieldsAttachment=Cp,a.addAssetProcedureStepFieldsAttachments=Dn,a.addAssetProcedureStepFieldsMany=Hp,a.addAssetProcedureSteps=hA,a.addAssetProcedures=Ep,a.addAssetStage=Qs,a.addAssetStageCompletion=Ws,a.addAssetStageCompletions=Ks,a.addAssetStages=OA,a.addAssetType=pa,a.addAssetTypeAttachment=jA,a.addAssetTypeAttachments=sa,a.addAssetTypeFieldValues=ua,a.addAssetTypeFieldValuesAttachment=ZA,a.addAssetTypeFieldValuesAttachments=It,a.addAssetTypeFieldValuesMany=dd,a.addAssetTypeFields=Yr,a.addAssetTypeFieldsAttachment=zA,a.addAssetTypeFieldsAttachments=Br,a.addAssetTypeFieldsMany=GA,a.addAssetTypes=dy,a.addAssets=bt,a.addCategories=fy,a.addCategory=ga,a.addConversation=_c,a.addConversations=$m,a.addDocumentAttachment=Iy,a.addDocumentAttachments=vd,a.addDocuments=kd,a.addEmailDomain=Wd,a.addEmailDomains=Ey,a.addForm=ja,a.addFormRevision=wa,a.addFormRevisionAttachment=ky,a.addFormRevisionAttachments=iu,a.addFormRevisions=lu,a.addFormSubmission=Da,a.addFormSubmissionAttachment=cf,a.addFormSubmissionAttachments=vt,a.addFormSubmissions=Et,a.addForms=Xy,a.addGeoImage=ku,a.addGeoImages=Bu,a.addIssue=di,a.addIssueAssociation=Wa,a.addIssueAssociations=Ka,a.addIssueAttachment=Sf,a.addIssueAttachments=Qa,a.addIssueComment=ai,a.addIssueCommentAttachment=Pf,a.addIssueCommentAttachments=lo,a.addIssueComments=Of,a.addIssueType=ml,a.addIssueTypeAttachment=Uf,a.addIssueTypeAttachments=Mo,a.addIssueTypeFieldValues=yi,a.addIssueTypeFieldValuesAttachment=dS,a.addIssueTypeFieldValuesAttachments=zt,a.addIssueTypeFieldValuesMany=Kf,a.addIssueTypeFields=xo,a.addIssueTypeFieldsAttachment=Bf,a.addIssueTypeFieldsAttachments=$o,a.addIssueTypeFieldsMany=xf,a.addIssueTypes=pS,a.addIssueUpdate=bl,a.addIssueUpdates=Pl,a.addIssues=Oo,a.addOrganization=HS,a.addOrganizationAccess=Ul,a.addOrganizationAccesses=zS,a.addOrganizations=NS,a.addProject=Rh,a.addProjectAccess=Ui,a.addProjectAccesses=Ql,a.addProjectAttachment=ng,a.addProjectAttachments=ih,a.addProjectFile=og,a.addProjectFiles=yh,a.addProjects=Sg,a.addTeam=$h,a.addTeamMembership=zh,a.addTeamMemberships=Og,a.addTeams=qg,a.addUser=wl,a.addUsers=vS,a.agentsReducer=vc,a.agentsSlice=Yt,a.areArraysEqual=Tm,a.assetAttachmentReducer=Dc,a.assetAttachmentSlice=Zt,a.assetProcedureAttachmentReducer=Yc,a.assetProcedureAttachmentSlice=es,a.assetProcedureFieldValuesAttachmentReducer=fn,a.assetProcedureFieldValuesAttachmentSlice=is,a.assetProcedureFieldValuesReducer=In,a.assetProcedureFieldValuesSlice=ns,a.assetProcedureFieldsAttachmentReducer=sn,a.assetProcedureFieldsAttachmentSlice=ts,a.assetProcedureFieldsReducer=on,a.assetProcedureFieldsSlice=ss,a.assetProcedureInstanceReducer=Mn,a.assetProcedureInstanceSlice=ls,a.assetProcedureReducer=Vn,a.assetProcedureSlice=fs,a.assetProcedureStepFieldValuesAttachmentReducer=Qn,a.assetProcedureStepFieldValuesAttachmentSlice=vs,a.assetProcedureStepFieldValuesReducer=cr,a.assetProcedureStepFieldValuesSlice=Ms,a.assetProcedureStepFieldsAttachmentReducer=Gn,a.assetProcedureStepFieldsAttachmentSlice=Fs,a.assetProcedureStepFieldsReducer=Hn,a.assetProcedureStepFieldsSlice=Ts,a.assetProcedureStepReducer=ur,a.assetProcedureStepSlice=Vs,a.assetReducer=Ar,a.assetSlice=Cs,a.assetStageCompletionReducer=br,a.assetStageCompletionSlice=Hs,a.assetStageReducer=Or,a.assetStageSlice=Xs,a.assetTypeAttachmentReducer=Dr,a.assetTypeAttachmentSlice=ta,a.assetTypeFieldValuesAttachmentReducer=cd,a.assetTypeFieldValuesAttachmentSlice=na,a.assetTypeFieldValuesReducer=hd,a.assetTypeFieldValuesSlice=da,a.assetTypeFieldsAttachmentReducer=Hr,a.assetTypeFieldsAttachmentSlice=ia,a.assetTypeFieldsReducer=Qr,a.assetTypeFieldsSlice=ca,a.assetTypeReducer=yd,a.assetTypeSlice=ma,a.authReducer=gd,a.authSlice=Ot,a.baseReducer=Bg,a.baseReducers=sc,a.blobToBase64=jm,a.categoryReducer=_d,a.categorySlice=Sa,a.clearTokens=py,a.constructUploadedFilePayloads=Em,a.coordinatesAreEqual=Pm,a.createModelAdapter=I,a.createMultiPointGeometry=bm,a.createOfflineAction=Nl,a.createPayload=v,a.createPointGeometry=gm,a.createSelectionAdapter=Sm,a.deleteAsset=Bs,a.deleteAssetAttachment=jc,a.deleteAssetAttachments=xt,a.deleteAssetProcedure=gs,a.deleteAssetProcedureAttachment=Lc,a.deleteAssetProcedureAttachments=Nc,a.deleteAssetProcedureFieldValues=ds,a.deleteAssetProcedureFieldValuesAttachment=bp,a.deleteAssetProcedureFieldValuesAttachments=pt,a.deleteAssetProcedureFieldValuesMany=Fn,a.deleteAssetProcedureFields=dn,a.deleteAssetProcedureFieldsAttachment=cp,a.deleteAssetProcedureFieldsAttachments=xc,a.deleteAssetProcedureFieldsMany=hp,a.deleteAssetProcedureInstance=ms,a.deleteAssetProcedureInstances=vn,a.deleteAssetProcedureStep=Us,a.deleteAssetProcedureStepFieldValues=js,a.deleteAssetProcedureStepFieldValuesAttachment=iA,a.deleteAssetProcedureStepFieldValuesAttachments=yt,a.deleteAssetProcedureStepFieldValuesMany=ar,a.deleteAssetProcedureStepFields=_s,a.deleteAssetProcedureStepFieldsAttachment=Gp,a.deleteAssetProcedureStepFieldsAttachments=kn,a.deleteAssetProcedureStepFieldsMany=Jp,a.deleteAssetProcedureSteps=pA,a.deleteAssetProcedures=qp,a.deleteAssetStage=xs,a.deleteAssetStageCompletion=Ys,a.deleteAssetStageCompletions=Js,a.deleteAssetStages=vA,a.deleteAssetType=Aa,a.deleteAssetTypeAttachment=jr,a.deleteAssetTypeAttachments=aa,a.deleteAssetTypeFieldValues=oa,a.deleteAssetTypeFieldValuesAttachment=ey,a.deleteAssetTypeFieldValuesAttachments=_t,a.deleteAssetTypeFieldValuesMany=od,a.deleteAssetTypeFields=Zr,a.deleteAssetTypeFieldsAttachment=kA,a.deleteAssetTypeFieldsAttachments=Gr,a.deleteAssetTypeFieldsMany=WA,a.deleteAssetTypes=oy,a.deleteAssets=$s,a.deleteCategories=Py,a.deleteCategory=Td,a.deleteConversation=Nm,a.deleteConversations=Hm,a.deleteDocumentAttachment=Ed,a.deleteDocumentAttachments=jd,a.deleteEmailDomain=Kd,a.deleteEmailDomains=Uy,a.deleteForm=qa,a.deleteFormRevision=Ma,a.deleteFormRevisionAttachment=Ly,a.deleteFormRevisionAttachments=nu,a.deleteFormRevisions=mu,a.deleteFormSubmission=Ca,a.deleteFormSubmissionAttachment=uf,a.deleteFormSubmissionAttachments=wt,a.deleteFormSubmissions=jt,a.deleteForms=sf,a.deleteGeoImage=La,a.deleteGeoImages=Gu,a.deleteIssue=ui,a.deleteIssueAssociation=Ya,a.deleteIssueAssociations=Ja,a.deleteIssueAttachment=ao,a.deleteIssueAttachments=xa,a.deleteIssueComment=ci,a.deleteIssueCommentAttachment=po,a.deleteIssueCommentAttachments=Ao,a.deleteIssueComments=wf,a.deleteIssueType=fS,a.deleteIssueTypeAttachment=qo,a.deleteIssueTypeAttachments=Vo,a.deleteIssueTypeFieldValues=fi,a.deleteIssueTypeFieldValuesAttachment=hS,a.deleteIssueTypeFieldValuesAttachments=Ut,a.deleteIssueTypeFieldValuesMany=Xf,a.deleteIssueTypeFields=tl,a.deleteIssueTypeFieldsAttachment=Nf,a.deleteIssueTypeFieldsAttachments=Lo,a.deleteIssueTypeFieldsMany=aS,a.deleteIssueTypes=SS,a.deleteIssueUpdate=Fl,a.deleteIssueUpdates=Tl,a.deleteIssues=Ro,a.deleteOrganization=YS,a.deleteOrganizationAccess=Dl,a.deleteOrganizationAccesses=kS,a.deleteOrganizations=JS,a.deleteProject=Hi,a.deleteProjectAccess=Di,a.deleteProjectAccesses=xl,a.deleteProjectAttachment=dh,a.deleteProjectAttachments=$i,a.deleteProjectFile=fh,a.deleteProjectFiles=Sh,a.deleteProjects=bg,a.deleteTeam=xi,a.deleteTeamMembership=Zi,a.deleteTeamMemberships=Mg,a.deleteTeams=Ug,a.deleteUser=Ml,a.deleteUsers=ES,a.dequeue=am,a.discard=cc,a.documentAttachmentReducer=Ud,a.documentAttachmentSlice=Fa,a.documentSlice=Ta,a.documentsReducer=Ld,a.downloadFile=qm,a.downloadInMemoryFile=Mm,a.emailDomainsReducer=Zd,a.emailDomainsSlice=_a,a.emailRegex=Bm,a.enqueue=sm,a.enqueueRequest=Wl,a.fallbackToEmptyArray=g,a.fallbackToEmptyObject=ht,a.fileReducer=tu,a.fileSlice=Oa,a.fileToBlob=Sc,a.formReducer=gu,a.formRevisionAttachmentReducer=du,a.formRevisionAttachmentSlice=Ra,a.formRevisionReducer=yu,a.formRevisionsSlice=va,a.formSlice=Ea,a.formSubmissionAttachmentReducer=vu,a.formSubmissionAttachmentSlice=Va,a.formSubmissionReducer=zu,a.formSubmissionSlice=Ua,a.geoImageReducer=Hu,a.geoImageSlice=Ga,a.getFileIdentifier=wm,a.getFileS3Key=Kt,a.getLocalDateString=yc,a.getLocalRelativeDateString=Rm,a.getOutboxCoordinator=ke,a.getRenamedFile=fc,a.hashFile=Ne,a.initSDK=fP,a.initializeAssetAttachments=Xt,a.initializeAssetProcedureAttachments=kc,a.initializeAssetProcedureFieldValues=gn,a.initializeAssetProcedureFieldValuesAttachments=hn,a.initializeAssetProcedureFields=cn,a.initializeAssetProcedureFieldsAttachments=Zc,a.initializeAssetProcedureInstances=On,a.initializeAssetProcedureStepFieldValues=er,a.initializeAssetProcedureStepFieldValuesAttachments=Kn,a.initializeAssetProcedureStepFields=Nn,a.initializeAssetProcedureStepFieldsAttachments=Un,a.initializeAssetProcedureSteps=rr,a.initializeAssetProcedures=jn,a.initializeAssetStageCompletions=fr,a.initializeAssetStages=Ir,a.initializeAssetTypeAttachments=wr,a.initializeAssetTypeFieldValues=rd,a.initializeAssetTypeFieldValuesAttachments=ed,a.initializeAssetTypeFields=Kr,a.initializeAssetTypeFieldsAttachments=kr,a.initializeAssetTypes=pd,a.initializeAssets=hr,a.initializeCategories=Pd,a.initializeConversations=Ic,a.initializeDocumentAttachments=Rd,a.initializeEmailDomains=Hd,a.initializeFormRevisionAttachments=au,a.initializeFormRevisions=ou,a.initializeFormSubmissionAttachments=Iu,a.initializeFormSubmissions=Mu,a.initializeForms=Su,a.initializeGeoImages=Du,a.initializeIssueAssociations=Ku,a.initializeIssueAttachments=Xa,a.initializeIssueCommentAttachments=ti,a.initializeIssueComments=_f,a.initializeIssueTypeAttachments=mi,a.initializeIssueTypeFieldValues=Yo,a.initializeIssueTypeFieldValuesAttachments=cl,a.initializeIssueTypeFields=Qo,a.initializeIssueTypeFieldsAttachments=Bo,a.initializeIssueTypes=hl,a.initializeIssueUpdates=gl,a.initializeIssues=_o,a.initializeOrganizationAccesses=zl,a.initializeOrganizations=GS,a.initializeProjectAccesses=Xl,a.initializeProjectAttachments=ah,a.initializeProjectFiles=Ah,a.initializeProjects=Oh,a.initializeTeamMemberships=Vh,a.initializeTeams=Bh,a.initializeUsers=vl,a.isToday=Om,a.issueAssociationReducer=xu,a.issueAssociationSlice=Ha,a.issueAttachmentReducer=uo,a.issueAttachmentSlice=Za,a.issueCommentAttachmentReducer=go,a.issueCommentAttachmentSlice=ei,a.issueCommentReducer=To,a.issueCommentSlice=si,a.issueReducer=vo,a.issueSlice=ri,a.issueTypeAttachmentReducer=Co,a.issueTypeAttachmentSlice=hi,a.issueTypeFieldValuesAttachmentReducer=ol,a.issueTypeFieldValuesAttachmentSlice=Pi,a.issueTypeFieldValuesReducer=Zo,a.issueTypeFieldValuesSlice=Ai,a.issueTypeFieldsAttachmentReducer=Wo,a.issueTypeFieldsAttachmentSlice=pi,a.issueTypeFieldsReducer=al,a.issueTypeFieldsSlice=bi,a.issueTypeReducer=fl,a.issueTypeSlice=Ti,a.issueUpdateReducer=Ol,a.issueUpdateSlice=Ri,a.logOnlyOnce=Vm,a.markAsDeleted=Kl,a.markForDeletion=eg,a.memoize=Ht,a.moveDocument=Bd,a.offline=T,a.onlyUniqueHashes=km,a.onlyUniqueOfflineIds=Fc,a.organizationAccessReducer=Cl,a.organizationAccessSlice=Mi,a.organizationReducer=Ll,a.organizationSlice=qi,a.outboxReducer=Jl,a.outboxSlice=Vi,a.overmapEnhancer=Qg,a.overmapReducer=$g,a.overmapReducers=Kh,a.performRequest=ic,a.projectAccessReducer=eh,a.projectAccessSlice=zi,a.projectAttachmentReducer=mh,a.projectAttachmentSlice=Bi,a.projectFileReducer=Ih,a.projectFileSlice=Gi,a.projectReducer=wh,a.projectSlice=Ni,a.rehydratedReducer=jh,a.rehydratedSlice=Ki,a.removeDocuments=Ia,a.removeIssueType=Ii,a.resetProjectFileObjectUrls=hg,a.restructureCreateSelectorWithArgs=f,a.saveActiveProjectFileBounds=Ph,a.selectAccessToken=Ay,a.selectAccessesByUserOfProject=ig,a.selectAccessibleProjects=Pg,a.selectActiveOrganizationAccess=BS,a.selectActiveProjectFileId=pg,a.selectAllDocumentAttachments=Vd,a.selectAllProjectAttachments=oh,a.selectAncestorIdsOfDocument=wy,a.selectAssetAttachmentById=zc,a.selectAssetAttachmentMapping=qc,a.selectAssetAttachments=Vc,a.selectAssetById=Ns,a.selectAssetProcedureAttachmentById=Kc,a.selectAssetProcedureAttachmentMapping=Hc,a.selectAssetProcedureAttachments=Wc,a.selectAssetProcedureById=Ps,a.selectAssetProcedureFieldValues=us,a.selectAssetProcedureFieldValuesAttachmentById=Pp,a.selectAssetProcedureFieldValuesAttachments=pn,a.selectAssetProcedureFieldValuesAttachmentsByIds=An,a.selectAssetProcedureFieldValuesAttachmentsMapping=cs,a.selectAssetProcedureFieldValuesById=os,a.selectAssetProcedureFieldValuesMapping=Tn,a.selectAssetProcedureFieldValuesOfAsset=Ip,a.selectAssetProcedureFields=as,a.selectAssetProcedureFieldsAttachmentById=rp,a.selectAssetProcedureFieldsAttachments=tn,a.selectAssetProcedureFieldsAttachmentsMapping=en,a.selectAssetProcedureFieldsById=Ap,a.selectAssetProcedureFieldsMapping=un,a.selectAssetProcedureFieldsOfAssetProcedure=mp,a.selectAssetProcedureInstanceById=ys,a.selectAssetProcedureInstances=As,a.selectAssetProcedureInstancesByIds=Mp,a.selectAssetProcedureInstancesMapping=ps,a.selectAssetProcedureInstancesOfAssetProcedure=wn,a.selectAssetProcedureInstancesOfAssetType=wp,a.selectAssetProcedureStepById=Ds,a.selectAssetProcedureStepFieldValues=ft,a.selectAssetProcedureStepFieldValuesAttachmentById=cA,a.selectAssetProcedureStepFieldValuesAttachments=Jn,a.selectAssetProcedureStepFieldValuesAttachmentsByIds=Zn,a.selectAssetProcedureStepFieldValuesAttachmentsMapping=ws,a.selectAssetProcedureStepFieldValuesById=qs,a.selectAssetProcedureStepFieldValuesMapping=ir,a.selectAssetProcedureStepFieldValuesOfAsset=dA,a.selectAssetProcedureStepFieldValuesOfAssetProcedureInstance=uA,a.selectAssetProcedureStepFieldValuesOfAssetProcedureStep=oA,a.selectAssetProcedureStepFields=Rs,a.selectAssetProcedureStepFieldsAttachmentById=Np,a.selectAssetProcedureStepFieldsAttachments=$n,a.selectAssetProcedureStepFieldsAttachmentsMapping=Bn,a.selectAssetProcedureStepFieldsById=xp,a.selectAssetProcedureStepFieldsMapping=Os,a.selectAssetProcedureStepFieldsOfAssetProcedureStep=Zp,a.selectAssetProcedureStepMapping=gt,a.selectAssetProcedureSteps=or,a.selectAssetProcedureStepsByIds=fA,a.selectAssetProcedureStepsMappingOfAssetProcedure=AA,a.selectAssetProcedureStepsOfAssetProcedure=yA,a.selectAssetProcedures=qn,a.selectAssetProceduresByIds=Up,a.selectAssetProceduresMapping=bs,a.selectAssetProceduresOfOrganization=Dp,a.selectAssetStageById=ea,a.selectAssetStageCompletionById=Pr,a.selectAssetStageCompletionMapping=Zs,a.selectAssetStageCompletions=IA,a.selectAssetStageCompletionsByIds=Fr,a.selectAssetStages=Rr,a.selectAssetStagesByIds=EA,a.selectAssetStagesMappingOfAssetProcedure=wA,a.selectAssetStagesOfAssetProcedure=MA,a.selectAssetTypeAttachmentById=zr,a.selectAssetTypeAttachmentMapping=qr,a.selectAssetTypeAttachments=Vr,a.selectAssetTypeById=fa,a.selectAssetTypeFieldValues=la,a.selectAssetTypeFieldValuesAttachmentById=ty,a.selectAssetTypeFieldValuesAttachments=sd,a.selectAssetTypeFieldValuesAttachmentsByIds=ad,a.selectAssetTypeFieldValuesAttachmentsMapping=ra,a.selectAssetTypeFieldValuesById=ha,a.selectAssetTypeFieldValuesMapping=ld,a.selectAssetTypeFieldValuesOfAsset=iy,a.selectAssetTypeFields=Tt,a.selectAssetTypeFieldsAttachmentById=$A,a.selectAssetTypeFieldsAttachments=Nr,a.selectAssetTypeFieldsAttachmentsMapping=Lr,a.selectAssetTypeFieldsById=JA,a.selectAssetTypeFieldsMapping=Xr,a.selectAssetTypeFieldsOfAssetType=KA,a.selectAssetTypeValuesOfAssetType=cy,a.selectAssetTypes=Ad,a.selectAssetTypesByIds=ly,a.selectAssetTypesMapping=ya,a.selectAssetTypesOfOrganization=hy,a.selectAssets=mr,a.selectAssetsByIds=pr,a.selectAssetsMapping=Gs,a.selectAssetsOfAssetType=Ls,a.selectAttachmentsOfAsset=Uc,a.selectAttachmentsOfAssetProcedure=ep,a.selectAttachmentsOfAssetProcedureFieldValues=yn,a.selectAttachmentsOfAssetProcedureFields=np,a.selectAttachmentsOfAssetProcedureStepFieldValues=Xn,a.selectAttachmentsOfAssetProcedureStepFields=Lp,a.selectAttachmentsOfAssetType=Ur,a.selectAttachmentsOfAssetTypeFieldValues=id,a.selectAttachmentsOfAssetTypeFields=BA,a.selectAttachmentsOfDocument=Ry,a.selectAttachmentsOfFormRevision=Ny,a.selectAttachmentsOfFormSubmission=Ru,a.selectAttachmentsOfIssue=no,a.selectAttachmentsOfIssueComment=If,a.selectAttachmentsOfIssueType=kf,a.selectAttachmentsOfIssueTypeFieldValues=ul,a.selectAttachmentsOfIssueTypeFields=Hf,a.selectAttachmentsOfProject=hh,a.selectCategories=Id,a.selectCategoriesByIds=Fy,a.selectCategoriesOfProject=Ty,a.selectCategoryById=Pa,a.selectCategoryMapping=ba,a.selectCommentsOfIssue=Mf,a.selectConversation=Km,a.selectConversationMapping=Jt,a.selectConversations=Wm,a.selectCurrentUser=jl,a.selectDeletedRequests=QS,a.selectDocumentAttachmentById=zd,a.selectDocumentAttachmentMapping=qd,a.selectDocumentById=Gd,a.selectDocuments=$d,a.selectDocumentsByIds=vy,a.selectDocumentsMapping=He,a.selectEmailDomains=Jd,a.selectEmailDomainsAsMapping=Yd,a.selectEmailDomainsOfOrganization=Dy,a.selectFieldValuesOfAssetProcedureInstance=_p,a.selectFormById=Fu,a.selectFormMapping=bu,a.selectFormRevisionAttachmentsMapping=ru,a.selectFormRevisionById=Jy,a.selectFormRevisionMapping=Rt,a.selectFormRevisions=pu,a.selectFormRevisionsOfForm=Au,a.selectFormSubmissionAttachemntsByIds=Ou,a.selectFormSubmissionAttachmentsMapping=za,a.selectFormSubmissionById=$a,a.selectFormSubmissions=Ba,a.selectFormSubmissionsMapping=ka,a.selectFormSubmissionsOfAsset=Vu,a.selectFormSubmissionsOfForm=ju,a.selectFormSubmissionsOfIssue=qu,a.selectForms=Pu,a.selectFormsOfOrganization=af,a.selectGeoImageById=Na,a.selectGeoImageMapping=Lu,a.selectGeoImages=Nu,a.selectGeoImagesOfProject=mf,a.selectIsImportingProjectFile=Ag,a.selectIsLoggedIn=yy,a.selectIssueAssociationById=Ju,a.selectIssueAssociationMapping=ct,a.selectIssueAssociations=ff,a.selectIssueAssociationsOfAsset=Qu,a.selectIssueAssociationsOfIssue=Xu,a.selectIssueAssociationsToIssue=Zu,a.selectIssueAttachmentById=ro,a.selectIssueAttachmentMapping=io,a.selectIssueAttachments=co,a.selectIssueById=li,a.selectIssueCommentAttachmentById=So,a.selectIssueCommentAttachmentMapping=yo,a.selectIssueCommentAttachments=fo,a.selectIssueCommentById=ni,a.selectIssueCommentMapping=Fo,a.selectIssueMapping=oi,a.selectIssueTypeAttachmentById=Do,a.selectIssueTypeAttachmentMapping=zo,a.selectIssueTypeAttachments=Uo,a.selectIssueTypeById=_i,a.selectIssueTypeFieldValues=Si,a.selectIssueTypeFieldValuesAttachmentById=mS,a.selectIssueTypeFieldValuesAttachments=rl,a.selectIssueTypeFieldValuesAttachmentsByIds=dl,a.selectIssueTypeFieldValuesAttachmentsMapping=Fi,a.selectIssueTypeFieldValuesById=gi,a.selectIssueTypeFieldValuesMapping=Jo,a.selectIssueTypeFieldValuesOfIssue=Qf,a.selectIssueTypeFields=Vt,a.selectIssueTypeFieldsAttachmentById=Wf,a.selectIssueTypeFieldsAttachments=Ho,a.selectIssueTypeFieldsAttachmentsMapping=No,a.selectIssueTypeFieldsById=rS,a.selectIssueTypeFieldsMapping=sl,a.selectIssueTypeFieldsOfIssueType=iS,a.selectIssueTypeMapping=Al,a.selectIssueTypeValuesOfIssueType=nS,a.selectIssueTypes=yl,a.selectIssueTypesByIds=gS,a.selectIssueTypesOfOrganization=bS,a.selectIssueUpdateMapping=Il,a.selectIssueUpdatesOfIssue=_l,a.selectIssues=Vf,a.selectIssuesByIds=zf,a.selectIssuesOfIssueType=Oi,a.selectIssuesOfIssueTypeCount=PS,a.selectLatestAssetProcedureFieldsOfAssetProcedure=pp,a.selectLatestAssetProcedureStepFieldsOfAssetProcedureStep=Xp,a.selectLatestAssetTypeFieldsOfAssetType=YA,a.selectLatestFieldsByAssetProcedureStep=Qp,a.selectLatestFormRevisionOfForm=Zy,a.selectLatestIssueTypeFieldsOfIssueType=cS,a.selectLatestRetryTime=xS,a.selectMembershipsByUserOfTeam=Eg,a.selectNumberOfAssetsOfAssetType=PA,a.selectOrganizationAccessById=ji,a.selectOrganizationAccessMapping=Ei,a.selectOrganizationAccessUserMapping=kl,a.selectOrganizationById=XS,a.selectOrganizations=ZS,a.selectOrganizationsMapping=Gl,a.selectProjectAccessById=ki,a.selectProjectAccessMapping=Ci,a.selectProjectAccesses=kt,a.selectProjectAccessesOfProject=th,a.selectProjectAttachmentById=lh,a.selectProjectAttachmentMapping=uh,a.selectProjectById=Eh,a.selectProjectFileById=mg,a.selectProjectFileMapping=Fh,a.selectProjectFiles=Th,a.selectProjectMapping=Mh,a.selectProjects=Wi,a.selectProjectsOfOrganization=Fg,a.selectRehydrated=_g,a.selectRootDocuments=My,a.selectStageMapping=Ft,a.selectTeamById=tc,a.selectTeamMembershipById=Ch,a.selectTeamMemberships=Xi,a.selectTeamMembershipsMapping=Dh,a.selectTeams=Lh,a.selectTeamsByIds=Dg,a.selectTeamsMapping=ec,a.selectTeamsOfOrganization=Cg,a.selectUploadUrl=eu,a.selectUserById=ql,a.selectUsers=wi,a.selectUsersByIds=VS,a.selectUsersMapping=Dt,a.selectUsersOfOrganization=$S,a.selectUsersOfProject=cg,a.selectUsersOfTeam=jg,a.setActiveProjectFileId=bh,a.setAsset=gA,a.setAssetAttachment=Mc,a.setAssetAttachments=Jm,a.setAssetProcedure=Vp,a.setAssetProcedureAttachment=$c,a.setAssetProcedureAttachments=Qm,a.setAssetProcedureFieldValues=Fp,a.setAssetProcedureFieldValuesAttachment=fp,a.setAssetProcedureFieldValuesAttachments=Sp,a.setAssetProcedureFieldValuesMany=Tp,a.setAssetProcedureFields=up,a.setAssetProcedureFieldsAttachment=sp,a.setAssetProcedureFieldsAttachments=ap,a.setAssetProcedureFieldsMany=op,a.setAssetProcedureInstance=Rp,a.setAssetProcedureInstances=vp,a.setAssetProcedureStep=dr,a.setAssetProcedureStepFieldValues=nA,a.setAssetProcedureStepFieldValuesAttachment=tA,a.setAssetProcedureStepFieldValuesAttachments=sA,a.setAssetProcedureStepFieldValuesMany=rA,a.setAssetProcedureStepFields=Wp,a.setAssetProcedureStepFieldsAttachment=kp,a.setAssetProcedureStepFieldsAttachments=Bp,a.setAssetProcedureStepFieldsMany=Kp,a.setAssetProcedureSteps=lA,a.setAssetProcedures=zp,a.setAssetStage=_r,a.setAssetStageCompletion=FA,a.setAssetStageCompletions=TA,a.setAssetStages=_A,a.setAssetType=ny,a.setAssetTypeAttachment=Mr,a.setAssetTypeAttachments=qA,a.setAssetTypeFieldValues=sy,a.setAssetTypeFieldValuesAttachment=XA,a.setAssetTypeFieldValuesAttachments=QA,a.setAssetTypeFieldValuesMany=ay,a.setAssetTypeFields=LA,a.setAssetTypeFieldsAttachment=UA,a.setAssetTypeFieldsAttachments=DA,a.setAssetTypeFieldsMany=NA,a.setAssetTypes=ry,a.setAssets=bA,a.setCategories=gy,a.setCategory=Sy,a.setConversation=Oc,a.setConversations=Gm,a.setCurrentUser=jS,a.setDocumentAttachment=wd,a.setDocumentAttachments=_y,a.setDocuments=Cd,a.setEmailDomain=jy,a.setEmailDomains=qy,a.setForm=Qy,a.setFormRevision=hu,a.setFormRevisionAttachment=By,a.setFormRevisionAttachments=$y,a.setFormRevisions=Wy,a.setFormSubmission=Mt,a.setFormSubmissionAttachment=nf,a.setFormSubmissionAttachments=rf,a.setFormSubmissions=of,a.setForms=xy,a.setGeoImage=it,a.setGeoImages=Cu,a.setIsImportingProjectFile=gh,a.setIssue=Ef,a.setIssueAssociation=Af,a.setIssueAssociations=pf,a.setIssueAttachment=to,a.setIssueAttachments=gf,a.setIssueComment=ii,a.setIssueCommentAttachment=ho,a.setIssueCommentAttachments=Ff,a.setIssueComments=Po,a.setIssueType=rt,a.setIssueTypeAttachment=Eo,a.setIssueTypeAttachments=Df,a.setIssueTypeFieldValues=Yf,a.setIssueTypeFieldValuesAttachment=uS,a.setIssueTypeFieldValuesAttachments=oS,a.setIssueTypeFieldValuesMany=Jf,a.setIssueTypeFields=eS,a.setIssueTypeFieldsAttachment=$f,a.setIssueTypeFieldsAttachments=Gf,a.setIssueTypeFieldsMany=tS,a.setIssueTypes=AS,a.setIssueUpdate=FS,a.setIssueUpdates=TS,a.setIssues=jf,a.setLoggedIn=Sd,a.setOrganization=LS,a.setOrganizationAccess=US,a.setOrganizationAccesses=DS,a.setOrganizations=$l,a.setProfilePicture=qS,a.setProject=fg,a.setProjectAccess=tg,a.setProjectAccesses=sg,a.setProjectAttachment=ch,a.setProjectAttachments=nh,a.setProjectFile=dg,a.setProjectFiles=ug,a.setProjects=yg,a.setRehydrated=Ig,a.setTeam=ut,a.setTeamMembership=Ji,a.setTeamMemberships=Rg,a.setTeams=Vg,a.setTokens=my,a.setUploadUrl=xd,a.setUser=RS,a.setUsers=OS,a.shallowEqual=Fm,a.slugify=Dm,a.spacesToDashesLower=Um,a.teamMembershipReducer=Uh,a.teamMembershipSlice=Yi,a.teamReducer=Nh,a.teamSlice=Qi,a.toFileNameSafeString=zm,a.toOfflineIdRecord=Pc,a.truncate=Cm,a.updateAsset=tt,a.updateAssetAttachment=Zm,a.updateAssetAttachments=Ec,a.updateAssetProcedure=Qe,a.updateAssetProcedureAttachment=xm,a.updateAssetProcedureAttachments=Gc,a.updateAssetProcedureFieldValues=Ze,a.updateAssetProcedureFieldValuesAttachment=gp,a.updateAssetProcedureFieldValuesAttachments=mn,a.updateAssetProcedureFieldValuesMany=Pn,a.updateAssetProcedureFields=rn,a.updateAssetProcedureFieldsAttachment=ip,a.updateAssetProcedureFieldsAttachments=Qc,a.updateAssetProcedureFieldsMany=lp,a.updateAssetProcedureInstance=Xe,a.updateAssetProcedureInstances=Op,a.updateAssetProcedureStep=St,a.updateAssetProcedureStepFieldValues=et,a.updateAssetProcedureStepFieldValuesAttachment=aA,a.updateAssetProcedureStepFieldValuesAttachments=Yn,a.updateAssetProcedureStepFieldValuesMany=sr,a.updateAssetProcedureStepFields=xe,a.updateAssetProcedureStepFieldsAttachment=$p,a.updateAssetProcedureStepFieldsAttachments=Cn,a.updateAssetProcedureStepFieldsMany=Yp,a.updateAssetProcedureSteps=mA,a.updateAssetProcedures=jp,a.updateAssetStage=Pt,a.updateAssetStageCompletion=Sr,a.updateAssetStageCompletions=gr,a.updateAssetStages=RA,a.updateAssetType=at,a.updateAssetTypeAttachment=VA,a.updateAssetTypeAttachments=Er,a.updateAssetTypeFieldValues=st,a.updateAssetTypeFieldValuesAttachment=xA,a.updateAssetTypeFieldValuesAttachments=td,a.updateAssetTypeFieldValuesMany=ud,a.updateAssetTypeFields=Jr,a.updateAssetTypeFieldsAttachment=CA,a.updateAssetTypeFieldsAttachments=$r,a.updateAssetTypeFieldsMany=HA,a.updateAssetTypes=uy,a.updateAssets=SA,a.updateCategories=by,a.updateCategory=Fd,a.updateConversation=Rc,a.updateConversations=Lm,a.updateDocumentAttachment=Oy,a.updateDocumentAttachments=Md,a.updateDocuments=De,a.updateEmailDomain=Vy,a.updateEmailDomains=zy,a.updateForm=ef,a.updateFormRevision=Ky,a.updateFormRevisionAttachment=Gy,a.updateFormRevisionAttachments=cu,a.updateFormRevisions=Yy,a.updateFormSubmission=Eu,a.updateFormSubmissionAttachment=df,a.updateFormSubmissionAttachments=_u,a.updateFormSubmissions=lf,a.updateForms=tf,a.updateGeoImage=$u,a.updateGeoImages=hf,a.updateIssue=qt,a.updateIssueAssociation=Yu,a.updateIssueAssociations=yf,a.updateIssueAttachment=bf,a.updateIssueAttachments=so,a.updateIssueComment=Rf,a.updateIssueCommentAttachment=Tf,a.updateIssueCommentAttachments=mo,a.updateIssueComments=vf,a.updateIssueType=pl,a.updateIssueTypeAttachment=Cf,a.updateIssueTypeAttachments=jo,a.updateIssueTypeFieldValues=nt,a.updateIssueTypeFieldValuesAttachment=lS,a.updateIssueTypeFieldValuesAttachments=nl,a.updateIssueTypeFieldValuesMany=Zf,a.updateIssueTypeFields=el,a.updateIssueTypeFieldsAttachment=Lf,a.updateIssueTypeFieldsAttachments=Go,a.updateIssueTypeFieldsMany=sS,a.updateIssueTypes=yS,a.updateIssueUpdate=IS,a.updateIssueUpdates=_S,a.updateIssues=qf,a.updateOrganization=KS,a.updateOrganizationAccess=Ct,a.updateOrganizationAccesses=CS,a.updateOrganizations=WS,a.updateProject=vh,a.updateProjectAccess=dt,a.updateProjectAccesses=ag,a.updateProjectAttachment=rg,a.updateProjectAttachments=rh,a.updateProjectFile=Li,a.updateProjectFiles=lg,a.updateProjects=gg,a.updateTeam=Gh,a.updateTeamMembership=vg,a.updateTeamMemberships=wg,a.updateTeams=zg,a.updateUser=MS,a.updateUsers=wS,a.userReducer=El,a.userSlice=vi,a.versioningReducer=Wh,a.versioningSlice=Hh,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|