@overmap-ai/core 1.0.74-procedures.1 → 1.0.74-procedures.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/enums/access.d.ts +6 -4
  2. package/dist/overmap-core.js +2814 -2709
  3. package/dist/overmap-core.umd.cjs +7 -7
  4. package/dist/sdk/services/BaseAttachmentService.d.ts +3 -3
  5. package/dist/sdk/services/IssueAttachmentService.d.ts +1 -0
  6. package/dist/sdk/services/IssueCommentAttachmentService.d.ts +40 -0
  7. package/dist/sdk/services/IssueTypeAttachmentService.d.ts +40 -0
  8. package/dist/sdk/services/ProjectAttachmentService.d.ts +1 -1
  9. package/dist/sdk/services/index.d.ts +2 -0
  10. package/dist/store/slices/assetAttachmentSlice.d.ts +0 -4
  11. package/dist/store/slices/assetProcedureFieldValuesAttachmentSlice.d.ts +1 -1
  12. package/dist/store/slices/assetProcedureFieldValuesSlice.d.ts +2 -2
  13. package/dist/store/slices/assetProcedureFieldsAttachmentSlice.d.ts +2 -2
  14. package/dist/store/slices/assetProcedureFieldsSlice.d.ts +3 -3
  15. package/dist/store/slices/assetProcedureInstanceSlice.d.ts +3 -3
  16. package/dist/store/slices/assetProcedureSlice.d.ts +2 -2
  17. package/dist/store/slices/assetSlice.d.ts +2 -2
  18. package/dist/store/slices/assetStageCompletionSlice.d.ts +21 -21
  19. package/dist/store/slices/assetStageSlice.d.ts +9 -9
  20. package/dist/store/slices/assetTypeAttachmentSlice.d.ts +0 -4
  21. package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +1 -1
  22. package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +2 -2
  23. package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +2 -2
  24. package/dist/store/slices/assetTypeFieldsSlice.d.ts +3 -3
  25. package/dist/store/slices/assetTypeSlice.d.ts +2 -2
  26. package/dist/store/slices/documentAttachmentSlice.d.ts +0 -4
  27. package/dist/store/slices/emailDomainsSlice.d.ts +10 -10
  28. package/dist/store/slices/formRevisionSlice.d.ts +0 -1
  29. package/dist/store/slices/formSlice.d.ts +0 -1
  30. package/dist/store/slices/geoImageSlice.d.ts +17 -17
  31. package/dist/store/slices/index.d.ts +2 -0
  32. package/dist/store/slices/issueAttachmentSlice.d.ts +0 -4
  33. package/dist/store/slices/issueCommentAttachmentSlice.d.ts +42 -0
  34. package/dist/store/slices/issueTypeAttachmentSlice.d.ts +42 -0
  35. package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +2 -2
  36. package/dist/store/slices/issueTypeFieldsSlice.d.ts +1 -1
  37. package/dist/store/slices/licenseSlice.d.ts +9 -9
  38. package/dist/store/slices/organizationAccessSlice.d.ts +9 -9
  39. package/dist/store/slices/projectAccessSlice.d.ts +9 -9
  40. package/dist/store/slices/projectAttachmentSlice.d.ts +0 -4
  41. package/dist/store/slices/projectSlice.d.ts +22 -1
  42. package/dist/store/store.d.ts +3 -1
  43. package/dist/typings/models/access.d.ts +0 -1
  44. package/dist/typings/models/assets.d.ts +3 -3
  45. package/dist/typings/models/attachments.d.ts +6 -0
  46. package/dist/typings/models/base.d.ts +7 -6
  47. package/dist/typings/models/fields.d.ts +1 -1
  48. package/dist/typings/models/forms.d.ts +4 -4
  49. package/dist/typings/models/geoImages.d.ts +3 -3
  50. package/dist/typings/models/issues.d.ts +22 -34
  51. package/dist/typings/models/store.d.ts +3 -1
  52. package/dist/utils/offline.d.ts +1 -0
  53. package/dist/utils/utils.d.ts +1 -0
  54. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
- (function(i,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("uuid"),require("@reduxjs/toolkit"),require("file-saver"),require("@redux-offline/redux-offline"),require("@redux-offline/redux-offline/lib/defaults"),require("localforage"),require("redux-persist-migrate"),require("superagent"),require("dependency-graph"),require("idb"),require("@redux-offline/redux-offline/lib/constants"),require("jwt-decode")):typeof define=="function"&&define.amd?define(["exports","uuid","@reduxjs/toolkit","file-saver","@redux-offline/redux-offline","@redux-offline/redux-offline/lib/defaults","localforage","redux-persist-migrate","superagent","dependency-graph","idb","@redux-offline/redux-offline/lib/constants","jwt-decode"],O):(i=typeof globalThis<"u"?globalThis:i||self,O(i["overmap-core"]={},i.uuid,i.toolkit,i.fileSaver,i.reduxOffline,i.offlineConfig,i.localforage,i.createMigration,i.request,i.dependencyGraph,i.idb,i.constants,i.jwtDecode))})(this,function(i,O,l,du,lu,gn,uu,hu,Se,mu,fu,pu,Au){"use strict";var fy=Object.defineProperty;var py=(i,O,l)=>O in i?fy(i,O,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[O]=l;var g=(i,O,l)=>py(i,typeof O!="symbol"?O+"":O,l);var ou;const bn=Object.freeze([]),_n=Object.freeze({});var gt=(t=>(t[t.BASIC=0]="BASIC",t[t.ADMIN=2]="ADMIN",t))(gt||{}),bt=(t=>(t[t.BASIC=0]="BASIC",t[t.ADMIN=2]="ADMIN",t))(bt||{}),u=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(u||{}),Tn=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(Tn||{}),_t=(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))(_t||{}),Tt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Tt||{}),v=(t=>(t.STATUS="status",t.PRIORITY="priority",t.CATEGORY="category",t.DESCRIPTION="description",t.TITLE="title",t.ASSIGNED_TO="assigned_to",t.DUE_DATE="due_date",t))(v||{}),Fn=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Fn||{}),In=(t=>(t[t.PRO=0]="PRO",t))(In||{}),Rn=(t=>(t[t.ACTIVE=0]="ACTIVE",t[t.PAUSED=2]="PAUSED",t[t.CANCELLED=4]="CANCELLED",t[t.INACTIVE=6]="INACTIVE",t[t.PAST_DUE=8]="PAST_DUE",t))(Rn||{});const yu=Tt.BACKLOG,Su=_t.MEDIUM,Pn=6e4;function I(t){return{addOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},addMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},setOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},setMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},updateOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},updateMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},deleteOne:(f,p)=>{delete f.instances[p.payload]},deleteMany:(f,p)=>{for(const A of p.payload)delete f.instances[A]},initialize:(f,p)=>{f.instances={};for(const A of p.payload){const _=t(A);f.instances[_]=A}},getInitialState:f=>({...f,instances:{}})}}ou=Symbol.toStringTag;class On{constructor(){g(this,ou,"Promise");g(this,"_promise");g(this,"_resolve");g(this,"_reject");g(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 gu=t=>({type:"Point",coordinates:t}),bu=t=>({type:"MultiPoint",coordinates:t}),_u=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Ft=!1;["true","1"].includes("".toLowerCase())&&(Ft=!0);function vn(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;const s=Object.keys(t),n=Object.keys(e),a=s.length;if(a!==n.length)return!1;for(let c=0;c<a;c++){const r=s[c];if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1}return!0}function It(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Ft&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Ft&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Tu(t,e){if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}const S=t=>t.length===0?bn:t,ge=t=>Object.keys(t).length===0?_n:t,wn=It(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===Rt.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),Fu=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),Iu=1e3*86400,Rt=new Date,Ru=t=>new Date(t).toDateString()===Rt.toDateString(),Pu=It((t,e,s)=>{const n=Math.round((new Date(t).getTime()-Rt.getTime())/Iu);return n<e||n>s?wn(t):Fu.format(n,"days")});function Ou(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const Pt=async(t,e)=>{e||(e=await be(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 be(t){return new Promise((e,s)=>{const n=new FileReader;n.onload=()=>{const a=n.result;if(!a){s(new Error("FileReader did not return a valid ArrayBuffer."));return}crypto.subtle.digest("SHA-1",a).then(c=>{const r=Ou(c);e(r)})},n.readAsArrayBuffer(t)})}function vu(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 En(t,e){return new File([t],e,{type:t.type})}function wu(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 Eu=async t=>{const e={};for(const s of t){const n=await be(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},jn=async t=>(await fetch(t)).blob(),ju=t=>new Promise((e,s)=>{const n=new FileReader;n.onloadend=()=>{var a;e(((a=n.result)==null?void 0:a.toString())||"")},n.readAsDataURL(t)});function qu(t){const e=new Blob([t]);du.saveAs(e,t.name)}const qn={};function Mu(t,e,s,...n){const a=qn[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(qn[t]={[e]:!0},c=!0),c&&console[s](...n)}function F(t){return{...t,offline_id:O.v4()}}function Mn(t){const e={};for(const s of t)e[s.offline_id]=s;return e}function ku(t,e=void 0,s=255){let n=t.replace(/[^a-z0-9_\-.]/gi,"_").replace(/_{2,}/g,"_");if(!e){const c=t.split(".");c.length>1&&(e=c[c.length-1])}e&&!e.startsWith(".")&&(e="."+e);const a=e?e.length:0;return n.length+a>s&&(n=n.slice(0,s-a)+(e||"")),n}function Du(t){return t.toLowerCase().replace(" ","-")}function zu(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Vu(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const y=t=>e=>s=>t(s,e);function kn(t,e,s){return s.findIndex(n=>n.offline_id===t.offline_id)===e}function Cu(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const Uu=/^.+@.+\..+$/,we=I(t=>t.offline_id),Dn=we.getInitialState({}),Ot=l.createSlice({name:"agents",initialState:Dn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dn)),reducers:{initializeConversations:we.initialize,addConversation:we.addOne,setConversation:we.setOne,updateConversation:we.updateOne}}),{initializeConversations:zn,addConversation:Vn,setConversation:Cn,updateConversation:Un}=Ot.actions,vt=t=>t.agentsReducer.instances,$u=l.createSelector([vt],t=>Object.values(t)),Bu=y(l.createSelector([vt,(t,e)=>e],(t,e)=>t[e])),$n=Ot.reducer,M=I(t=>t.offline_id),Bn=M.getInitialState({}),wt=l.createSlice({name:"assetAttachments",initialState:Bn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bn)),reducers:{initializeAssetAttachments:M.initialize,addAssetAttachment:M.addOne,addAssetAttachments:M.addMany,setAssetAttachment:M.setOne,setAssetAttachments:M.setMany,updateAssetAttachment:M.updateOne,updateAssetAttachments:M.updateMany,deleteAssetAttachment:M.deleteOne,deleteAssetAttachments:M.deleteMany}}),{initializeAssetAttachments:Et,addAssetAttachment:Gu,addAssetAttachments:jt,setAssetAttachment:Gn,setAssetAttachments:Lu,updateAssetAttachment:Nu,updateAssetAttachments:Ln,deleteAssetAttachment:Nn,deleteAssetAttachments:qt}=wt.actions,Hn=t=>t.assetAttachmentReducer.instances,Mt=l.createSelector([Hn],t=>Object.values(t)),Wn=t=>e=>e.assetAttachmentReducer.instances[t],Kn=y(l.createSelector([Mt,(t,e)=>e],(t,e)=>S(t.filter(({asset:s})=>e===s)))),Hu=y(l.createSelector([Mt,(t,e)=>e],(t,e)=>{const s=t.filter(({asset:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Yn=wt.reducer,k=I(t=>t.offline_id),Jn=k.getInitialState({}),kt=l.createSlice({name:"assetProcedureFieldsAttachments",initialState:Jn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Jn)),reducers:{initializeAssetProcedureFieldsAttachments:k.initialize,addAssetProcedureFieldsAttachment:k.addOne,addAssetProcedureFieldsAttachments:k.addMany,setAssetProcedureFieldsAttachment:k.setOne,setAssetProcedureFieldsAttachments:k.setMany,updateAssetProcedureFieldsAttachment:k.updateOne,updateAssetProcedureFieldsAttachments:k.updateMany,deleteAssetProcedureFieldsAttachment:k.deleteOne,deleteAssetProcedureFieldsAttachments:k.deleteMany}}),{initializeAssetProcedureFieldsAttachments:Xn,addAssetProcedureFieldsAttachment:Wu,addAssetProcedureFieldsAttachments:Zn,setAssetProcedureFieldsAttachment:Ku,setAssetProcedureFieldsAttachments:Yu,updateAssetProcedureFieldsAttachment:Ju,updateAssetProcedureFieldsAttachments:Qn,deleteAssetProcedureFieldsAttachment:Xu,deleteAssetProcedureFieldsAttachments:xn}=kt.actions,ea=t=>t.assetProcedureFieldsAttachmentReducer.instances,ta=l.createSelector([ea],t=>Object.values(t)),Zu=y(l.createSelector([ta,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),Qu=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],sa=kt.reducer,D=I(t=>t.offline_id),ia=D.getInitialState({}),Dt=l.createSlice({name:"assetProcedureFields",initialState:ia,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ia)),reducers:{initializeAssetProcedureFields:D.initialize,addAssetProcedureFields:D.addOne,addAssetProcedureFieldsMany:D.addMany,setAssetProcedureFields:D.setOne,setAssetProcedureFieldsMany:D.setMany,updateAssetProcedureFields:D.updateOne,updateAssetProcedureFieldsMany:D.updateMany,deleteAssetProcedureFields:D.deleteOne,deleteAssetProcedureFieldsMany:D.deleteMany}}),{initializeAssetProcedureFields:na,addAssetProcedureFields:aa,addAssetProcedureFieldsMany:xu,setAssetProcedureFields:eh,setAssetProcedureFieldsMany:th,updateAssetProcedureFields:ca,updateAssetProcedureFieldsMany:sh,deleteAssetProcedureFields:ra,deleteAssetProcedureFieldsMany:ih}=Dt.actions,oa=t=>t.assetProcedureFieldsReducer.instances,zt=l.createSelector([oa],t=>Object.values(t)),nh=y(l.createSelector([zt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),ah=y(l.createSelector([zt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),ch=t=>e=>e.assetProcedureFieldsReducer.instances[t],da=Dt.reducer,z=I(t=>t.offline_id),la=z.getInitialState({}),Vt=l.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:la,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,la)),reducers:{initializeAssetProcedureFieldValuesAttachments:z.initialize,addAssetProcedureFieldValuesAttachment:z.addOne,addAssetProcedureFieldValuesAttachments:z.addMany,setAssetProcedureFieldValuesAttachment:z.setOne,setAssetProcedureFieldValuesAttachments:z.setMany,updateAssetProcedureFieldValuesAttachment:z.updateOne,updateAssetProcedureFieldValuesAttachments:z.updateMany,deleteAssetProcedureFieldValuesAttachment:z.deleteOne,deleteAssetProcedureFieldValuesAttachments:z.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:ua,addAssetProcedureFieldValuesAttachment:rh,addAssetProcedureFieldValuesAttachments:We,setAssetProcedureFieldValuesAttachment:oh,setAssetProcedureFieldValuesAttachments:dh,updateAssetProcedureFieldValuesAttachment:lh,updateAssetProcedureFieldValuesAttachments:ha,deleteAssetProcedureFieldValuesAttachment:uh,deleteAssetProcedureFieldValuesAttachments:Ke}=Vt.actions,Ct=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,ma=l.createSelector([Ct],t=>Object.values(t)),hh=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],fa=y(l.createSelector([Ct,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),pa=y(l.createSelector([ma,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),Aa=Vt.reducer,V=I(t=>t.offline_id),ya=V.getInitialState({}),Ut=l.createSlice({name:"assetProcedureFieldValues",initialState:ya,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ya)),reducers:{initializeAssetProcedureFieldValues:V.initialize,addAssetProcedureFieldValues:V.addOne,addAssetProcedureFieldValuesMany:V.addMany,setAssetProcedureFieldValues:V.setOne,setAssetProcedureFieldValuesMany:V.setMany,updateAssetProcedureFieldValues:V.updateOne,updateAssetProcedureFieldValuesMany:V.updateMany,deleteAssetProcedureFieldValues:V.deleteOne,deleteAssetProcedureFieldValuesMany:V.deleteMany}}),{initializeAssetProcedureFieldValues:Sa,addAssetProcedureFieldValues:$t,addAssetProcedureFieldValuesMany:ga,setAssetProcedureFieldValues:mh,setAssetProcedureFieldValuesMany:fh,updateAssetProcedureFieldValues:Ee,updateAssetProcedureFieldValuesMany:ba,deleteAssetProcedureFieldValues:Bt,deleteAssetProcedureFieldValuesMany:_a}=Ut.actions,Ta=t=>t.assetProcedureFieldValuesReducer.instances,Gt=l.createSelector([Ta],t=>Object.values(t)),ph=y(l.createSelector([Gt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),Ah=y(l.createSelector([Gt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure_instance===e)))),Lt=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],Fa=Ut.reducer,C=I(t=>t.offline_id),Ia=C.getInitialState({}),Nt=l.createSlice({name:"assetProcedureInstances",initialState:Ia,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ia)),reducers:{initializeAssetProcedureInstances:C.initialize,addAssetProcedureInstance:C.addOne,addAssetProcedureInstances:C.addMany,setAssetProcedureInstance:C.setOne,setAssetProcedureInstances:C.setMany,updateAssetProcedureInstance:C.updateOne,updateAssetProcedureInstances:C.updateMany,deleteAssetProcedureInstance:C.deleteOne,deleteAssetProcedureInstances:C.deleteMany}}),{initializeAssetProcedureInstances:Ra,addAssetProcedureInstance:Ht,addAssetProcedureInstances:Pa,updateAssetProcedureInstance:je,updateAssetProcedureInstances:yh,deleteAssetProcedureInstance:Wt,deleteAssetProcedureInstances:Oa,setAssetProcedureInstance:Sh,setAssetProcedureInstances:gh}=Nt.actions,Kt=t=>t.assetProcedureInstanceReducer.instances,Yt=l.createSelector([Kt],t=>Object.values(t)),va=y(l.createSelector([Yt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),bh=y(l.createSelector([Yt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),Jt=t=>e=>e.assetProcedureInstanceReducer.instances[t],_h=y(l.createSelector([Kt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),wa=Nt.reducer,U=I(t=>t.offline_id),Ea=U.getInitialState({}),Xt=l.createSlice({name:"assetProcedures",initialState:Ea,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ea)),reducers:{initializeAssetProcedures:U.initialize,addAssetProcedure:U.addOne,addAssetProcedures:U.addMany,setAssetProcedure:U.setOne,setAssetProcedures:U.setMany,updateAssetProcedure:U.updateOne,updateAssetProcedures:U.updateMany,deleteAssetProcedure:U.deleteOne,deleteAssetProcedures:U.deleteMany}}),{initializeAssetProcedures:ja,addAssetProcedure:Zt,addAssetProcedures:Th,updateAssetProcedure:qe,updateAssetProcedures:Fh,deleteAssetProcedure:Qt,deleteAssetProcedures:Ih,setAssetProcedure:Rh,setAssetProcedures:Ph}=Xt.actions,xt=t=>t.assetProcedureReducer.instances,qa=l.createSelector([xt],t=>Object.values(t)),Oh=y(l.createSelector([qa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),es=t=>e=>e.assetProcedureReducer.instances[t],vh=y(l.createSelector([xt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),Ma=Xt.reducer,$=I(t=>t.offline_id),ka=$.getInitialState({}),ts=l.createSlice({name:"assets",initialState:ka,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ka)),reducers:{initializeAssets:$.initialize,addAsset:$.addOne,addAssets:$.addMany,setAsset:$.setOne,setAssets:$.setMany,updateAsset:$.updateOne,updateAssets:$.updateMany,deleteAsset:$.deleteOne,deleteAssets:$.deleteMany}}),{initializeAssets:Da,addAsset:ss,addAssets:is,updateAsset:Me,updateAssets:wh,deleteAsset:ns,deleteAssets:za,setAsset:Eh,setAssets:jh}=ts.actions,as=t=>t.assetReducer.instances,Va=l.createSelector([as],t=>S(Object.values(t))),cs=y(l.createSelector([Va,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),rs=t=>e=>e.assetReducer.instances[t],qh=y(l.createSelector([as,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),Mh=t=>e=>cs(t)(e).length,Ca=ts.reducer,de=I(t=>t.offline_id),Ua=de.getInitialState({}),os=l.createSlice({name:"assetStageCompletions",initialState:Ua,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ua)),reducers:{initializeAssetStageCompletions:de.initialize,addAssetStageCompletion:de.addOne,addAssetStageCompletions:de.addMany,updateAssetStageCompletion:de.updateOne,updateAssetStageCompletions:de.updateMany,deleteAssetStageCompletion:de.deleteOne,deleteAssetStageCompletions:de.deleteMany}}),{initializeAssetStageCompletions:$a,addAssetStageCompletion:ds,addAssetStageCompletions:ls,updateAssetStageCompletion:Ba,updateAssetStageCompletions:Ga,deleteAssetStageCompletion:us,deleteAssetStageCompletions:hs}=os.actions,La=os.reducer,ms=t=>t.assetStageCompletionReducer.instances,kh=l.createSelector([ms],t=>Object.values(t)),Na=t=>e=>e.assetStageCompletionReducer.instances[t],Ha=y(l.createSelector([ms,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),B=I(t=>t.offline_id),Wa=B.getInitialState({}),fs=l.createSlice({name:"assetStages",initialState:Wa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wa)),reducers:{initializeAssetStages:B.initialize,setAssetStage:B.setOne,setAssetStages:B.setMany,addAssetStage:B.addOne,addAssetStages:B.addMany,updateAssetStage:B.updateOne,updateAssetStages:B.updateMany,deleteAssetStage:B.deleteOne,deleteAssetStages:B.deleteMany}}),{initializeAssetStages:Ka,setAssetStage:Ya,setAssetStages:Dh,addAssetStage:zh,addAssetStages:ps,updateAssetStage:As,updateAssetStages:Ye,deleteAssetStage:Vh,deleteAssetStages:ys}=fs.actions,Ja=fs.reducer,Je=t=>t.assetStageReducer.instances,Xa=t=>e=>e.assetStageReducer.instances[t],Za=l.createSelector([Je],t=>Object.values(t)),Ch=y(l.createSelector([Je,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_procedure===e&&(s[n]=a);return ge(s)})),Uh=y(l.createSelector([Za,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Ss=y(l.createSelector([Je,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectStagesFromStageIds: No stage exists with the id",n)}return S(s)})),G=I(t=>t.offline_id),Qa=G.getInitialState({}),gs=l.createSlice({name:"assetTypeAttachments",initialState:Qa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qa)),reducers:{initializeAssetTypeAttachments:G.initialize,addAssetTypeAttachment:G.addOne,addAssetTypeAttachments:G.addMany,setAssetTypeAttachment:G.setOne,setAssetTypeAttachments:G.setMany,updateAssetTypeAttachment:G.updateOne,updateAssetTypeAttachments:G.updateMany,deleteAssetTypeAttachment:G.deleteOne,deleteAssetTypeAttachments:G.deleteMany}}),{initializeAssetTypeAttachments:xa,addAssetTypeAttachment:$h,addAssetTypeAttachments:bs,setAssetTypeAttachment:ec,setAssetTypeAttachments:Bh,updateAssetTypeAttachment:Gh,updateAssetTypeAttachments:tc,deleteAssetTypeAttachment:sc,deleteAssetTypeAttachments:_s}=gs.actions,ic=t=>t.assetTypeAttachmentReducer.instances,Ts=l.createSelector([ic],t=>Object.values(t)),nc=t=>e=>e.assetTypeAttachmentReducer.instances[t],ac=y(l.createSelector([Ts,(t,e)=>e],(t,e)=>S(t.filter(({asset_type:s})=>e===s)))),Lh=y(l.createSelector([Ts,(t,e)=>e],(t,e)=>{const s=t.filter(({asset_type:c})=>c===e),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),cc=gs.reducer,L=I(t=>t.offline_id),rc=L.getInitialState({}),Fs=l.createSlice({name:"assetTypeFieldsAttachments",initialState:rc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,rc)),reducers:{initializeAssetTypeFieldsAttachments:L.initialize,addAssetTypeFieldsAttachment:L.addOne,addAssetTypeFieldsAttachments:L.addMany,setAssetTypeFieldsAttachment:L.setOne,setAssetTypeFieldsAttachments:L.setMany,updateAssetTypeFieldsAttachment:L.updateOne,updateAssetTypeFieldsAttachments:L.updateMany,deleteAssetTypeFieldsAttachment:L.deleteOne,deleteAssetTypeFieldsAttachments:L.deleteMany}}),{initializeAssetTypeFieldsAttachments:oc,addAssetTypeFieldsAttachment:Nh,addAssetTypeFieldsAttachments:dc,setAssetTypeFieldsAttachment:Hh,setAssetTypeFieldsAttachments:Wh,updateAssetTypeFieldsAttachment:Kh,updateAssetTypeFieldsAttachments:lc,deleteAssetTypeFieldsAttachment:Yh,deleteAssetTypeFieldsAttachments:uc}=Fs.actions,hc=t=>t.assetTypeFieldsAttachmentReducer.instances,mc=l.createSelector([hc],t=>Object.values(t)),Jh=y(l.createSelector([mc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),Xh=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],fc=Fs.reducer,N=I(t=>t.offline_id),pc=N.getInitialState({}),Is=l.createSlice({name:"assetTypeFields",initialState:pc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pc)),reducers:{initializeAssetTypeFields:N.initialize,addAssetTypeFields:N.addOne,addAssetTypeFieldsMany:N.addMany,setAssetTypeFields:N.setOne,setAssetTypeFieldsMany:N.setMany,updateAssetTypeFields:N.updateOne,updateAssetTypeFieldsMany:N.updateMany,deleteAssetTypeFields:N.deleteOne,deleteAssetTypeFieldsMany:N.deleteMany}}),{initializeAssetTypeFields:Ac,addAssetTypeFields:yc,addAssetTypeFieldsMany:Zh,setAssetTypeFields:Qh,setAssetTypeFieldsMany:xh,updateAssetTypeFields:Sc,updateAssetTypeFieldsMany:em,deleteAssetTypeFields:gc,deleteAssetTypeFieldsMany:tm}=Is.actions,bc=t=>t.assetTypeFieldsReducer.instances,Xe=l.createSelector([bc],t=>Object.values(t)),sm=y(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),im=y(l.createSelector([Xe,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),nm=t=>e=>e.assetTypeFieldsReducer.instances[t],_c=Is.reducer,H=I(t=>t.offline_id),Tc=H.getInitialState({}),Rs=l.createSlice({name:"assetTypeFieldValuesAttachments",initialState:Tc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Tc)),reducers:{initializeAssetTypeFieldValuesAttachments:H.initialize,addAssetTypeFieldValuesAttachment:H.addOne,addAssetTypeFieldValuesAttachments:H.addMany,setAssetTypeFieldValuesAttachment:H.setOne,setAssetTypeFieldValuesAttachments:H.setMany,updateAssetTypeFieldValuesAttachment:H.updateOne,updateAssetTypeFieldValuesAttachments:H.updateMany,deleteAssetTypeFieldValuesAttachment:H.deleteOne,deleteAssetTypeFieldValuesAttachments:H.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:Fc,addAssetTypeFieldValuesAttachment:am,addAssetTypeFieldValuesAttachments:Ze,setAssetTypeFieldValuesAttachment:cm,setAssetTypeFieldValuesAttachments:rm,updateAssetTypeFieldValuesAttachment:om,updateAssetTypeFieldValuesAttachments:Ic,deleteAssetTypeFieldValuesAttachment:dm,deleteAssetTypeFieldValuesAttachments:Qe}=Rs.actions,Ps=t=>t.assetTypeFieldValuesAttachmentReducer.instances,Rc=l.createSelector([Ps],t=>Object.values(t)),lm=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],Pc=y(l.createSelector([Ps,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),Oc=y(l.createSelector([Rc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),vc=Rs.reducer,W=I(t=>t.offline_id),wc=W.getInitialState({}),Os=l.createSlice({name:"assetTypeFieldValues",initialState:wc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wc)),reducers:{initializeAssetTypeFieldValues:W.initialize,addAssetTypeFieldValues:W.addOne,addAssetTypeFieldValuesMany:W.addMany,setAssetTypeFieldValues:W.setOne,setAssetTypeFieldValuesMany:W.setMany,updateAssetTypeFieldValues:W.updateOne,updateAssetTypeFieldValuesMany:W.updateMany,deleteAssetTypeFieldValues:W.deleteOne,deleteAssetTypeFieldValuesMany:W.deleteMany}}),{initializeAssetTypeFieldValues:Ec,addAssetTypeFieldValues:vs,addAssetTypeFieldValuesMany:jc,setAssetTypeFieldValues:um,setAssetTypeFieldValuesMany:hm,updateAssetTypeFieldValues:ke,updateAssetTypeFieldValuesMany:qc,deleteAssetTypeFieldValues:ws,deleteAssetTypeFieldValuesMany:Mc}=Os.actions,kc=t=>t.assetTypeFieldValuesReducer.instances,Es=l.createSelector([kc],t=>Object.values(t)),mm=y(l.createSelector([Es,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),fm=y(l.createSelector([Xe,Es,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.asset_type===s).map(a=>a.offline_id));return S(e.filter(a=>n.has(a.fields_revision)))})),js=t=>e=>e.assetTypeFieldValuesReducer.instances[t],Dc=Os.reducer,K=I(t=>t.offline_id),zc=K.getInitialState({}),qs=l.createSlice({name:"assetTypes",initialState:zc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zc)),reducers:{initializeAssetTypes:K.initialize,setAssetType:K.setOne,setAssetTypes:K.setMany,addAssetType:K.addOne,addAssetTypes:K.addMany,updateAssetType:K.updateOne,updateAssetTypes:K.updateMany,deleteAssetType:K.deleteOne,deleteAssetTypes:K.deleteMany}}),{initializeAssetTypes:Vc,setAssetType:pm,setAssetTypes:Am,addAssetType:Ms,addAssetTypes:ym,updateAssetType:De,updateAssetTypes:Sm,deleteAssetType:ks,deleteAssetTypes:gm}=qs.actions,Ds=t=>t.assetTypeReducer.instances,bm=l.createSelector([Ds],t=>Object.values(t)),zs=t=>e=>e.assetTypeReducer.instances[t],_m=y(l.createSelector([Ds,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectAssetTypesByIds: No assetType exists with the id",n)}return S(s)})),Cc=qs.reducer,Uc={accessToken:"",refreshToken:"",isLoggedIn:!1},xe=l.createSlice({name:"auth",initialState:Uc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Uc)),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||xe.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Tm,clearTokens:Fm,setLoggedIn:$c}=xe.actions,Im=t=>t.authReducer.accessToken,Rm=t=>t.authReducer.isLoggedIn,Bc=xe.reducer,ze=I(t=>t.offline_id),Gc=ze.getInitialState({}),Vs=l.createSlice({name:"categories",initialState:Gc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Gc)),reducers:{initializeCategories:ze.initialize,addCategory:ze.addOne,updateCategory:ze.updateOne,deleteCategory:ze.deleteOne}}),{initializeCategories:Lc,addCategory:Cs,updateCategory:Nc,deleteCategory:Hc}=Vs.actions,Us=t=>t.categoryReducer.instances,Pm=l.createSelector([Us],t=>Object.values(t)),$s=t=>e=>e.categoryReducer.instances[t],Om=y(l.createSelector([Us,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectCategoryByIds: No category exists with the id",n)}return S(s)})),vm=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,Wc=Vs.reducer,Y=I(t=>t.offline_id),Kc=Y.getInitialState({}),Bs=l.createSlice({name:"documentAttachments",initialState:Kc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kc)),reducers:{initializeDocumentAttachments:Y.initialize,addDocumentAttachment:Y.addOne,addDocumentAttachments:Y.addMany,setDocumentAttachment:Y.setOne,setDocumentAttachments:Y.setMany,updateDocumentAttachment:Y.updateOne,updateDocumentAttachments:Y.updateMany,deleteDocumentAttachment:Y.deleteOne,deleteDocumentAttachments:Y.deleteMany}}),{initializeDocumentAttachments:Yc,addDocumentAttachment:wm,addDocumentAttachments:Jc,setDocumentAttachment:Xc,setDocumentAttachments:Em,updateDocumentAttachment:jm,updateDocumentAttachments:Zc,deleteDocumentAttachment:Qc,deleteDocumentAttachments:xc}=Bs.actions,er=t=>t.documentAttachmentReducer.instances,Gs=l.createSelector([er],t=>Object.values(t)),tr=t=>e=>e.documentAttachmentReducer.instances[t],qm=y(l.createSelector([Gs,(t,e)=>e],(t,e)=>S(t.filter(({document:s})=>e===s)))),Mm=y(l.createSelector([Gs,(t,e)=>e],(t,e)=>{const s=t.filter(({document:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),sr=Bs.reducer,ir={documents:{}},Ls=l.createSlice({name:"documents",initialState:ir,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,ir)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(kn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Mn(e.payload)},addDocuments:(t,e)=>{for(const s of e.payload)if(s.offline_id in t.documents)throw new Error(`attempting to add a document with offline_id ${s.offline_id} which already exists in state.documents.`);for(const s of e.payload){if(s.parent_document&&t.documents[s.parent_document]){const n=t.documents[s.parent_document];t.documents[s.parent_document]={...n,children_documents:[...n.children_documents,s.offline_id]}}t.documents[s.offline_id]=s}},updateDocuments:(t,e)=>{for(const s of e.payload)if(!(s.offline_id in t.documents))throw new Error(`attempting to update a document with offline_id ${s.offline_id} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s.offline_id];if(s.organization!==void 0&&s.organization!==n.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==n.project)throw new Error("project cannot be updated");t.documents[s.offline_id]={...n,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:n,position:a}=e.payload;if(!(s in t.documents))throw new Error(`attempting to move a document with offline_id ${s} which doesn't exist in state.documents`);const c=t.documents[s];if(c.parent_document&&t.documents[c.parent_document]){const{children_documents:r}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(r.indexOf(c.offline_id),1)}if(n){const r=t.documents[n],d=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(a){case"left":if(!d)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(d.children_documents.indexOf(r.offline_id),0,c.offline_id),t.documents[s].parent_document=d.offline_id;break;case"right":if(!d)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(d.children_documents.indexOf(r.offline_id)+1,0,c.offline_id),t.documents[s].parent_document=d.offline_id;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[n].children_documents.unshift(c.offline_id),t.documents[s].parent_document=r.offline_id;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[n].children_documents.push(c.offline_id),t.documents[s].parent_document=r.offline_id}}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 offline_id ${s} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s];if(n.parent_document&&t.documents[n.parent_document]){const a=t.documents[n.parent_document];t.documents[n.parent_document]={...a,children_documents:a.children_documents.filter(c=>c!==n.offline_id)}}delete t.documents[s]}}}}),{setDocuments:nr,addDocuments:Ns,updateDocuments:le,moveDocument:ar,removeDocuments:Hs}=Ls.actions,_e=t=>t.documentsReducer.documents,cr=l.createSelector([_e],t=>Object.values(t)),rr=t=>e=>e.documentsReducer.documents[t],km=y(l.createSelector([_e,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectDocumentByIds: No document exists with the id",n)}return S(s)})),Dm=y(l.createSelector([_e,(t,e)=>e],(t,e)=>{const s=[],n=t[e];if(!n||!n.parent_document)return s;let a=t[n.parent_document];for(;a;)s.push(a.offline_id),a=t[a.parent_document??""];return S(s)})),zm=l.createSelector([cr],t=>S(t.filter(e=>!e.parent_document))),or=Ls.reducer,et=I(t=>t.offline_id),Vm=et.getInitialState({}),Ws=l.createSlice({name:"emailDomains",initialState:Vm,reducers:{initializeEmailDomains:et.initialize,addEmailDomain:et.addOne,deleteEmailDomain:et.deleteOne}}),{initializeEmailDomains:dr,addEmailDomain:lr,deleteEmailDomain:ur}=Ws.actions,hr=t=>t.emailDomainsReducer.instances,mr=l.createSelector([hr],t=>Object.values(t)),Cm=y(l.createSelector([mr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),fr=Ws.reducer,pr={s3Urls:{}},Ar=1e3*60*60,Um=Ar*24*7,Ks=l.createSlice({name:"file",initialState:pr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pr)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:n,sha1:a}=e.payload,c=new Date,r=new Date(c.getTime()+Um);t.s3Urls[a]={url:s,fields:n,exp:r.getTime()}}}}),{setUploadUrl:yr}=Ks.actions,Sr=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<Ar))return s},gr=Ks.reducer,J=I(t=>t.offline_id),br=J.getInitialState({}),Ys=l.createSlice({name:"formRevisionAttachments",initialState:br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,br)),reducers:{initializeFormRevisionAttachments:J.initialize,addFormRevisionAttachment:J.addOne,addFormRevisionAttachments:J.addMany,setFormRevisionAttachment:J.setOne,setFormRevisionAttachments:J.setMany,updateFormRevisionAttachment:J.updateOne,updateFormRevisionAttachments:J.updateMany,deleteFormRevisionAttachment:J.deleteOne,deleteFormRevisionAttachments:J.deleteMany}}),{initializeFormRevisionAttachments:_r,addFormRevisionAttachment:$m,addFormRevisionAttachments:Tr,setFormRevisionAttachment:Bm,setFormRevisionAttachments:Gm,updateFormRevisionAttachment:Lm,updateFormRevisionAttachments:Fr,deleteFormRevisionAttachment:Nm,deleteFormRevisionAttachments:Ir}=Ys.actions,Rr=t=>t.formRevisionAttachmentReducer.instances,Hm=y(l.createSelector([Rr,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_revision===e)))),Pr=Ys.reducer,Wm=(t,e)=>{const s=t.revision,n=e.revision;return s==="Pending"&&n==="Pending"?t.submitted_at<e.submitted_at?-1:1:s==="Pending"?1:n==="Pending"||s<n?-1:1},ue=I(t=>t.offline_id),Or=ue.getInitialState({}),Js=l.createSlice({name:"formRevisions",initialState:Or,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Or)),reducers:{initializeFormRevisions:ue.initialize,setFormRevision:ue.setOne,addFormRevision:ue.addOne,addFormRevisions:ue.addMany,deleteFormRevision:ue.deleteOne,deleteFormRevisions:ue.deleteMany}}),{setFormRevision:vr,initializeFormRevisions:wr,addFormRevision:Xs,addFormRevisions:Er,deleteFormRevision:Zs,deleteFormRevisions:jr}=Js.actions,tt=t=>t.formRevisionReducer.instances,qr=l.createSelector([tt],t=>Object.values(t)),Km=t=>e=>e.formRevisionReducer.instances[t],Mr=(t,e)=>{let s=null;for(const n of Object.values(t))n.form===e&&(!s||s.revision<n.revision)&&(s=n);if(!s)throw new Error("No form revision found for form "+e);return s},Ym=y(l.createSelector([tt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(Wm)[s.length-1];return t[a.offline_id]})),kr=y(l.createSelector([qr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.form===e)))),Dr=Js.reducer,he=I(t=>t.offline_id),zr=he.getInitialState({}),Qs=l.createSlice({name:"forms",initialState:zr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zr)),reducers:{initializeForms:he.initialize,setForm:he.setOne,addForm:he.addOne,addForms:he.addMany,updateForm:he.updateOne,deleteForm:he.deleteOne}}),{initializeForms:Vr,setForm:Jm,addForm:xs,addForms:Xm,updateForm:Zm,deleteForm:ei}=Qs.actions,Cr=Qs.reducer,Ur=t=>t.formReducer.instances,Qm=l.createSelector([Ur],t=>Object.values(t)),$r=t=>e=>e.formReducer.instances[t],xm=y(l.createSelector([t=>t.formReducer.instances,t=>t.formRevisionReducer.instances,(t,e)=>e],(t,e,s)=>{const{searchTerm:n,maxResults:a,organization:c}=s,r=[];for(const[d,m]of Object.entries(t)){if(Number.isInteger(c)&&c!==m.organization)continue;Mr(e,d).title.toLowerCase().includes(n.toLowerCase())&&r.push(m)}return[...r.slice(0,a)]},{memoizeOptions:{resultEqualityCheck:vn}})),X=I(t=>t.offline_id),Br=X.getInitialState({}),ti=l.createSlice({name:"formSubmissionAttachments",initialState:Br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Br)),reducers:{initializeFormSubmissionAttachments:X.initialize,addFormSubmissionAttachment:X.addOne,addFormSubmissionAttachments:X.addMany,setFormSubmissionAttachment:X.setOne,setFormSubmissionAttachments:X.setMany,updateFormSubmissionAttachment:X.updateOne,updateFormSubmissionAttachments:X.updateMany,deleteFormSubmissionAttachment:X.deleteOne,deleteFormSubmissionAttachments:X.deleteMany}}),{initializeFormSubmissionAttachments:Gr,addFormSubmissionAttachment:ef,addFormSubmissionAttachments:st,setFormSubmissionAttachment:tf,setFormSubmissionAttachments:sf,updateFormSubmissionAttachment:nf,updateFormSubmissionAttachments:Lr,deleteFormSubmissionAttachment:af,deleteFormSubmissionAttachments:it}=ti.actions,si=t=>t.formSubmissionAttachmentReducer.instances,Nr=y(l.createSelector([si,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),Hr=y(l.createSelector([si,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_submission===e)))),Wr=ti.reducer,Z=I(t=>t.offline_id),Kr=Z.getInitialState({}),ii=l.createSlice({name:"formSubmissions",initialState:Kr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kr)),reducers:{initializeFormSubmissions:Z.initialize,setFormSubmission:Z.setOne,setFormSubmissions:Z.setMany,addFormSubmission:Z.addOne,addFormSubmissions:Z.addMany,updateFormSubmission:Z.updateOne,updateFormSubmissions:Z.updateMany,deleteFormSubmission:Z.deleteOne,deleteFormSubmissions:Z.deleteMany}}),{initializeFormSubmissions:Yr,setFormSubmission:nt,setFormSubmissions:cf,addFormSubmission:ni,addFormSubmissions:at,updateFormSubmission:Jr,updateFormSubmissions:rf,deleteFormSubmission:ai,deleteFormSubmissions:ct}=ii.actions,ci=t=>t.formSubmissionReducer.instances,ri=l.createSelector([ci],t=>Object.values(t)),oi=t=>e=>e.formSubmissionReducer.instances[t],Xr=y(l.createSelector([ci,tt,(t,e)=>e],(t,e,s)=>{const n=new Set;for(const a of Object.values(e))a.form===s&&n.add(a.offline_id);return Object.values(t).filter(a=>n.has(a.form_revision))})),Zr=y(l.createSelector([ri,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),Qr=y(l.createSelector([ri,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),xr=ii.reducer,Q=I(t=>t.offline_id),eo=Q.getInitialState({}),di=l.createSlice({name:"geoImages",initialState:eo,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,eo)})},reducers:{initializeGeoImages:Q.initialize,setGeoImage:Q.setOne,setGeoImages:Q.setMany,addGeoImage:Q.addOne,addGeoImages:Q.addMany,updateGeoImage:Q.updateOne,updateGeoImages:Q.updateMany,deleteGeoImage:Q.deleteOne,deleteGeoImages:Q.deleteMany}}),{initializeGeoImages:to,setGeoImage:Ve,setGeoImages:so,addGeoImage:io,addGeoImages:no,updateGeoImage:ao,updateGeoImages:of,deleteGeoImage:li,deleteGeoImages:co}=di.actions,ro=t=>t.geoImageReducer.instances,oo=l.createSelector([ro],t=>Object.values(t)),ui=t=>e=>e.geoImageReducer.instances[t],df=y(l.createSelector([oo,(t,e)=>e],(t,e)=>S(t.filter(s=>s.project===e)))),lo=di.reducer,x=I(t=>t.offline_id),uo=x.getInitialState({}),hi=l.createSlice({name:"issueAssociations",initialState:uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uo)),reducers:{initializeIssueAssociations:x.initialize,addIssueAssociation:x.addOne,addIssueAssociations:x.addMany,setIssueAssociation:x.setOne,setIssueAssociations:x.setMany,updateIssueAssociation:x.updateOne,updateIssueAssociations:x.updateMany,deleteIssueAssociation:x.deleteOne,deleteIssueAssociations:x.deleteMany}}),{initializeIssueAssociations:ho,setIssueAssociations:lf,setIssueAssociation:uf,updateIssueAssociation:mo,updateIssueAssociations:hf,addIssueAssociation:mi,addIssueAssociations:fi,deleteIssueAssociation:pi,deleteIssueAssociations:Ai}=hi.actions,Ce=t=>t.issueAssociationReducer.instances,mf=l.createSelector([Ce],t=>Object.values(t)),fo=t=>e=>e.issueAssociationReducer.instances[t],po=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.associated_issue===e)))),Ao=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),yo=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.asset===e)))),So=hi.reducer,ee=I(t=>t.offline_id),go=ee.getInitialState({}),yi=l.createSlice({name:"issueAttachments",initialState:go,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,go)),reducers:{initializeIssueAttachments:ee.initialize,addIssueAttachment:ee.addOne,addIssueAttachments:ee.addMany,setIssueAttachment:ee.setOne,setIssueAttachments:ee.setMany,updateIssueAttachment:ee.updateOne,updateIssueAttachments:ee.updateMany,deleteIssueAttachment:ee.deleteOne,deleteIssueAttachments:ee.deleteMany}}),{initializeIssueAttachments:bo,addIssueAttachment:ff,addIssueAttachments:Si,setIssueAttachment:_o,setIssueAttachments:pf,updateIssueAttachment:Af,updateIssueAttachments:To,deleteIssueAttachment:Fo,deleteIssueAttachments:gi}=yi.actions,Io=t=>t.issueAttachmentReducer.instances,bi=l.createSelector([Io],t=>Object.values(t)),Ro=y(l.createSelector([bi,(t,e)=>e],(t,e)=>S(t.filter(({issue:s})=>e===s)))),Po=t=>e=>e.issueAttachmentReducer.instances[t],yf=y(l.createSelector([bi,(t,e)=>e],(t,e)=>{const s=t.filter(({issue:c})=>c===e),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Oo=yi.reducer,me=I(t=>t.offline_id),vo=me.getInitialState({}),_i=l.createSlice({name:"issueComments",initialState:vo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vo)),reducers:{addIssueComment:me.addOne,addIssueComments:me.addMany,setIssueComment:me.setOne,setIssueComments:me.setMany,deleteIssueComment:me.deleteOne,deleteIssueComments:me.deleteMany}}),{setIssueComments:wo,setIssueComment:Ti,addIssueComment:Fi,addIssueComments:Sf,deleteIssueComment:Ii,deleteIssueComments:gf}=_i.actions,Eo=t=>t.issueCommentReducer.instances,jo=t=>e=>e.issueCommentReducer.instances[t],bf=y(l.createSelector([Eo,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),qo=_i.reducer,fe=I(t=>t.offline_id),Mo=fe.getInitialState({}),Ri=l.createSlice({name:"issues",initialState:Mo,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Mo)}),reducers:{initializeIssues:fe.initialize,addIssue:fe.addOne,addIssues:fe.addMany,updateIssue:fe.updateOne,deleteIssue:fe.deleteOne,deleteIssues:fe.deleteMany}}),{initializeIssues:ko,addIssue:Pi,addIssues:Do,updateIssue:rt,deleteIssue:Oi,deleteIssues:zo}=Ri.actions,Vo=t=>t.issueReducer.instances,vi=t=>e=>e.issueReducer.instances[t],_f=y(l.createSelector([Vo,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectIssuesByIds: No issue exists with the id",n)}return S(s)})),Co=Ri.reducer,te=I(t=>t.offline_id),Uo=te.getInitialState({}),wi=l.createSlice({name:"issueTypeFieldsAttachments",initialState:Uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Uo)),reducers:{initializeIssueTypeFieldsAttachments:te.initialize,addIssueTypeFieldsAttachment:te.addOne,addIssueTypeFieldsAttachments:te.addMany,setIssueTypeFieldsAttachment:te.setOne,setIssueTypeFieldsAttachments:te.setMany,updateIssueTypeFieldsAttachment:te.updateOne,updateIssueTypeFieldsAttachments:te.updateMany,deleteIssueTypeFieldsAttachment:te.deleteOne,deleteIssueTypeFieldsAttachments:te.deleteMany}}),{initializeIssueTypeFieldsAttachments:$o,addIssueTypeFieldsAttachment:Tf,addIssueTypeFieldsAttachments:Bo,setIssueTypeFieldsAttachment:Ff,setIssueTypeFieldsAttachments:If,updateIssueTypeFieldsAttachment:Rf,updateIssueTypeFieldsAttachments:Go,deleteIssueTypeFieldsAttachment:Pf,deleteIssueTypeFieldsAttachments:Lo}=wi.actions,No=t=>t.issueTypeFieldsAttachmentReducer.instances,Ho=l.createSelector([No],t=>Object.values(t)),Of=y(l.createSelector([Ho,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),vf=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],Wo=wi.reducer,se=I(t=>t.offline_id),Ko=se.getInitialState({}),Ei=l.createSlice({name:"issueTypeFieldValues",initialState:Ko,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ko)),reducers:{initializeIssueTypeFieldValues:se.initialize,addIssueTypeFieldValues:se.addOne,addIssueTypeFieldValuesMany:se.addMany,setIssueTypeFieldValues:se.setOne,setIssueTypeFieldValuesMany:se.setMany,updateIssueTypeFieldValues:se.updateOne,updateIssueTypeFieldValuesMany:se.updateMany,deleteIssueTypeFieldValues:se.deleteOne,deleteIssueTypeFieldValuesMany:se.deleteMany}}),{initializeIssueTypeFieldValues:Yo,addIssueTypeFieldValues:ji,addIssueTypeFieldValuesMany:wf,setIssueTypeFieldValues:Ef,setIssueTypeFieldValuesMany:jf,updateIssueTypeFieldValues:Ue,updateIssueTypeFieldValuesMany:qf,deleteIssueTypeFieldValues:qi,deleteIssueTypeFieldValuesMany:Mf}=Ei.actions,Jo=t=>t.issueTypeFieldValuesReducer.instances,Mi=l.createSelector([Jo],t=>Object.values(t)),kf=y(l.createSelector([Mi,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue===e)))),ki=t=>e=>e.issueTypeFieldValuesReducer.instances[t],Xo=Ei.reducer,ie=I(t=>t.offline_id),Zo=ie.getInitialState({}),Di=l.createSlice({name:"issueTypeFields",initialState:Zo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zo)),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:Df,setIssueTypeFields:zf,setIssueTypeFieldsMany:Vf,updateIssueTypeFields:ed,updateIssueTypeFieldsMany:Cf,deleteIssueTypeFields:td,deleteIssueTypeFieldsMany:Uf}=Di.actions,sd=t=>t.issueTypeFieldsReducer.instances,ot=l.createSelector([sd],t=>Object.values(t)),$f=y(l.createSelector([ot,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue_type===e)))),Bf=y(l.createSelector([ot,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Gf=y(l.createSelector([ot,Mi,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.issue_type===s).map(a=>a.offline_id));return S(e.filter(a=>n.has(a.fields_revision)))})),Lf=t=>e=>e.issueTypeFieldsReducer.instances[t],id=Di.reducer,ne=I(t=>t.offline_id),nd=ne.getInitialState({}),zi=l.createSlice({name:"issueTypeFieldValuesAttachments",initialState:nd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,nd)),reducers:{initializeIssueTypeFieldValuesAttachments:ne.initialize,addIssueTypeFieldValuesAttachment:ne.addOne,addIssueTypeFieldValuesAttachments:ne.addMany,setIssueTypeFieldValuesAttachment:ne.setOne,setIssueTypeFieldValuesAttachments:ne.setMany,updateIssueTypeFieldValuesAttachment:ne.updateOne,updateIssueTypeFieldValuesAttachments:ne.updateMany,deleteIssueTypeFieldValuesAttachment:ne.deleteOne,deleteIssueTypeFieldValuesAttachments:ne.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:ad,addIssueTypeFieldValuesAttachment:Nf,addIssueTypeFieldValuesAttachments:dt,setIssueTypeFieldValuesAttachment:Hf,setIssueTypeFieldValuesAttachments:Wf,updateIssueTypeFieldValuesAttachment:Kf,updateIssueTypeFieldValuesAttachments:cd,deleteIssueTypeFieldValuesAttachment:Yf,deleteIssueTypeFieldValuesAttachments:lt}=zi.actions,Vi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,rd=l.createSelector([Vi],t=>Object.values(t)),Jf=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],od=y(l.createSelector([Vi,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),dd=y(l.createSelector([rd,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),ld=zi.reducer,Te=I(t=>t.offline_id),ud=Te.getInitialState({}),Ci=l.createSlice({name:"issueTypes",initialState:ud,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,ud)}),reducers:{initializeIssueTypes:Te.initialize,setIssueType:Te.setOne,addIssueType:Te.addOne,updateIssueType:Te.updateOne,removeIssueType:Te.deleteOne}}),{initializeIssueTypes:hd,setIssueType:$e,addIssueType:md,updateIssueType:fd,removeIssueType:Ui}=Ci.actions,pd=t=>t.issueTypeReducer.instances,Ad=l.createSelector(pd,t=>Object.values(t)),$i=t=>e=>e.issueTypeReducer.instances[t],Xf=t=>e=>{const s=[];for(const n of t){const a=e.issueTypeReducer.instances[n];a?s.push(a):console.warn("selectIssueTypesByIds: No issue type exists with the id",n)}return s},Zf=y(l.createSelector([Ad,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),Bi=y(l.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue_type===e)))),Qf=t=>e=>Bi(t)(e).length,yd=Ci.reducer,pe=I(t=>t.offline_id),Sd=pe.getInitialState({}),Gi=l.createSlice({name:"issueUpdates",initialState:Sd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sd)),reducers:{initializeIssueUpdates:pe.setMany,setIssueUpdate:pe.setOne,addIssueUpdate:pe.addOne,addIssueUpdates:pe.addMany,deleteIssueUpdate:pe.deleteOne,deleteIssueUpdates:pe.deleteMany}}),{initializeIssueUpdates:gd,setIssueUpdate:xf,addIssueUpdate:bd,addIssueUpdates:_d,deleteIssueUpdate:Td,deleteIssueUpdates:Fd}=Gi.actions,Id=t=>t.issueUpdateReducer.instances,Rd=y(l.createSelector([Id,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),Pd=Gi.reducer,ut=I(t=>t.offline_id),Od=ut.getInitialState({}),Li=l.createSlice({name:"license",initialState:Od,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Od)),reducers:{initializeLicences:ut.initialize,addLicenses:ut.addMany,updateLicense:ut.updateOne}}),{initializeLicences:vd,addLicenses:ep,updateLicense:oe}=Li.actions,ht=t=>t.licenseReducer.instances,tp=t=>e=>e.licenseReducer.instances[t],wd=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),sp=l.createSelector([ht],t=>S(Object.values(t).filter(e=>e.is_active))),ip=l.createSelector([ht],t=>ge(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),Ed=Li.reducer,jd={users:{},currentUser:null},Ni=l.createSlice({name:"users",initialState:jd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jd)),reducers:{setUsers:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.users=s},addUsers:(t,e)=>{for(const s of e.payload)t.users[s.id]=s},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.users[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},removeUser:(t,e)=>{delete t.users[e.payload]}}}),{setCurrentUser:np,setProfilePicture:ap,setUsers:qd,addUsers:cp,removeUser:Md}=Ni.actions,kd=Ni.reducer,mt=t=>t.userReducer.currentUser,ft=t=>t.userReducer.users,rp=t=>e=>e.userReducer.users[t],op=y(l.createSelector([ft,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectUsersByIds: No user exists with the id",n)}return S(s)})),pt=I(t=>t.offline_id),Dd=pt.getInitialState({}),Hi=l.createSlice({name:"organizationAccess",initialState:Dd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dd)),reducers:{initializeOrganizationAccesses:pt.initialize,updateOrganizationAccess:pt.updateOne,deleteOrganizationAccess:pt.deleteOne}}),{initializeOrganizationAccesses:zd,updateOrganizationAccess:Vd,deleteOrganizationAccess:Cd}=Hi.actions,Wi=t=>t.organizationAccessReducer.instances,dp=t=>e=>e.organizationAccessReducer.instances[t],lp=l.createSelector([mt,Wi],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.id))??null),up=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),Ud=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return ge(e)},$d=Hi.reducer,Be=I(t=>t.offline_id),Bd=Be.getInitialState({}),Ki=l.createSlice({name:"projectAccess",initialState:Bd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bd)),reducers:{initializeProjectAccesses:Be.initialize,updateProjectAccess:Be.updateOne,deleteProjectAccess:Be.deleteOne,deleteProjectAccesses:Be.deleteMany}}),{initializeProjectAccesses:Yi,updateProjectAccess:Gd,deleteProjectAccess:Ld,deleteProjectAccesses:Nd}=Ki.actions,Ji=t=>t.projectAccessReducer.instances,Hd=l.createSelector(Ji,t=>Object.values(t)),hp=t=>e=>e.projectAccessReducer.instances[t],mp=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),Wd=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return ge(e)},Kd=Ki.reducer,Yd={projects:{}},Xi=l.createSlice({name:"projects",initialState:Yd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yd)),reducers:{setProjects:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.projects=s},updateProject:(t,e)=>{t.projects[e.payload.id]=e.payload},deleteProject:(t,e)=>{delete t.projects[e.payload.id]},acceptProjectInvite:(t,e)=>{if(e.payload in t.projects)t.projects[e.payload].invited=!1;else throw new Error("Accept project invite: user is not in this project")}}}),{setProjects:Jd,updateProject:Xd,deleteProject:Zd,acceptProjectInvite:Qd}=Xi.actions,xd=Xi.reducer,Zi=t=>t.projectReducer.projects,fp=t=>e=>e.projectReducer.projects[t],el=l.createSelector([Ji],t=>Object.values(t).map(e=>e.user)),tl=l.createSelector([el,ft],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),pp=l.createSelector([mt,tl,Wd],(t,e,s)=>S(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===gt.ADMIN?-1:1}))),sl={organizations:{}},Qi=l.createSlice({name:"organizations",initialState:sl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sl)),reducers:{setOrganizations:(t,e)=>{for(const s of e.payload)t.organizations[s.id]=s}}}),{setOrganizations:il}=Qi.actions,nl=t=>t.organizationReducer.organizations,al=l.createSelector([nl],t=>Object.values(t)),Ap=t=>e=>e.organizationReducer.organizations[t],yp=l.createSelector([al],t=>S(Object.values(t).filter(e=>e.has_access))),cl=l.createSelector([Wi],t=>Object.values(t).map(e=>e.user)),Sp=y(l.createSelector([Zi,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),gp=y(l.createSelector([ht,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),rl=l.createSelector([cl,ft],(t,e)=>ge(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),bp=l.createSelector([mt,rl,Ud],(t,e,s)=>S(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===bt.ADMIN?-1:1}))),ol=Qi.reducer,dl=(t,e,s)=>{const n=t.uuid?t:{...t,uuid:O.v4()};return{payload:n,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:n,BASE_URL:e,serviceName:s}}}}},ll={deletedRequests:[],latestRetryTime:0},xi=l.createSlice({name:"outbox",initialState:ll,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ll)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return dl(n,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}}}),_p=t=>t.outboxReducer.deletedRequests,Tp=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:ul,markForDeletion:Fp,markAsDeleted:hl,_setLatestRetryTime:ml}=xi.actions,fl=xi.reducer,ae=I(t=>t.offline_id),pl=ae.getInitialState({}),en=l.createSlice({name:"projectAttachments",initialState:pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pl)),reducers:{initializeProjectAttachments:ae.initialize,addProjectAttachment:ae.addOne,addProjectAttachments:ae.addMany,setProjectAttachment:ae.setOne,setProjectAttachments:ae.setMany,updateProjectAttachment:ae.updateOne,updateProjectAttachments:ae.updateMany,deleteProjectAttachment:ae.deleteOne,deleteProjectAttachments:ae.deleteMany}}),{initializeProjectAttachments:Al,addProjectAttachment:Ip,addProjectAttachments:yl,setProjectAttachment:Sl,setProjectAttachments:gl,updateProjectAttachment:Rp,updateProjectAttachments:bl,deleteProjectAttachment:_l,deleteProjectAttachments:tn}=en.actions,Tl=t=>t.projectAttachmentReducer.instances,sn=l.createSelector([Tl],t=>Object.values(t)),Fl=t=>e=>e.projectAttachmentReducer.instances[t],Il=y(l.createSelector([sn,(t,e)=>e],(t,e)=>S(t.filter(({project:s})=>e===s)))),Pp=y(l.createSelector([sn,(t,e)=>e],(t,e)=>{const s=t.filter(({project:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Rl=en.reducer,ce=I(t=>t.offline_id),Pl=ce.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),nn=l.createSlice({name:"projectFiles",initialState:Pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pl)),reducers:{initializeProjectFiles:ce.initialize,setProjectFile:ce.setOne,setProjectFiles:ce.setMany,addProjectFile:ce.addOne,addProjectFiles:ce.addMany,updateProjectFile:ce.updateOne,updateProjectFiles:ce.updateMany,deleteProjectFile:ce.deleteOne,deleteProjectFiles:ce.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:Ol,setProjectFile:Op,setProjectFiles:vp,addProjectFile:wp,addProjectFiles:vl,updateProjectFile:an,updateProjectFiles:Ep,deleteProjectFile:wl,deleteProjectFiles:El,setIsImportingProjectFile:jl,setActiveProjectFileId:ql,saveActiveProjectFileBounds:Ml,resetProjectFileObjectUrls:jp}=nn.actions,kl=t=>t.projectFileReducer.instances,Dl=l.createSelector([kl],t=>S(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),qp=t=>e=>e.projectFileReducer.instances[t],Mp=t=>t.projectFileReducer.activeProjectFileId,kp=t=>t.projectFileReducer.isImportingProjectFile,zl=nn.reducer,Dp={isRehydrated:!1},cn=l.createSlice({name:"rehydrated",initialState:Dp,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:zp}=cn.actions,Vp=t=>t.rehydratedReducer.isRehydrated,Vl=cn.reducer,Fe=I(t=>t.offline_id),Cl=Fe.getInitialState({}),rn=l.createSlice({name:"teams",initialState:Cl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Cl)),reducers:{setTeam:Fe.setOne,initializeTeams:Fe.initialize,addTeam:Fe.addOne,updateTeam:Fe.updateOne,deleteTeam:Fe.deleteOne}}),{setTeam:Ie,initializeTeams:Ul,addTeam:$l,updateTeam:on,deleteTeam:dn}=rn.actions,ln=t=>t.teamReducer.instances,un=l.createSelector([ln],t=>Object.values(t)),Re=t=>e=>e.teamReducer.instances[t],Cp=y(l.createSelector([ln,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectTeamsByIds: No team exists with the id",n)}return S(s)})),Up=y(l.createSelector([un,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),$p=y(l.createSelector([un,(t,e)=>e],(t,e)=>S(t.filter(s=>s.members.includes(e))))),Bl=rn.reducer,Bp={version:0},Gl=l.createSlice({name:"versioning",initialState:Bp,reducers:{}}),Ll=Gl.reducer;let Nl;function Gp(t){Nl=t}function Ge(){return Nl}let Hl;function Lp(t){Hl=t}function Np(){return Hl}const Wl={};class Kl{constructor(e){g(this,"client");Wl[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 Yl="versioning",Jl=()=>Ql.length-1,Xl=t=>(t[Yl]={version:Jl()},t),Zl=()=>Xl({}),Hp=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Wp=t=>e=>{var s;return e===void 0&&(e={}),((s=e[Yl])==null?void 0:s.version)===Jl()?e:t(e)},Ql=[Xl,Zl,Zl,Hp],Kp=Object.fromEntries(Ql.map((t,e)=>[e,Wp(t)])),hn="versioning",xl={[hn]:Ll,fileReducer:gr,authReducer:Bc,categoryReducer:Wc,assetReducer:Ca,assetAttachmentReducer:Yn,assetStageCompletionReducer:La,assetStageReducer:Ja,assetTypeReducer:Cc,assetTypeAttachmentReducer:cc,issueReducer:Co,issueAttachmentReducer:Oo,issueTypeReducer:yd,organizationReducer:ol,outboxReducer:fl,projectReducer:xd,projectAttachmentReducer:Rl,projectAccessReducer:Kd,organizationAccessReducer:$d,projectFileReducer:zl,rehydratedReducer:Vl,formReducer:Cr,formRevisionReducer:Dr,formRevisionAttachmentReducer:Pr,formSubmissionAttachmentReducer:Wr,formSubmissionReducer:xr,userReducer:kd,emailDomainsReducer:fr,licenseReducer:Ed,documentsReducer:or,documentAttachmentReducer:sr,teamReducer:Bl,agentsReducer:$n,issueCommentReducer:qo,issueUpdateReducer:Pd,geoImageReducer:lo,issueAssociationReducer:So,issueTypeFieldsReducer:id,issueTypeFieldValuesReducer:Xo,issueTypeFieldsAttachmentReducer:Wo,issueTypeFieldValuesAttachmentReducer:ld,assetTypeFieldsReducer:_c,assetTypeFieldValuesReducer:Dc,assetTypeFieldsAttachmentReducer:fc,assetTypeFieldValuesAttachmentReducer:vc,assetProcedureReducer:Ma,assetProcedureInstanceReducer:wa,assetProcedureFieldsReducer:da,assetProcedureFieldValuesReducer:Fa,assetProcedureFieldsAttachmentReducer:sa,assetProcedureFieldValuesAttachmentReducer:Aa},eu=l.combineReducers(xl),tu="RESET",Yp=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?eu(void 0,e):eu(t,e);let mn=null;function Ae(){const t=Ge();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(mn)return mn;const e=t.getState().offline.outbox,s=Oe._fromOutbox(e);return mn=s,s}const Jp=t=>{if(t)throw t;const e=Ge();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},su=(t,e,s)=>{const n=Ae();return n?(n.addRequest(e),n.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},iu=(t,e,s)=>{const n=Ae();if(!n)return console.warn("Outbox coordinator not set; cannot dequeue request yet."),[];const c=e.meta.offlineAction.payload.uuid;return n.remove(c),n.getQueue()};async function Xp(t,e){if(!e.payload)throw new Error("Received empty payload");return aA(e)}const Zp={...gn,effect:Xp,discard:pn,returnPromises:!0,persistCallback:Jp,retry:rA,persistOptions:{storage:uu},queue:{...gn.queue,enqueue:su,dequeue:iu,peek:(...t)=>cA(...t)}},Qp=hu(Kp,hn),xp=l.compose(lu.offline(Zp),Qp);function eA(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(a=>a 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 fn(t,e){const s=Wl[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const n=s instanceof R;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");n&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const c={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:d,headers:m,method:o,queryParams:h,attachmentHash:f,isExternalUrl:p,isAuthNeeded:A,isResponseBlob:_}={...c,...r.request},T=r.request;let b=T.url;const P=f?await e.files.fetchCache(f):void 0;if(f&&!P)throw new Error(`Cannot upload file ${f} because it's not cached.`);!p&&!b.startsWith("http")&&(!b.startsWith("/")&&!b.startsWith("blob:")&&(b="/"+b),b=t.meta.offline.effect.BASE_URL+b);const q=w=>{if(f){const re=T.s3url;if(!re)throw new Error(`No S3 URL for file ${f}`);if("warning"in re)throw new Error(`S3 URL warning for file ${f}`);if(!P)throw new Error(`No file for file ${f}`);const He=re.fields["x-amz-checksum-sha1"];if(!He)throw new Error(`No checksum for file ${f}`);return w.set("x-amz-checksum-sha1",He).field({...d,...re.fields}).attach("file",P)}return w.send(d)},my={[u.GET]:()=>_?Se.get(b.toString()).responseType("blob"):Se.get(b.toString()),[u.POST]:()=>{const w=Se.post(b.toString());return q(w)},[u.PATCH]:()=>{const w=Se.patch(b.toString());return q(w)},[u.PUT]:()=>{const w=Se.put(b.toString());return q(w)},[u.DELETE]:()=>{const w=Se.delete(b.toString());return q(w)}}[o];let ye=my();if(A&&n){const w=s.auth.getAuthHeader();ye=ye.set("Authorization",w)}m&&(ye=ye.set(m));try{return await ye.query(h)}catch(w){const re=eA(w),He=re==null?void 0:re.status;if(n&&He===401)return await s.auth.handleUnauthorized(ye,re),ye.query(h);throw new j({response:re,innerError:w,discard:au.includes(He)})}}class tA{constructor(e){g(this,"_all");g(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 nu{constructor(){g(this,"next");this.next=null}then(e){return new tA(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!Ge())throw new Error("Client store not set");const n=Np();if(!n)throw new Error("Client SDK not set");return fn(e,n)}}}class sA extends nu{async run(e){return super.run(e)}}class iA extends nu{async run(e){return super.run(e)}}const nA=new sA().then(new iA).compile();function aA(t){var e;return(e=nA[0])==null?void 0:e.run(t)}const au=[400,409,403,404,405,500];function pn(t,e,s=0){var o;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
1
+ (function(i,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("uuid"),require("@reduxjs/toolkit"),require("file-saver"),require("@redux-offline/redux-offline"),require("@redux-offline/redux-offline/lib/defaults"),require("localforage"),require("redux-persist-migrate"),require("superagent"),require("dependency-graph"),require("idb"),require("@redux-offline/redux-offline/lib/constants"),require("jwt-decode")):typeof define=="function"&&define.amd?define(["exports","uuid","@reduxjs/toolkit","file-saver","@redux-offline/redux-offline","@redux-offline/redux-offline/lib/defaults","localforage","redux-persist-migrate","superagent","dependency-graph","idb","@redux-offline/redux-offline/lib/constants","jwt-decode"],O):(i=typeof globalThis<"u"?globalThis:i||self,O(i["overmap-core"]={},i.uuid,i.toolkit,i.fileSaver,i.reduxOffline,i.offlineConfig,i.localforage,i.createMigration,i.request,i.dependencyGraph,i.idb,i.constants,i.jwtDecode))})(this,function(i,O,u,Cu,Du,Tn,zu,Vu,_e,Uu,$u,Bu,Gu){"use strict";var Wy=Object.defineProperty;var Ky=(i,O,u)=>O in i?Wy(i,O,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[O]=u;var y=(i,O,u)=>Ky(i,typeof O!="symbol"?O+"":O,u);var ku;const _n=Object.freeze([]),Fn=Object.freeze({});var Ft=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(Ft||{}),It=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(It||{}),l=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(l||{}),In=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(In||{}),Rt=(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))(Rt||{}),Pt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Pt||{}),w=(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))(w||{}),Rn=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Rn||{}),Pn=(t=>(t[t.PRO=0]="PRO",t))(Pn||{}),On=(t=>(t[t.ACTIVE=0]="ACTIVE",t[t.PAUSED=2]="PAUSED",t[t.CANCELLED=4]="CANCELLED",t[t.INACTIVE=6]="INACTIVE",t[t.PAST_DUE=8]="PAST_DUE",t))(On||{});const Lu=Pt.BACKLOG,Nu=Rt.MEDIUM,vn=6e4;function I(t){return{addOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},addMany:(f,p)=>{for(const A of p.payload){const T=t(A);f.instances[T]=A}},setOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},setMany:(f,p)=>{for(const A of p.payload){const T=t(A);f.instances[T]=A}},updateOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},updateMany:(f,p)=>{for(const A of p.payload){const T=t(A);f.instances[T]=A}},deleteOne:(f,p)=>{delete f.instances[p.payload]},deleteMany:(f,p)=>{for(const A of p.payload)delete f.instances[A]},initialize:(f,p)=>{f.instances={};for(const A of p.payload){const T=t(A);f.instances[T]=A}},getInitialState:f=>({...f,instances:{}})}}ku=Symbol.toStringTag;class wn{constructor(){y(this,ku,"Promise");y(this,"_promise");y(this,"_resolve");y(this,"_reject");y(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 Hu=t=>({type:"Point",coordinates:t}),Wu=t=>({type:"MultiPoint",coordinates:t}),Ku=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Ot=!1;["true","1"].includes("".toLowerCase())&&(Ot=!0);function Yu(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;const s=Object.keys(t),n=Object.keys(e),a=s.length;if(a!==n.length)return!1;for(let c=0;c<a;c++){const r=s[c];if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1}return!0}function vt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Ot&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Ot&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Ju(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?_n:t,Fe=t=>Object.keys(t).length===0?Fn:t,En=vt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===wt.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),Xu=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),Qu=1e3*86400,wt=new Date,Zu=t=>new Date(t).toDateString()===wt.toDateString(),xu=vt((t,e,s)=>{const n=Math.round((new Date(t).getTime()-wt.getTime())/Qu);return n<e||n>s?En(t):Xu.format(n,"days")});function eh(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const Et=async(t,e)=>{e||(e=await Ie(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 Ie(t){return new Promise((e,s)=>{const n=new FileReader;n.onload=()=>{const a=n.result;if(!a){s(new Error("FileReader did not return a valid ArrayBuffer."));return}crypto.subtle.digest("SHA-1",a).then(c=>{const r=eh(c);e(r)})},n.readAsArrayBuffer(t)})}function th(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 jn(t,e){return new File([t],e,{type:t.type})}function sh(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 ih=async t=>{const e={};for(const s of t){const n=await Ie(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},qn=async t=>(await fetch(t)).blob(),nh=t=>new Promise((e,s)=>{const n=new FileReader;n.onloadend=()=>{var a;e(((a=n.result)==null?void 0:a.toString())||"")},n.readAsDataURL(t)});function ah(t){const e=new Blob([t]);Cu.saveAs(e,t.name)}const Mn={};function ch(t,e,s,...n){const a=Mn[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(Mn[t]={[e]:!0},c=!0),c&&console[s](...n)}const kn=["created_at","updated_at","index","revision"];function F(t){return{...t,offline_id:O.v4()}}function Cn(t){const e={};for(const s of t)e[s.offline_id]=s;return e}function rh(t,e=void 0,s=255){let n=t.replace(/[^a-z0-9_\-.]/gi,"_").replace(/_{2,}/g,"_");if(!e){const c=t.split(".");c.length>1&&(e=c[c.length-1])}e&&!e.startsWith(".")&&(e="."+e);const a=e?e.length:0;return n.length+a>s&&(n=n.slice(0,s-a)+(e||"")),n}function dh(t){return t.toLowerCase().replace(" ","-")}function oh(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function lh(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const S=t=>e=>s=>t(s,e);function Dn(t,e,s){return s.findIndex(n=>n.offline_id===t.offline_id)===e}function uh(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const hh=/^.+@.+\..+$/;function v(t){const e={...t};for(const s of kn)s in e&&delete e[s];return e}const Me=I(t=>t.offline_id),zn=Me.getInitialState({}),jt=u.createSlice({name:"agents",initialState:zn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zn)),reducers:{initializeConversations:Me.initialize,addConversation:Me.addOne,setConversation:Me.setOne,updateConversation:Me.updateOne}}),{initializeConversations:Vn,addConversation:Un,setConversation:$n,updateConversation:Bn}=jt.actions,qt=t=>t.agentsReducer.instances,mh=u.createSelector([qt],t=>Object.values(t)),fh=S(u.createSelector([qt,(t,e)=>e],(t,e)=>t[e])),Gn=jt.reducer,k=I(t=>t.offline_id),Ln=k.getInitialState({}),Mt=u.createSlice({name:"assetAttachments",initialState:Ln,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ln)),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:kt,addAssetAttachment:ph,addAssetAttachments:Ct,setAssetAttachment:Nn,setAssetAttachments:Ah,updateAssetAttachment:yh,updateAssetAttachments:Hn,deleteAssetAttachment:Wn,deleteAssetAttachments:Dt}=Mt.actions,Kn=t=>t.assetAttachmentReducer.instances,Yn=u.createSelector([Kn],t=>Object.values(t)),Jn=t=>e=>e.assetAttachmentReducer.instances[t],Xn=S(u.createSelector([Yn,(t,e)=>e],(t,e)=>g(t.filter(({asset:s})=>e===s)))),Qn=Mt.reducer,C=I(t=>t.offline_id),Zn=C.getInitialState({}),zt=u.createSlice({name:"assetProcedureFieldsAttachments",initialState:Zn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zn)),reducers:{initializeAssetProcedureFieldsAttachments:C.initialize,addAssetProcedureFieldsAttachment:C.addOne,addAssetProcedureFieldsAttachments:C.addMany,setAssetProcedureFieldsAttachment:C.setOne,setAssetProcedureFieldsAttachments:C.setMany,updateAssetProcedureFieldsAttachment:C.updateOne,updateAssetProcedureFieldsAttachments:C.updateMany,deleteAssetProcedureFieldsAttachment:C.deleteOne,deleteAssetProcedureFieldsAttachments:C.deleteMany}}),{initializeAssetProcedureFieldsAttachments:xn,addAssetProcedureFieldsAttachment:Sh,addAssetProcedureFieldsAttachments:ea,setAssetProcedureFieldsAttachment:gh,setAssetProcedureFieldsAttachments:bh,updateAssetProcedureFieldsAttachment:Th,updateAssetProcedureFieldsAttachments:ta,deleteAssetProcedureFieldsAttachment:_h,deleteAssetProcedureFieldsAttachments:sa}=zt.actions,ia=t=>t.assetProcedureFieldsAttachmentReducer.instances,na=u.createSelector([ia],t=>Object.values(t)),Fh=S(u.createSelector([na,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Ih=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],aa=zt.reducer,D=I(t=>t.offline_id),ca=D.getInitialState({}),Vt=u.createSlice({name:"assetProcedureFields",initialState:ca,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ca)),reducers:{initializeAssetProcedureFields:D.initialize,addAssetProcedureFields:D.addOne,addAssetProcedureFieldsMany:D.addMany,setAssetProcedureFields:D.setOne,setAssetProcedureFieldsMany:D.setMany,updateAssetProcedureFields:D.updateOne,updateAssetProcedureFieldsMany:D.updateMany,deleteAssetProcedureFields:D.deleteOne,deleteAssetProcedureFieldsMany:D.deleteMany}}),{initializeAssetProcedureFields:ra,addAssetProcedureFields:da,addAssetProcedureFieldsMany:Rh,setAssetProcedureFields:Ph,setAssetProcedureFieldsMany:Oh,updateAssetProcedureFields:oa,updateAssetProcedureFieldsMany:vh,deleteAssetProcedureFields:la,deleteAssetProcedureFieldsMany:wh}=Vt.actions,ua=t=>t.assetProcedureFieldsReducer.instances,Ut=u.createSelector([ua],t=>Object.values(t)),Eh=S(u.createSelector([Ut,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),jh=S(u.createSelector([Ut,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),qh=t=>e=>e.assetProcedureFieldsReducer.instances[t],ha=Vt.reducer,z=I(t=>t.offline_id),ma=z.getInitialState({}),$t=u.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:ma,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ma)),reducers:{initializeAssetProcedureFieldValuesAttachments:z.initialize,addAssetProcedureFieldValuesAttachment:z.addOne,addAssetProcedureFieldValuesAttachments:z.addMany,setAssetProcedureFieldValuesAttachment:z.setOne,setAssetProcedureFieldValuesAttachments:z.setMany,updateAssetProcedureFieldValuesAttachment:z.updateOne,updateAssetProcedureFieldValuesAttachments:z.updateMany,deleteAssetProcedureFieldValuesAttachment:z.deleteOne,deleteAssetProcedureFieldValuesAttachments:z.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:fa,addAssetProcedureFieldValuesAttachment:Mh,addAssetProcedureFieldValuesAttachments:Je,setAssetProcedureFieldValuesAttachment:kh,setAssetProcedureFieldValuesAttachments:Ch,updateAssetProcedureFieldValuesAttachment:Dh,updateAssetProcedureFieldValuesAttachments:pa,deleteAssetProcedureFieldValuesAttachment:zh,deleteAssetProcedureFieldValuesAttachments:Xe}=$t.actions,Bt=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,Aa=u.createSelector([Bt],t=>Object.values(t)),Vh=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],ya=S(u.createSelector([Bt,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),Sa=S(u.createSelector([Aa,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),ga=$t.reducer,V=I(t=>t.offline_id),ba=V.getInitialState({}),Gt=u.createSlice({name:"assetProcedureFieldValues",initialState:ba,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ba)),reducers:{initializeAssetProcedureFieldValues:V.initialize,addAssetProcedureFieldValues:V.addOne,addAssetProcedureFieldValuesMany:V.addMany,setAssetProcedureFieldValues:V.setOne,setAssetProcedureFieldValuesMany:V.setMany,updateAssetProcedureFieldValues:V.updateOne,updateAssetProcedureFieldValuesMany:V.updateMany,deleteAssetProcedureFieldValues:V.deleteOne,deleteAssetProcedureFieldValuesMany:V.deleteMany}}),{initializeAssetProcedureFieldValues:Ta,addAssetProcedureFieldValues:Lt,addAssetProcedureFieldValuesMany:_a,setAssetProcedureFieldValues:Uh,setAssetProcedureFieldValuesMany:$h,updateAssetProcedureFieldValues:ke,updateAssetProcedureFieldValuesMany:Fa,deleteAssetProcedureFieldValues:Nt,deleteAssetProcedureFieldValuesMany:Ia}=Gt.actions,Ra=t=>t.assetProcedureFieldValuesReducer.instances,Ht=u.createSelector([Ra],t=>Object.values(t)),Bh=S(u.createSelector([Ht,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Gh=S(u.createSelector([Ht,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),Wt=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],Pa=Gt.reducer,U=I(t=>t.offline_id),Oa=U.getInitialState({}),Kt=u.createSlice({name:"assetProcedureInstances",initialState:Oa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Oa)),reducers:{initializeAssetProcedureInstances:U.initialize,addAssetProcedureInstance:U.addOne,addAssetProcedureInstances:U.addMany,setAssetProcedureInstance:U.setOne,setAssetProcedureInstances:U.setMany,updateAssetProcedureInstance:U.updateOne,updateAssetProcedureInstances:U.updateMany,deleteAssetProcedureInstance:U.deleteOne,deleteAssetProcedureInstances:U.deleteMany}}),{initializeAssetProcedureInstances:va,addAssetProcedureInstance:Yt,addAssetProcedureInstances:wa,updateAssetProcedureInstance:Ce,updateAssetProcedureInstances:Lh,deleteAssetProcedureInstance:Jt,deleteAssetProcedureInstances:Ea,setAssetProcedureInstance:Nh,setAssetProcedureInstances:Hh}=Kt.actions,Xt=t=>t.assetProcedureInstanceReducer.instances,Qt=u.createSelector([Xt],t=>Object.values(t)),ja=S(u.createSelector([Qt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Wh=S(u.createSelector([Qt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),Zt=t=>e=>e.assetProcedureInstanceReducer.instances[t],Kh=S(u.createSelector([Xt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),qa=Kt.reducer,$=I(t=>t.offline_id),Ma=$.getInitialState({}),xt=u.createSlice({name:"assetProcedures",initialState:Ma,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ma)),reducers:{initializeAssetProcedures:$.initialize,addAssetProcedure:$.addOne,addAssetProcedures:$.addMany,setAssetProcedure:$.setOne,setAssetProcedures:$.setMany,updateAssetProcedure:$.updateOne,updateAssetProcedures:$.updateMany,deleteAssetProcedure:$.deleteOne,deleteAssetProcedures:$.deleteMany}}),{initializeAssetProcedures:ka,addAssetProcedure:es,addAssetProcedures:Yh,updateAssetProcedure:De,updateAssetProcedures:Jh,deleteAssetProcedure:ts,deleteAssetProcedures:Xh,setAssetProcedure:Qh,setAssetProcedures:Zh}=xt.actions,ss=t=>t.assetProcedureReducer.instances,Ca=u.createSelector([ss],t=>Object.values(t)),xh=S(u.createSelector([Ca,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),is=t=>e=>e.assetProcedureReducer.instances[t],em=S(u.createSelector([ss,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),Da=xt.reducer,B=I(t=>t.offline_id),za=B.getInitialState({}),ns=u.createSlice({name:"assets",initialState:za,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,za)),reducers:{initializeAssets:B.initialize,addAsset:B.addOne,addAssets:B.addMany,setAsset:B.setOne,setAssets:B.setMany,updateAsset:B.updateOne,updateAssets:B.updateMany,deleteAsset:B.deleteOne,deleteAssets:B.deleteMany}}),{initializeAssets:Va,addAsset:as,addAssets:cs,updateAsset:ze,updateAssets:tm,deleteAsset:rs,deleteAssets:Ua,setAsset:sm,setAssets:im}=ns.actions,ds=t=>t.assetReducer.instances,$a=u.createSelector([ds],t=>g(Object.values(t))),os=S(u.createSelector([$a,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ls=t=>e=>e.assetReducer.instances[t],nm=S(u.createSelector([ds,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),am=t=>e=>os(t)(e).length,Ba=ns.reducer,he=I(t=>t.offline_id),Ga=he.getInitialState({}),us=u.createSlice({name:"assetStageCompletions",initialState:Ga,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ga)),reducers:{initializeAssetStageCompletions:he.initialize,addAssetStageCompletion:he.addOne,addAssetStageCompletions:he.addMany,updateAssetStageCompletion:he.updateOne,updateAssetStageCompletions:he.updateMany,deleteAssetStageCompletion:he.deleteOne,deleteAssetStageCompletions:he.deleteMany}}),{initializeAssetStageCompletions:La,addAssetStageCompletion:hs,addAssetStageCompletions:ms,updateAssetStageCompletion:Na,updateAssetStageCompletions:Ha,deleteAssetStageCompletion:fs,deleteAssetStageCompletions:ps}=us.actions,Wa=us.reducer,As=t=>t.assetStageCompletionReducer.instances,cm=u.createSelector([As],t=>Object.values(t)),Ka=t=>e=>e.assetStageCompletionReducer.instances[t],Ya=S(u.createSelector([As,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),G=I(t=>t.offline_id),Ja=G.getInitialState({}),ys=u.createSlice({name:"assetStages",initialState:Ja,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ja)),reducers:{initializeAssetStages:G.initialize,setAssetStage:G.setOne,setAssetStages:G.setMany,addAssetStage:G.addOne,addAssetStages:G.addMany,updateAssetStage:G.updateOne,updateAssetStages:G.updateMany,deleteAssetStage:G.deleteOne,deleteAssetStages:G.deleteMany}}),{initializeAssetStages:Xa,setAssetStage:Qa,setAssetStages:rm,addAssetStage:dm,addAssetStages:Ss,updateAssetStage:gs,updateAssetStages:Qe,deleteAssetStage:om,deleteAssetStages:bs}=ys.actions,Za=ys.reducer,Ze=t=>t.assetStageReducer.instances,xa=t=>e=>e.assetStageReducer.instances[t],ec=u.createSelector([Ze],t=>Object.values(t)),lm=S(u.createSelector([Ze,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_procedure===e&&(s[n]=a);return Fe(s)})),um=S(u.createSelector([ec,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Ts=S(u.createSelector([Ze,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectStagesFromStageIds: No stage exists with the id",n)}return g(s)})),L=I(t=>t.offline_id),tc=L.getInitialState({}),_s=u.createSlice({name:"assetTypeAttachments",initialState:tc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,tc)),reducers:{initializeAssetTypeAttachments:L.initialize,addAssetTypeAttachment:L.addOne,addAssetTypeAttachments:L.addMany,setAssetTypeAttachment:L.setOne,setAssetTypeAttachments:L.setMany,updateAssetTypeAttachment:L.updateOne,updateAssetTypeAttachments:L.updateMany,deleteAssetTypeAttachment:L.deleteOne,deleteAssetTypeAttachments:L.deleteMany}}),{initializeAssetTypeAttachments:sc,addAssetTypeAttachment:hm,addAssetTypeAttachments:Fs,setAssetTypeAttachment:ic,setAssetTypeAttachments:mm,updateAssetTypeAttachment:fm,updateAssetTypeAttachments:nc,deleteAssetTypeAttachment:ac,deleteAssetTypeAttachments:Is}=_s.actions,cc=t=>t.assetTypeAttachmentReducer.instances,rc=u.createSelector([cc],t=>Object.values(t)),dc=t=>e=>e.assetTypeAttachmentReducer.instances[t],oc=S(u.createSelector([rc,(t,e)=>e],(t,e)=>g(t.filter(({asset_type:s})=>e===s)))),lc=_s.reducer,N=I(t=>t.offline_id),uc=N.getInitialState({}),Rs=u.createSlice({name:"assetTypeFieldsAttachments",initialState:uc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uc)),reducers:{initializeAssetTypeFieldsAttachments:N.initialize,addAssetTypeFieldsAttachment:N.addOne,addAssetTypeFieldsAttachments:N.addMany,setAssetTypeFieldsAttachment:N.setOne,setAssetTypeFieldsAttachments:N.setMany,updateAssetTypeFieldsAttachment:N.updateOne,updateAssetTypeFieldsAttachments:N.updateMany,deleteAssetTypeFieldsAttachment:N.deleteOne,deleteAssetTypeFieldsAttachments:N.deleteMany}}),{initializeAssetTypeFieldsAttachments:hc,addAssetTypeFieldsAttachment:pm,addAssetTypeFieldsAttachments:mc,setAssetTypeFieldsAttachment:Am,setAssetTypeFieldsAttachments:ym,updateAssetTypeFieldsAttachment:Sm,updateAssetTypeFieldsAttachments:fc,deleteAssetTypeFieldsAttachment:gm,deleteAssetTypeFieldsAttachments:pc}=Rs.actions,Ac=t=>t.assetTypeFieldsAttachmentReducer.instances,yc=u.createSelector([Ac],t=>Object.values(t)),bm=S(u.createSelector([yc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Tm=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Sc=Rs.reducer,H=I(t=>t.offline_id),gc=H.getInitialState({}),Ps=u.createSlice({name:"assetTypeFields",initialState:gc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gc)),reducers:{initializeAssetTypeFields:H.initialize,addAssetTypeFields:H.addOne,addAssetTypeFieldsMany:H.addMany,setAssetTypeFields:H.setOne,setAssetTypeFieldsMany:H.setMany,updateAssetTypeFields:H.updateOne,updateAssetTypeFieldsMany:H.updateMany,deleteAssetTypeFields:H.deleteOne,deleteAssetTypeFieldsMany:H.deleteMany}}),{initializeAssetTypeFields:bc,addAssetTypeFields:Tc,addAssetTypeFieldsMany:_m,setAssetTypeFields:Fm,setAssetTypeFieldsMany:Im,updateAssetTypeFields:_c,updateAssetTypeFieldsMany:Rm,deleteAssetTypeFields:Fc,deleteAssetTypeFieldsMany:Pm}=Ps.actions,Ic=t=>t.assetTypeFieldsReducer.instances,xe=u.createSelector([Ic],t=>Object.values(t)),Om=S(u.createSelector([xe,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),vm=S(u.createSelector([xe,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),wm=t=>e=>e.assetTypeFieldsReducer.instances[t],Rc=Ps.reducer,W=I(t=>t.offline_id),Pc=W.getInitialState({}),Os=u.createSlice({name:"assetTypeFieldValuesAttachments",initialState:Pc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pc)),reducers:{initializeAssetTypeFieldValuesAttachments:W.initialize,addAssetTypeFieldValuesAttachment:W.addOne,addAssetTypeFieldValuesAttachments:W.addMany,setAssetTypeFieldValuesAttachment:W.setOne,setAssetTypeFieldValuesAttachments:W.setMany,updateAssetTypeFieldValuesAttachment:W.updateOne,updateAssetTypeFieldValuesAttachments:W.updateMany,deleteAssetTypeFieldValuesAttachment:W.deleteOne,deleteAssetTypeFieldValuesAttachments:W.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:Oc,addAssetTypeFieldValuesAttachment:Em,addAssetTypeFieldValuesAttachments:et,setAssetTypeFieldValuesAttachment:jm,setAssetTypeFieldValuesAttachments:qm,updateAssetTypeFieldValuesAttachment:Mm,updateAssetTypeFieldValuesAttachments:vc,deleteAssetTypeFieldValuesAttachment:km,deleteAssetTypeFieldValuesAttachments:tt}=Os.actions,vs=t=>t.assetTypeFieldValuesAttachmentReducer.instances,wc=u.createSelector([vs],t=>Object.values(t)),Cm=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],Ec=S(u.createSelector([vs,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),jc=S(u.createSelector([wc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),qc=Os.reducer,K=I(t=>t.offline_id),Mc=K.getInitialState({}),ws=u.createSlice({name:"assetTypeFieldValues",initialState:Mc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Mc)),reducers:{initializeAssetTypeFieldValues:K.initialize,addAssetTypeFieldValues:K.addOne,addAssetTypeFieldValuesMany:K.addMany,setAssetTypeFieldValues:K.setOne,setAssetTypeFieldValuesMany:K.setMany,updateAssetTypeFieldValues:K.updateOne,updateAssetTypeFieldValuesMany:K.updateMany,deleteAssetTypeFieldValues:K.deleteOne,deleteAssetTypeFieldValuesMany:K.deleteMany}}),{initializeAssetTypeFieldValues:kc,addAssetTypeFieldValues:Es,addAssetTypeFieldValuesMany:Cc,setAssetTypeFieldValues:Dm,setAssetTypeFieldValuesMany:zm,updateAssetTypeFieldValues:Ve,updateAssetTypeFieldValuesMany:Dc,deleteAssetTypeFieldValues:js,deleteAssetTypeFieldValuesMany:zc}=ws.actions,Vc=t=>t.assetTypeFieldValuesReducer.instances,qs=u.createSelector([Vc],t=>Object.values(t)),Vm=S(u.createSelector([qs,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Um=S(u.createSelector([xe,qs,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.asset_type===s).map(a=>a.offline_id));return g(e.filter(a=>n.has(a.fields_revision)))})),Ms=t=>e=>e.assetTypeFieldValuesReducer.instances[t],Uc=ws.reducer,Y=I(t=>t.offline_id),$c=Y.getInitialState({}),ks=u.createSlice({name:"assetTypes",initialState:$c,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,$c)),reducers:{initializeAssetTypes:Y.initialize,setAssetType:Y.setOne,setAssetTypes:Y.setMany,addAssetType:Y.addOne,addAssetTypes:Y.addMany,updateAssetType:Y.updateOne,updateAssetTypes:Y.updateMany,deleteAssetType:Y.deleteOne,deleteAssetTypes:Y.deleteMany}}),{initializeAssetTypes:Bc,setAssetType:$m,setAssetTypes:Bm,addAssetType:Cs,addAssetTypes:Gm,updateAssetType:Ue,updateAssetTypes:Lm,deleteAssetType:Ds,deleteAssetTypes:Nm}=ks.actions,zs=t=>t.assetTypeReducer.instances,Hm=u.createSelector([zs],t=>Object.values(t)),Vs=t=>e=>e.assetTypeReducer.instances[t],Wm=S(u.createSelector([zs,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectAssetTypesByIds: No assetType exists with the id",n)}return g(s)})),Gc=ks.reducer,Lc={accessToken:"",refreshToken:"",isLoggedIn:!1},st=u.createSlice({name:"auth",initialState:Lc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lc)),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||st.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Km,clearTokens:Ym,setLoggedIn:Nc}=st.actions,Jm=t=>t.authReducer.accessToken,Xm=t=>t.authReducer.isLoggedIn,Hc=st.reducer,$e=I(t=>t.offline_id),Wc=$e.getInitialState({}),Us=u.createSlice({name:"categories",initialState:Wc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wc)),reducers:{initializeCategories:$e.initialize,addCategory:$e.addOne,updateCategory:$e.updateOne,deleteCategory:$e.deleteOne}}),{initializeCategories:Kc,addCategory:$s,updateCategory:Yc,deleteCategory:Jc}=Us.actions,Bs=t=>t.categoryReducer.instances,Qm=u.createSelector([Bs],t=>Object.values(t)),Gs=t=>e=>e.categoryReducer.instances[t],Zm=S(u.createSelector([Bs,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectCategoryByIds: No category exists with the id",n)}return g(s)})),xm=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,Xc=Us.reducer,J=I(t=>t.offline_id),Qc=J.getInitialState({}),Ls=u.createSlice({name:"documentAttachments",initialState:Qc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qc)),reducers:{initializeDocumentAttachments:J.initialize,addDocumentAttachment:J.addOne,addDocumentAttachments:J.addMany,setDocumentAttachment:J.setOne,setDocumentAttachments:J.setMany,updateDocumentAttachment:J.updateOne,updateDocumentAttachments:J.updateMany,deleteDocumentAttachment:J.deleteOne,deleteDocumentAttachments:J.deleteMany}}),{initializeDocumentAttachments:Zc,addDocumentAttachment:ef,addDocumentAttachments:xc,setDocumentAttachment:er,setDocumentAttachments:tf,updateDocumentAttachment:sf,updateDocumentAttachments:tr,deleteDocumentAttachment:sr,deleteDocumentAttachments:ir}=Ls.actions,nr=t=>t.documentAttachmentReducer.instances,ar=u.createSelector([nr],t=>Object.values(t)),cr=t=>e=>e.documentAttachmentReducer.instances[t],nf=S(u.createSelector([ar,(t,e)=>e],(t,e)=>g(t.filter(({document:s})=>e===s)))),rr=Ls.reducer,dr={documents:{}},Ns=u.createSlice({name:"documents",initialState:dr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,dr)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(Dn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Cn(e.payload)},addDocuments:(t,e)=>{for(const s of e.payload)if(s.offline_id in t.documents)throw new Error(`attempting to add a document with offline_id ${s.offline_id} which already exists in state.documents.`);for(const s of e.payload){if(s.parent_document&&t.documents[s.parent_document]){const n=t.documents[s.parent_document];t.documents[s.parent_document]={...n,children_documents:[...n.children_documents,s.offline_id]}}t.documents[s.offline_id]=s}},updateDocuments:(t,e)=>{for(const s of e.payload)if(!(s.offline_id in t.documents))throw new Error(`attempting to update a document with offline_id ${s.offline_id} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s.offline_id];if(s.organization!==void 0&&s.organization!==n.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==n.project)throw new Error("project cannot be updated");t.documents[s.offline_id]={...n,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:n,position:a}=e.payload;if(!(s in t.documents))throw new Error(`attempting to move a document with offline_id ${s} which doesn't exist in state.documents`);const c=t.documents[s];if(c.parent_document&&t.documents[c.parent_document]){const{children_documents:r}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(r.indexOf(c.offline_id),1)}if(n){const r=t.documents[n],o=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(a){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.offline_id),0,c.offline_id),t.documents[s].parent_document=o.offline_id;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.offline_id)+1,0,c.offline_id),t.documents[s].parent_document=o.offline_id;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[n].children_documents.unshift(c.offline_id),t.documents[s].parent_document=r.offline_id;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[n].children_documents.push(c.offline_id),t.documents[s].parent_document=r.offline_id}}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 offline_id ${s} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s];if(n.parent_document&&t.documents[n.parent_document]){const a=t.documents[n.parent_document];t.documents[n.parent_document]={...a,children_documents:a.children_documents.filter(c=>c!==n.offline_id)}}delete t.documents[s]}}}}),{setDocuments:or,addDocuments:lr,updateDocuments:me,moveDocument:ur,removeDocuments:Hs}=Ns.actions,Re=t=>t.documentsReducer.documents,hr=u.createSelector([Re],t=>Object.values(t)),mr=t=>e=>e.documentsReducer.documents[t],af=S(u.createSelector([Re,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectDocumentByIds: No document exists with the id",n)}return g(s)})),cf=S(u.createSelector([Re,(t,e)=>e],(t,e)=>{const s=[],n=t[e];if(!n||!n.parent_document)return s;let a=t[n.parent_document];for(;a;)s.push(a.offline_id),a=t[a.parent_document??""];return g(s)})),rf=u.createSelector([hr],t=>g(t.filter(e=>!e.parent_document))),fr=Ns.reducer,it=I(t=>t.offline_id),df=it.getInitialState({}),Ws=u.createSlice({name:"emailDomains",initialState:df,reducers:{initializeEmailDomains:it.initialize,addEmailDomain:it.addOne,deleteEmailDomain:it.deleteOne}}),{initializeEmailDomains:pr,addEmailDomain:Ar,deleteEmailDomain:yr}=Ws.actions,Sr=t=>t.emailDomainsReducer.instances,gr=u.createSelector([Sr],t=>Object.values(t)),of=S(u.createSelector([gr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),br=Ws.reducer,Tr={s3Urls:{}},_r=1e3*60*60,lf=_r*24*7,Ks=u.createSlice({name:"file",initialState:Tr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Tr)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:n,sha1:a}=e.payload,c=new Date,r=new Date(c.getTime()+lf);t.s3Urls[a]={url:s,fields:n,exp:r.getTime()}}}}),{setUploadUrl:Fr}=Ks.actions,Ir=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<_r))return s},Rr=Ks.reducer,X=I(t=>t.offline_id),Pr=X.getInitialState({}),Ys=u.createSlice({name:"formRevisionAttachments",initialState:Pr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pr)),reducers:{initializeFormRevisionAttachments:X.initialize,addFormRevisionAttachment:X.addOne,addFormRevisionAttachments:X.addMany,setFormRevisionAttachment:X.setOne,setFormRevisionAttachments:X.setMany,updateFormRevisionAttachment:X.updateOne,updateFormRevisionAttachments:X.updateMany,deleteFormRevisionAttachment:X.deleteOne,deleteFormRevisionAttachments:X.deleteMany}}),{initializeFormRevisionAttachments:Or,addFormRevisionAttachment:uf,addFormRevisionAttachments:vr,setFormRevisionAttachment:hf,setFormRevisionAttachments:mf,updateFormRevisionAttachment:ff,updateFormRevisionAttachments:wr,deleteFormRevisionAttachment:pf,deleteFormRevisionAttachments:Er}=Ys.actions,jr=t=>t.formRevisionAttachmentReducer.instances,Af=S(u.createSelector([jr,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_revision===e)))),qr=Ys.reducer,yf=(t,e)=>{const s=t.revision,n=e.revision;return s===void 0&&n===void 0?t.submitted_at<e.submitted_at?-1:1:s===void 0?1:n===void 0||s<n?-1:1},fe=I(t=>t.offline_id),Mr=fe.getInitialState({}),Js=u.createSlice({name:"formRevisions",initialState:Mr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Mr)),reducers:{initializeFormRevisions:fe.initialize,setFormRevision:fe.setOne,addFormRevision:fe.addOne,addFormRevisions:fe.addMany,deleteFormRevision:fe.deleteOne,deleteFormRevisions:fe.deleteMany}}),{setFormRevision:kr,initializeFormRevisions:Cr,addFormRevision:Xs,addFormRevisions:Dr,deleteFormRevision:Qs,deleteFormRevisions:zr}=Js.actions,nt=t=>t.formRevisionReducer.instances,Vr=u.createSelector([nt],t=>Object.values(t)),Sf=t=>e=>e.formRevisionReducer.instances[t],gf=S(u.createSelector([nt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(yf)[s.length-1];return t[a.offline_id]})),Ur=S(u.createSelector([Vr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.form===e)))),$r=Js.reducer,pe=I(t=>t.offline_id),Br=pe.getInitialState({}),Zs=u.createSlice({name:"forms",initialState:Br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Br)),reducers:{initializeForms:pe.initialize,setForm:pe.setOne,addForm:pe.addOne,addForms:pe.addMany,updateForm:pe.updateOne,deleteForm:pe.deleteOne}}),{initializeForms:Gr,setForm:bf,addForm:xs,addForms:Tf,updateForm:_f,deleteForm:ei}=Zs.actions,Lr=Zs.reducer,Nr=t=>t.formReducer.instances,Ff=u.createSelector([Nr],t=>Object.values(t)),Hr=t=>e=>e.formReducer.instances[t],Q=I(t=>t.offline_id),Wr=Q.getInitialState({}),ti=u.createSlice({name:"formSubmissionAttachments",initialState:Wr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wr)),reducers:{initializeFormSubmissionAttachments:Q.initialize,addFormSubmissionAttachment:Q.addOne,addFormSubmissionAttachments:Q.addMany,setFormSubmissionAttachment:Q.setOne,setFormSubmissionAttachments:Q.setMany,updateFormSubmissionAttachment:Q.updateOne,updateFormSubmissionAttachments:Q.updateMany,deleteFormSubmissionAttachment:Q.deleteOne,deleteFormSubmissionAttachments:Q.deleteMany}}),{initializeFormSubmissionAttachments:Kr,addFormSubmissionAttachment:If,addFormSubmissionAttachments:at,setFormSubmissionAttachment:Rf,setFormSubmissionAttachments:Pf,updateFormSubmissionAttachment:Of,updateFormSubmissionAttachments:Yr,deleteFormSubmissionAttachment:vf,deleteFormSubmissionAttachments:ct}=ti.actions,si=t=>t.formSubmissionAttachmentReducer.instances,Jr=S(u.createSelector([si,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),Xr=S(u.createSelector([si,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_submission===e)))),Qr=ti.reducer,Z=I(t=>t.offline_id),Zr=Z.getInitialState({}),ii=u.createSlice({name:"formSubmissions",initialState:Zr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zr)),reducers:{initializeFormSubmissions:Z.initialize,setFormSubmission:Z.setOne,setFormSubmissions:Z.setMany,addFormSubmission:Z.addOne,addFormSubmissions:Z.addMany,updateFormSubmission:Z.updateOne,updateFormSubmissions:Z.updateMany,deleteFormSubmission:Z.deleteOne,deleteFormSubmissions:Z.deleteMany}}),{initializeFormSubmissions:xr,setFormSubmission:rt,setFormSubmissions:wf,addFormSubmission:ni,addFormSubmissions:dt,updateFormSubmission:ed,updateFormSubmissions:Ef,deleteFormSubmission:ai,deleteFormSubmissions:ot}=ii.actions,ci=t=>t.formSubmissionReducer.instances,ri=u.createSelector([ci],t=>Object.values(t)),di=t=>e=>e.formSubmissionReducer.instances[t],td=S(u.createSelector([ci,nt,(t,e)=>e],(t,e,s)=>{const n=new Set;for(const a of Object.values(e))a.form===s&&n.add(a.offline_id);return Object.values(t).filter(a=>n.has(a.form_revision))})),sd=S(u.createSelector([ri,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),id=S(u.createSelector([ri,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),nd=ii.reducer,x=I(t=>t.offline_id),ad=x.getInitialState({}),oi=u.createSlice({name:"geoImages",initialState:ad,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,ad)})},reducers:{initializeGeoImages:x.initialize,setGeoImage:x.setOne,setGeoImages:x.setMany,addGeoImage:x.addOne,addGeoImages:x.addMany,updateGeoImage:x.updateOne,updateGeoImages:x.updateMany,deleteGeoImage:x.deleteOne,deleteGeoImages:x.deleteMany}}),{initializeGeoImages:cd,setGeoImage:Be,setGeoImages:rd,addGeoImage:dd,addGeoImages:od,updateGeoImage:ld,updateGeoImages:jf,deleteGeoImage:li,deleteGeoImages:ud}=oi.actions,hd=t=>t.geoImageReducer.instances,md=u.createSelector([hd],t=>Object.values(t)),ui=t=>e=>e.geoImageReducer.instances[t],qf=S(u.createSelector([md,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),fd=oi.reducer,ee=I(t=>t.offline_id),pd=ee.getInitialState({}),hi=u.createSlice({name:"issueAssociations",initialState:pd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pd)),reducers:{initializeIssueAssociations:ee.initialize,addIssueAssociation:ee.addOne,addIssueAssociations:ee.addMany,setIssueAssociation:ee.setOne,setIssueAssociations:ee.setMany,updateIssueAssociation:ee.updateOne,updateIssueAssociations:ee.updateMany,deleteIssueAssociation:ee.deleteOne,deleteIssueAssociations:ee.deleteMany}}),{initializeIssueAssociations:Ad,setIssueAssociations:Mf,setIssueAssociation:kf,updateIssueAssociation:yd,updateIssueAssociations:Cf,addIssueAssociation:mi,addIssueAssociations:fi,deleteIssueAssociation:pi,deleteIssueAssociations:Ai}=hi.actions,Ge=t=>t.issueAssociationReducer.instances,Df=u.createSelector([Ge],t=>Object.values(t)),Sd=t=>e=>e.issueAssociationReducer.instances[t],gd=S(u.createSelector([Ge,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.associated_issue===e)))),bd=S(u.createSelector([Ge,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Td=S(u.createSelector([Ge,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.asset===e)))),_d=hi.reducer,te=I(t=>t.offline_id),Fd=te.getInitialState({}),yi=u.createSlice({name:"issueAttachments",initialState:Fd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Fd)),reducers:{initializeIssueAttachments:te.initialize,addIssueAttachment:te.addOne,addIssueAttachments:te.addMany,setIssueAttachment:te.setOne,setIssueAttachments:te.setMany,updateIssueAttachment:te.updateOne,updateIssueAttachments:te.updateMany,deleteIssueAttachment:te.deleteOne,deleteIssueAttachments:te.deleteMany}}),{initializeIssueAttachments:Si,addIssueAttachment:zf,addIssueAttachments:gi,setIssueAttachment:Id,setIssueAttachments:Vf,updateIssueAttachment:Uf,updateIssueAttachments:Rd,deleteIssueAttachment:Pd,deleteIssueAttachments:bi}=yi.actions,Od=t=>t.issueAttachmentReducer.instances,vd=u.createSelector([Od],t=>Object.values(t)),wd=S(u.createSelector([vd,(t,e)=>e],(t,e)=>g(t.filter(({issue:s})=>e===s)))),Ed=t=>e=>e.issueAttachmentReducer.instances[t],jd=yi.reducer,se=I(t=>t.offline_id),qd=se.getInitialState({}),Ti=u.createSlice({name:"issueCommentAttachments",initialState:qd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,qd)),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:_i,addIssueCommentAttachment:$f,addIssueCommentAttachments:Md,setIssueCommentAttachment:kd,setIssueCommentAttachments:Bf,updateIssueCommentAttachment:Gf,updateIssueCommentAttachments:Cd,deleteIssueCommentAttachment:Dd,deleteIssueCommentAttachments:zd}=Ti.actions,Vd=t=>t.issueCommentAttachmentReducer.instances,Ud=u.createSelector([Vd],t=>Object.values(t)),$d=t=>e=>e.issueCommentAttachmentReducer.instances[t],Lf=S(u.createSelector([Ud,(t,e)=>e],(t,e)=>g(t.filter(({issue_comment:s})=>e===s)))),Bd=Ti.reducer,Ae=I(t=>t.offline_id),Gd=Ae.getInitialState({}),Fi=u.createSlice({name:"issueComments",initialState:Gd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Gd)),reducers:{addIssueComment:Ae.addOne,addIssueComments:Ae.addMany,setIssueComment:Ae.setOne,setIssueComments:Ae.setMany,deleteIssueComment:Ae.deleteOne,deleteIssueComments:Ae.deleteMany}}),{setIssueComments:Ld,setIssueComment:Ii,addIssueComment:Ri,addIssueComments:Nf,deleteIssueComment:Pi,deleteIssueComments:Hf}=Fi.actions,Nd=t=>t.issueCommentReducer.instances,Hd=t=>e=>e.issueCommentReducer.instances[t],Wf=S(u.createSelector([Nd,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Wd=Fi.reducer,ye=I(t=>t.offline_id),Kd=ye.getInitialState({}),Oi=u.createSlice({name:"issues",initialState:Kd,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Kd)}),reducers:{initializeIssues:ye.initialize,addIssue:ye.addOne,addIssues:ye.addMany,updateIssue:ye.updateOne,deleteIssue:ye.deleteOne,deleteIssues:ye.deleteMany}}),{initializeIssues:Yd,addIssue:vi,addIssues:Jd,updateIssue:lt,deleteIssue:wi,deleteIssues:Xd}=Oi.actions,Qd=t=>t.issueReducer.instances,Ei=t=>e=>e.issueReducer.instances[t],Kf=S(u.createSelector([Qd,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectIssuesByIds: No issue exists with the id",n)}return g(s)})),Zd=Oi.reducer,ie=I(t=>t.offline_id),xd=ie.getInitialState({}),ji=u.createSlice({name:"issueTypeAttachments",initialState:xd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,xd)),reducers:{initializeIssueTypeAttachments:ie.initialize,addIssueTypeAttachment:ie.addOne,addIssueTypeAttachments:ie.addMany,setIssueTypeAttachment:ie.setOne,setIssueTypeAttachments:ie.setMany,updateIssueTypeAttachment:ie.updateOne,updateIssueTypeAttachments:ie.updateMany,deleteIssueTypeAttachment:ie.deleteOne,deleteIssueTypeAttachments:ie.deleteMany}}),{initializeIssueTypeAttachments:qi,addIssueTypeAttachment:Yf,addIssueTypeAttachments:eo,setIssueTypeAttachment:to,setIssueTypeAttachments:Jf,updateIssueTypeAttachment:Xf,updateIssueTypeAttachments:so,deleteIssueTypeAttachment:io,deleteIssueTypeAttachments:no}=ji.actions,ao=t=>t.issueTypeAttachmentReducer.instances,co=u.createSelector([ao],t=>Object.values(t)),ro=t=>e=>e.issueTypeAttachmentReducer.instances[t],Qf=S(u.createSelector([co,(t,e)=>e],(t,e)=>g(t.filter(({issue_type:s})=>e===s)))),oo=ji.reducer,ne=I(t=>t.offline_id),lo=ne.getInitialState({}),Mi=u.createSlice({name:"issueTypeFieldsAttachments",initialState:lo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,lo)),reducers:{initializeIssueTypeFieldsAttachments:ne.initialize,addIssueTypeFieldsAttachment:ne.addOne,addIssueTypeFieldsAttachments:ne.addMany,setIssueTypeFieldsAttachment:ne.setOne,setIssueTypeFieldsAttachments:ne.setMany,updateIssueTypeFieldsAttachment:ne.updateOne,updateIssueTypeFieldsAttachments:ne.updateMany,deleteIssueTypeFieldsAttachment:ne.deleteOne,deleteIssueTypeFieldsAttachments:ne.deleteMany}}),{initializeIssueTypeFieldsAttachments:uo,addIssueTypeFieldsAttachment:Zf,addIssueTypeFieldsAttachments:ho,setIssueTypeFieldsAttachment:xf,setIssueTypeFieldsAttachments:ep,updateIssueTypeFieldsAttachment:tp,updateIssueTypeFieldsAttachments:mo,deleteIssueTypeFieldsAttachment:sp,deleteIssueTypeFieldsAttachments:fo}=Mi.actions,po=t=>t.issueTypeFieldsAttachmentReducer.instances,Ao=u.createSelector([po],t=>Object.values(t)),ip=S(u.createSelector([Ao,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),np=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],yo=Mi.reducer,ae=I(t=>t.offline_id),So=ae.getInitialState({}),ki=u.createSlice({name:"issueTypeFieldValues",initialState:So,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,So)),reducers:{initializeIssueTypeFieldValues:ae.initialize,addIssueTypeFieldValues:ae.addOne,addIssueTypeFieldValuesMany:ae.addMany,setIssueTypeFieldValues:ae.setOne,setIssueTypeFieldValuesMany:ae.setMany,updateIssueTypeFieldValues:ae.updateOne,updateIssueTypeFieldValuesMany:ae.updateMany,deleteIssueTypeFieldValues:ae.deleteOne,deleteIssueTypeFieldValuesMany:ae.deleteMany}}),{initializeIssueTypeFieldValues:go,addIssueTypeFieldValues:Ci,addIssueTypeFieldValuesMany:ap,setIssueTypeFieldValues:cp,setIssueTypeFieldValuesMany:rp,updateIssueTypeFieldValues:Le,updateIssueTypeFieldValuesMany:dp,deleteIssueTypeFieldValues:Di,deleteIssueTypeFieldValuesMany:op}=ki.actions,bo=t=>t.issueTypeFieldValuesReducer.instances,zi=u.createSelector([bo],t=>Object.values(t)),lp=S(u.createSelector([zi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue===e)))),Vi=t=>e=>e.issueTypeFieldValuesReducer.instances[t],To=ki.reducer,ce=I(t=>t.offline_id),_o=ce.getInitialState({}),Ui=u.createSlice({name:"issueTypeFields",initialState:_o,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,_o)),reducers:{initializeIssueTypeFields:ce.initialize,addIssueTypeFields:ce.addOne,addIssueTypeFieldsMany:ce.addMany,setIssueTypeFields:ce.setOne,setIssueTypeFieldsMany:ce.setMany,updateIssueTypeFields:ce.updateOne,updateIssueTypeFieldsMany:ce.updateMany,deleteIssueTypeFields:ce.deleteOne,deleteIssueTypeFieldsMany:ce.deleteMany}}),{initializeIssueTypeFields:Fo,addIssueTypeFields:Io,addIssueTypeFieldsMany:up,setIssueTypeFields:hp,setIssueTypeFieldsMany:mp,updateIssueTypeFields:Ro,updateIssueTypeFieldsMany:fp,deleteIssueTypeFields:Po,deleteIssueTypeFieldsMany:pp}=Ui.actions,Oo=t=>t.issueTypeFieldsReducer.instances,ut=u.createSelector([Oo],t=>Object.values(t)),Ap=S(u.createSelector([ut,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue_type===e)))),yp=S(u.createSelector([ut,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Sp=S(u.createSelector([ut,zi,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.issue_type===s).map(a=>a.offline_id));return g(e.filter(a=>n.has(a.fields_revision)))})),gp=t=>e=>e.issueTypeFieldsReducer.instances[t],vo=Ui.reducer,re=I(t=>t.offline_id),wo=re.getInitialState({}),$i=u.createSlice({name:"issueTypeFieldValuesAttachments",initialState:wo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wo)),reducers:{initializeIssueTypeFieldValuesAttachments:re.initialize,addIssueTypeFieldValuesAttachment:re.addOne,addIssueTypeFieldValuesAttachments:re.addMany,setIssueTypeFieldValuesAttachment:re.setOne,setIssueTypeFieldValuesAttachments:re.setMany,updateIssueTypeFieldValuesAttachment:re.updateOne,updateIssueTypeFieldValuesAttachments:re.updateMany,deleteIssueTypeFieldValuesAttachment:re.deleteOne,deleteIssueTypeFieldValuesAttachments:re.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:Eo,addIssueTypeFieldValuesAttachment:bp,addIssueTypeFieldValuesAttachments:ht,setIssueTypeFieldValuesAttachment:Tp,setIssueTypeFieldValuesAttachments:_p,updateIssueTypeFieldValuesAttachment:Fp,updateIssueTypeFieldValuesAttachments:jo,deleteIssueTypeFieldValuesAttachment:Ip,deleteIssueTypeFieldValuesAttachments:mt}=$i.actions,Bi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,qo=u.createSelector([Bi],t=>Object.values(t)),Rp=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],Mo=S(u.createSelector([Bi,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),ko=S(u.createSelector([qo,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Co=$i.reducer,Pe=I(t=>t.offline_id),Do=Pe.getInitialState({}),Gi=u.createSlice({name:"issueTypes",initialState:Do,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Do)}),reducers:{initializeIssueTypes:Pe.initialize,setIssueType:Pe.setOne,addIssueType:Pe.addOne,updateIssueType:Pe.updateOne,removeIssueType:Pe.deleteOne}}),{initializeIssueTypes:zo,setIssueType:Ne,addIssueType:Vo,updateIssueType:Uo,removeIssueType:Li}=Gi.actions,$o=t=>t.issueTypeReducer.instances,Bo=u.createSelector($o,t=>Object.values(t)),Ni=t=>e=>e.issueTypeReducer.instances[t],Pp=t=>e=>{const s=[];for(const n of t){const a=e.issueTypeReducer.instances[n];a?s.push(a):console.warn("selectIssueTypesByIds: No issue type exists with the id",n)}return s},Op=S(u.createSelector([Bo,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Hi=S(u.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue_type===e)))),vp=t=>e=>Hi(t)(e).length,Go=Gi.reducer,Se=I(t=>t.offline_id),Lo=Se.getInitialState({}),Wi=u.createSlice({name:"issueUpdates",initialState:Lo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lo)),reducers:{initializeIssueUpdates:Se.setMany,setIssueUpdate:Se.setOne,addIssueUpdate:Se.addOne,addIssueUpdates:Se.addMany,deleteIssueUpdate:Se.deleteOne,deleteIssueUpdates:Se.deleteMany}}),{initializeIssueUpdates:No,setIssueUpdate:wp,addIssueUpdate:Ho,addIssueUpdates:Wo,deleteIssueUpdate:Ko,deleteIssueUpdates:Yo}=Wi.actions,Jo=t=>t.issueUpdateReducer.instances,Xo=S(u.createSelector([Jo,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Qo=Wi.reducer,ft=I(t=>t.offline_id),Zo=ft.getInitialState({}),Ki=u.createSlice({name:"license",initialState:Zo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zo)),reducers:{initializeLicences:ft.initialize,addLicenses:ft.addMany,updateLicense:ft.updateOne}}),{initializeLicences:xo,addLicenses:Ep,updateLicense:ue}=Ki.actions,pt=t=>t.licenseReducer.instances,jp=t=>e=>e.licenseReducer.instances[t],el=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),qp=u.createSelector([pt],t=>g(Object.values(t).filter(e=>e.is_active))),Mp=u.createSelector([pt],t=>Fe(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),tl=Ki.reducer,sl={users:{},currentUser:null},Yi=u.createSlice({name:"users",initialState:sl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sl)),reducers:{setUsers:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.users=s},addUsers:(t,e)=>{for(const s of e.payload)t.users[s.id]=s},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.users[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},removeUser:(t,e)=>{delete t.users[e.payload]}}}),{setCurrentUser:kp,setProfilePicture:Cp,setUsers:il,addUsers:Dp,removeUser:nl}=Yi.actions,al=Yi.reducer,At=t=>t.userReducer.currentUser,yt=t=>t.userReducer.users,zp=t=>e=>e.userReducer.users[t],Vp=S(u.createSelector([yt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectUsersByIds: No user exists with the id",n)}return g(s)})),St=I(t=>t.offline_id),cl=St.getInitialState({}),Ji=u.createSlice({name:"organizationAccess",initialState:cl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,cl)),reducers:{initializeOrganizationAccesses:St.initialize,updateOrganizationAccess:St.updateOne,deleteOrganizationAccess:St.deleteOne}}),{initializeOrganizationAccesses:rl,updateOrganizationAccess:dl,deleteOrganizationAccess:ol}=Ji.actions,Xi=t=>t.organizationAccessReducer.instances,Up=t=>e=>e.organizationAccessReducer.instances[t],$p=u.createSelector([At,Xi],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.id))??null),Bp=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),ll=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return Fe(e)},ul=Ji.reducer,He=I(t=>t.offline_id),hl=He.getInitialState({}),Qi=u.createSlice({name:"projectAccess",initialState:hl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,hl)),reducers:{initializeProjectAccesses:He.initialize,updateProjectAccess:He.updateOne,deleteProjectAccess:He.deleteOne,deleteProjectAccesses:He.deleteMany}}),{initializeProjectAccesses:Zi,updateProjectAccess:ml,deleteProjectAccess:fl,deleteProjectAccesses:pl}=Qi.actions,xi=t=>t.projectAccessReducer.instances,Al=u.createSelector(xi,t=>Object.values(t)),Gp=t=>e=>e.projectAccessReducer.instances[t],Lp=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),yl=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return Fe(e)},Sl=Qi.reducer,gl={projects:{}},en=u.createSlice({name:"projects",initialState:gl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gl)),reducers:{setProjects:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.projects=s},updateProject:(t,e)=>{t.projects[e.payload.id]=e.payload},deleteProject:(t,e)=>{delete t.projects[e.payload.id]},acceptProjectInvite:(t,e)=>{if(e.payload in t.projects)t.projects[e.payload].invited=!1;else throw new Error("Accept project invite: user is not in this project")}}}),{setProjects:bl,updateProject:Tl,deleteProject:_l,acceptProjectInvite:Fl}=en.actions,Il=en.reducer,gt=t=>t.projectReducer.projects,Np=u.createSelector([gt],t=>g(Object.values(t))),Hp=t=>e=>e.projectReducer.projects[t],Rl=u.createSelector([xi],t=>Object.values(t).map(e=>e.user)),Pl=u.createSelector([Rl,yt],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),Wp=u.createSelector([At,Pl,yl],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===Ft.ADMIN?-1:1}))),Ol={organizations:{}},tn=u.createSlice({name:"organizations",initialState:Ol,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ol)),reducers:{setOrganizations:(t,e)=>{for(const s of e.payload)t.organizations[s.id]=s}}}),{setOrganizations:vl}=tn.actions,wl=t=>t.organizationReducer.organizations,El=u.createSelector([wl],t=>Object.values(t)),Kp=t=>e=>e.organizationReducer.organizations[t],Yp=u.createSelector([El],t=>g(Object.values(t).filter(e=>e.has_access))),jl=u.createSelector([Xi],t=>Object.values(t).map(e=>e.user)),Jp=S(u.createSelector([gt,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),Xp=S(u.createSelector([pt,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),ql=u.createSelector([jl,yt],(t,e)=>Fe(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),Qp=u.createSelector([At,ql,ll],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===It.ADMIN?-1:1}))),Ml=tn.reducer,kl=(t,e,s)=>{const n=t.uuid?t:{...t,uuid:O.v4()};return{payload:n,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:n,BASE_URL:e,serviceName:s}}}}},Cl={deletedRequests:[],latestRetryTime:0},sn=u.createSlice({name:"outbox",initialState:Cl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Cl)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return kl(n,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}}}),Zp=t=>t.outboxReducer.deletedRequests,xp=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Dl,markForDeletion:eA,markAsDeleted:zl,_setLatestRetryTime:Vl}=sn.actions,Ul=sn.reducer,de=I(t=>t.offline_id),$l=de.getInitialState({}),nn=u.createSlice({name:"projectAttachments",initialState:$l,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,$l)),reducers:{initializeProjectAttachments:de.initialize,addProjectAttachment:de.addOne,addProjectAttachments:de.addMany,setProjectAttachment:de.setOne,setProjectAttachments:de.setMany,updateProjectAttachment:de.updateOne,updateProjectAttachments:de.updateMany,deleteProjectAttachment:de.deleteOne,deleteProjectAttachments:de.deleteMany}}),{initializeProjectAttachments:Bl,addProjectAttachment:tA,addProjectAttachments:Gl,setProjectAttachment:Ll,setProjectAttachments:Nl,updateProjectAttachment:sA,updateProjectAttachments:Hl,deleteProjectAttachment:Wl,deleteProjectAttachments:an}=nn.actions,Kl=t=>t.projectAttachmentReducer.instances,Yl=u.createSelector([Kl],t=>Object.values(t)),Jl=t=>e=>e.projectAttachmentReducer.instances[t],Xl=S(u.createSelector([Yl,(t,e)=>e],(t,e)=>g(t.filter(({project:s})=>e===s)))),Ql=nn.reducer,oe=I(t=>t.offline_id),Zl=oe.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),cn=u.createSlice({name:"projectFiles",initialState:Zl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zl)),reducers:{initializeProjectFiles:oe.initialize,setProjectFile:oe.setOne,setProjectFiles:oe.setMany,addProjectFile:oe.addOne,addProjectFiles:oe.addMany,updateProjectFile:oe.updateOne,updateProjectFiles:oe.updateMany,deleteProjectFile:oe.deleteOne,deleteProjectFiles:oe.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:xl,setProjectFile:iA,setProjectFiles:nA,addProjectFile:aA,addProjectFiles:eu,updateProjectFile:rn,updateProjectFiles:cA,deleteProjectFile:tu,deleteProjectFiles:su,setIsImportingProjectFile:iu,setActiveProjectFileId:nu,saveActiveProjectFileBounds:au,resetProjectFileObjectUrls:rA}=cn.actions,cu=t=>t.projectFileReducer.instances,ru=u.createSelector([cu],t=>g(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),dA=t=>e=>e.projectFileReducer.instances[t],oA=t=>t.projectFileReducer.activeProjectFileId,lA=t=>t.projectFileReducer.isImportingProjectFile,du=cn.reducer,uA={isRehydrated:!1},dn=u.createSlice({name:"rehydrated",initialState:uA,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:hA}=dn.actions,mA=t=>t.rehydratedReducer.isRehydrated,ou=dn.reducer,Oe=I(t=>t.offline_id),lu=Oe.getInitialState({}),on=u.createSlice({name:"teams",initialState:lu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,lu)),reducers:{setTeam:Oe.setOne,initializeTeams:Oe.initialize,addTeam:Oe.addOne,updateTeam:Oe.updateOne,deleteTeam:Oe.deleteOne}}),{setTeam:ve,initializeTeams:uu,addTeam:hu,updateTeam:ln,deleteTeam:un}=on.actions,hn=t=>t.teamReducer.instances,mn=u.createSelector([hn],t=>Object.values(t)),we=t=>e=>e.teamReducer.instances[t],fA=S(u.createSelector([hn,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectTeamsByIds: No team exists with the id",n)}return g(s)})),pA=S(u.createSelector([mn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),AA=S(u.createSelector([mn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.members.includes(e))))),mu=on.reducer,yA={version:0},fu=u.createSlice({name:"versioning",initialState:yA,reducers:{}}),pu=fu.reducer;let Au;function SA(t){Au=t}function We(){return Au}let yu;function gA(t){yu=t}function bA(){return yu}const Su={};class gu{constructor(e){y(this,"client");Su[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 bu="versioning",Tu=()=>Iu.length-1,_u=t=>(t[bu]={version:Tu()},t),Fu=()=>_u({}),TA=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),_A=t=>e=>{var s;return e===void 0&&(e={}),((s=e[bu])==null?void 0:s.version)===Tu()?e:t(e)},Iu=[_u,Fu,Fu,TA],FA=Object.fromEntries(Iu.map((t,e)=>[e,_A(t)])),fn="versioning",Ru={[fn]:pu,fileReducer:Rr,authReducer:Hc,categoryReducer:Xc,assetReducer:Ba,assetAttachmentReducer:Qn,assetStageCompletionReducer:Wa,assetStageReducer:Za,assetTypeReducer:Gc,assetTypeAttachmentReducer:lc,issueReducer:Zd,issueAttachmentReducer:jd,issueTypeReducer:Go,issueTypeAttachmentReducer:oo,organizationReducer:Ml,outboxReducer:Ul,projectReducer:Il,projectAttachmentReducer:Ql,projectAccessReducer:Sl,organizationAccessReducer:ul,projectFileReducer:du,rehydratedReducer:ou,formReducer:Lr,formRevisionReducer:$r,formRevisionAttachmentReducer:qr,formSubmissionAttachmentReducer:Qr,formSubmissionReducer:nd,userReducer:al,emailDomainsReducer:br,licenseReducer:tl,documentsReducer:fr,documentAttachmentReducer:rr,teamReducer:mu,agentsReducer:Gn,issueCommentReducer:Wd,issueCommentAttachmentReducer:Bd,issueUpdateReducer:Qo,geoImageReducer:fd,issueAssociationReducer:_d,issueTypeFieldsReducer:vo,issueTypeFieldValuesReducer:To,issueTypeFieldsAttachmentReducer:yo,issueTypeFieldValuesAttachmentReducer:Co,assetTypeFieldsReducer:Rc,assetTypeFieldValuesReducer:Uc,assetTypeFieldsAttachmentReducer:Sc,assetTypeFieldValuesAttachmentReducer:qc,assetProcedureReducer:Da,assetProcedureInstanceReducer:qa,assetProcedureFieldsReducer:ha,assetProcedureFieldValuesReducer:Pa,assetProcedureFieldsAttachmentReducer:aa,assetProcedureFieldValuesAttachmentReducer:ga},Pu=u.combineReducers(Ru),Ou="RESET",IA=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?Pu(void 0,e):Pu(t,e);let pn=null;function ge(){const t=We();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(pn)return pn;const e=t.getState().offline.outbox,s=je._fromOutbox(e);return pn=s,s}const RA=t=>{if(t)throw t;const e=We();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},vu=(t,e,s)=>{const n=ge();return n?(n.addRequest(e),n.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},wu=(t,e,s)=>{const n=ge();if(!n)return console.warn("Outbox coordinator not set; cannot dequeue request yet."),[];const c=e.meta.offlineAction.payload.uuid;return n.remove(c),n.getQueue()};async function PA(t,e){if(!e.payload)throw new Error("Received empty payload");return CA(e)}const OA={...Tn,effect:PA,discard:yn,returnPromises:!0,persistCallback:RA,retry:zA,persistOptions:{storage:zu},queue:{...Tn.queue,enqueue:vu,dequeue:wu,peek:(...t)=>DA(...t)}},vA=Vu(FA,fn),wA=u.compose(Du.offline(OA),vA);function EA(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(a=>a 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 An(t,e){const s=Su[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const n=s instanceof R;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");n&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const c={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:o,headers:m,method:d,queryParams:h,attachmentHash:f,isExternalUrl:p,isAuthNeeded:A,isResponseBlob:T}={...c,...r.request},_=r.request;let b=_.url;const P=f?await e.files.fetchCache(f):void 0;if(f&&!P)throw new Error(`Cannot upload file ${f} because it's not cached.`);!p&&!b.startsWith("http")&&(!b.startsWith("/")&&!b.startsWith("blob:")&&(b="/"+b),b=t.meta.offline.effect.BASE_URL+b);const M=E=>{if(f){const le=_.s3url;if(!le)throw new Error(`No S3 URL for file ${f}`);if("warning"in le)throw new Error(`S3 URL warning for file ${f}`);if(!P)throw new Error(`No file for file ${f}`);const Ye=le.fields["x-amz-checksum-sha1"];if(!Ye)throw new Error(`No checksum for file ${f}`);return E.set("x-amz-checksum-sha1",Ye).field({...o,...le.fields}).attach("file",P)}return E.send(o)},Hy={[l.GET]:()=>T?_e.get(b.toString()).responseType("blob"):_e.get(b.toString()),[l.POST]:()=>{const E=_e.post(b.toString());return M(E)},[l.PATCH]:()=>{const E=_e.patch(b.toString());return M(E)},[l.PUT]:()=>{const E=_e.put(b.toString());return M(E)},[l.DELETE]:()=>{const E=_e.delete(b.toString());return M(E)}}[d];let Te=Hy();if(A&&n){const E=s.auth.getAuthHeader();Te=Te.set("Authorization",E)}m&&(Te=Te.set(m));try{return await Te.query(h)}catch(E){const le=EA(E),Ye=le==null?void 0:le.status;if(n&&Ye===401)return await s.auth.handleUnauthorized(Te,le),Te.query(h);throw new q({response:le,innerError:E,discard:ju.includes(Ye)})}}class jA{constructor(e){y(this,"_all");y(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 Eu{constructor(){y(this,"next");this.next=null}then(e){return new jA(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!We())throw new Error("Client store not set");const n=bA();if(!n)throw new Error("Client SDK not set");return An(e,n)}}}class qA extends Eu{async run(e){return super.run(e)}}class MA extends Eu{async run(e){return super.run(e)}}const kA=new qA().then(new MA).compile();function CA(t){var e;return(e=kA[0])==null?void 0:e.run(t)}const ju=[400,409,403,404,405,500];function yn(t,e,s=0){var d;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
3
3
  Action:`,e,`
4
- Retries:`,s),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ERROR:",t,"(throwing immediately, which may lead to unexpected behavior)"),t;const n=Ge(),c=n.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function d(){n.dispatch(hl(r));const h=Ae();if(!h)throw new Error("Outbox coordinator not set");h.remove(e.payload.uuid);const f=e.meta.offline.rollback;throw f&&(console.warn("Rolling back request due to SDK error:",e),n.dispatch(f)),t}if(t instanceof j&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),d();if(c.includes(r))return console.debug("Discarding request due to deletion:",e),d();if(t instanceof j){const h=t.status||((o=t.response)==null?void 0:o.status);if(h||console.warn("Error has no status code:",t),h!==void 0&&au.includes(h)){console.warn("Discarding request due to error:",t,`
5
- Action:`,e);const f=Ae();if(!f)throw new Error("Outbox coordinator not set");f.remove(e.payload.uuid),t.options.discard=!0,d()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=Ae();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cA(t,e,s){var n;return(n=Ae())==null?void 0:n.peek()}function rA(t,e){return Ge().dispatch(ml(new Date().getTime())),Pn}const Pe="An unknown error occurred",oA=500,cu=["non_field_errors","detail"];function dA(t,e){let s;if(t!=null&&t.body)if(typeof t.body=="object"){const n=t.body;if(typeof n.error=="string")s=n.error;else if(typeof n.message=="string")s=n.message;else try{s=Object.entries(n).map(([a,c])=>typeof c=="string"?cu.includes(a)?c:`${a}: ${c}`:Array.isArray(c)?cu.includes(a)?c.join(`
4
+ Retries:`,s),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ERROR:",t,"(throwing immediately, which may lead to unexpected behavior)"),t;const n=We(),c=n.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function o(){n.dispatch(zl(r));const h=ge();if(!h)throw new Error("Outbox coordinator not set");h.remove(e.payload.uuid);const f=e.meta.offline.rollback;throw f&&(console.warn("Rolling back request due to SDK error:",e),n.dispatch(f)),t}if(t instanceof q&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),o();if(c.includes(r))return console.debug("Discarding request due to deletion:",e),o();if(t instanceof q){const h=t.status||((d=t.response)==null?void 0:d.status);if(h||console.warn("Error has no status code:",t),h!==void 0&&ju.includes(h)){console.warn("Discarding request due to error:",t,`
5
+ Action:`,e);const f=ge();if(!f)throw new Error("Outbox coordinator not set");f.remove(e.payload.uuid),t.options.discard=!0,o()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=ge();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function DA(t,e,s){var n;return(n=ge())==null?void 0:n.peek()}function zA(t,e){return We().dispatch(Vl(new Date().getTime())),vn}const Ee="An unknown error occurred",VA=500,qu=["non_field_errors","detail"];function UA(t,e){let s;if(t!=null&&t.body)if(typeof t.body=="object"){const n=t.body;if(typeof n.error=="string")s=n.error;else if(typeof n.message=="string")s=n.message;else try{s=Object.entries(n).map(([a,c])=>typeof c=="string"?qu.includes(a)?c:`${a}: ${c}`:Array.isArray(c)?qu.includes(a)?c.join(`
6
6
  `):c.map(r=>`${a}: ${r}`).join(`
7
7
  `):`${a}: ${JSON.stringify(c)}`).join(`
8
- `)}catch(a){console.error("Failed to extract error message from response body",a)}}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>oA?Pe:s}class j extends Error{constructor(s){super(Pe);g(this,"status");g(this,"response");g(this,"message");g(this,"options");const{response:n,innerError:a}=s;this.message=s.message??dA(n,a)??Pe,this.status=(n==null?void 0:n.status)??0,this.response=n,s.discard=s.discard??!1,this.options=s}}class lA{constructor(e){g(this,"store");this.store=e}async enqueueRequest(e,s,n){return this._enqueueRequest(e,s,n).then(a=>{if(a instanceof j)throw a;return a})}_enqueueRequest(e,s,n){const a=new On,c={...e,BASE_URL:s,serviceName:n};if(e.immediate){const r={...c,uuid:e.uuid??O.v4()},d={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:n}}}};fn(d,this).then(m=>{a.resolve(m.body)}).catch(m=>{pn(m,d),m instanceof Error?a.reject(m):a.reject(new Error((m??Pe).toString()))})}else{const r=this.store.dispatch(ul(c)),d=o=>{if(o)a.resolve(o.body);else{const h=new j({message:"Could not get a response from the server.",response:o,discard:!0});a.reject(h)}},m=o=>{o instanceof j?o.options.discard=!0:(console.error("Received an unexpected error while processing a request:",o,`
9
- Converting error to APIError and discarding.`),o=new j({message:"An error occurred while processing the request.",innerError:o,discard:!0})),a.reject(o)};r.then(d,m)}return a}}class Oe{constructor(){g(this,"graph");g(this,"requestAttemptCounter");this.graph=new mu.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Oe;for(let n=0;n<e.length;n++){const a=e[n];if(!a){console.error("Outbox item was undefined");continue}s.sneakRequest(a);for(let c=0;c<n;c++){const r=e[c];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==a.payload.uuid&&r.payload.blocks.some(d=>a.payload.blockers.includes(d))&&Oe._addDependency(a.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){Oe._addDependency(e,s,this.graph)}static _addDependency(e,s,n){if(e===s)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!n.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${s})`);if(!n.hasNode(s))throw new Error(`Tried to add dependency to non-existent node: ${s} (from node: ${e})`);n.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 n=this.graph.getNodeData(s);e.payload.blockers.some(a=>n.payload.blocks.includes(a))&&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(a=>e.payload.blocks.includes(a))&&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,n;for(const a of e){const c=this.requestAttemptCounter[a]||0;c<s&&(s=c,n=a)}return n}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(n=>this.graph.getNodeData(n)),s=this._getNextNode();if(s){const n=this.graph.getNodeData(s),a=e.findIndex(c=>c.payload.uuid===n.payload.uuid);a!==-1&&(e.splice(a,1),e.unshift(n))}return e}getReady(){let e=this.graph.overallOrder(!0).map(s=>this.graph.getNodeData(s));return e=e.sort((s,n)=>s.meta.offline.effect.timestamp.localeCompare(n.meta.offline.effect.timestamp)),e=e.sort((s,n)=>{const a=this.requestAttemptCounter[s.payload.uuid]||0,c=this.requestAttemptCounter[n.payload.uuid]||0;return a-c}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const uA=(t,e)=>{const s=new e(t);return Lp(s),Gp(t),s};class R extends Kl{constructor(s,n){super(s);g(this,"auth");this.auth=n}}class hA extends R{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:u.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(n=>(this.dispatch(Vn(n)),n))}async continueConversation(e,s,n){return this.enqueueRequest({description:"Prompt agent",method:u.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:n},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(a=>{this.dispatch(Un(a))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:u.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(Cn(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:u.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:u.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(zn(s))}}class E extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:d,formSubmissionAttachmentReducer:m,geoImageReducer:o,assetTypeFieldsAttachmentReducer:h,assetTypeFieldValuesAttachmentReducer:f,issueTypeFieldsAttachmentReducer:p,issueTypeFieldValuesAttachmentReducer:A}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(n.instances),Object.values(a.instances),Object.values(c.instances),Object.values(r.instances),Object.values(d.instances),Object.values(m.instances),Object.values(o.instances),Object.values(h.instances),Object.values(f.instances),Object.values(p.instances),Object.values(A.instances)).filter(T=>T.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[n,a]of Object.entries(e))s[n]=this.enqueueRequest({url:a.url,description:"Upload file to S3",method:u.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:n,blockers:[`s3-${a.fields.key}`],blocks:[n],s3url:a});return s}async getFilePayload(e){const s=await be(e),n={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),n}}class Le extends E{async _bulkAdd(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=[],r=[],d={};for(const h of e){const{modelId:f,file:p}=h,A=await this.getFilePayload(p);A.sha1 in d||(d[A.sha1]=A);const _=this.buildOfflineAttachment({file:p,file_sha1:A.sha1,submitted_at:a,created_by:n,description:"",modelId:f});c.push(_),r.push(this.buildAttachmentPayload({offline_id:_.offline_id,file_name:_.file_name,file_sha1:_.file_sha1,file_extension:A.extension,description:_.description,modelId:f}))}this.dispatch(this.addAttachments(c));const m=this.enqueueRequest({description:`Add ${this.name}`,method:u.POST,url:`${this.url}/bulk/`,payload:{submitted_at:a,attachments:r,files:Object.values(d)},blocks:c.map(h=>h.offline_id),blockers:c.map(h=>h.file_sha1)});return m.then(({attachments:h,presigned_urls:f})=>{this.dispatch(this.updateAttachments(h)),this.processPresignedUrls(f)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(h=>h.offline_id)))}),[c,m.then(({attachments:h})=>h)]}async _delete(e){const{store:s}=this.client,n=this.selectAttachment(e)(s.getState());if(!n)throw new Error(`Attempting to delete attachment with offline_id ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(n.offline_id));const a=this.enqueueRequest({description:`Delete ${this.name}`,method:u.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return a.then(()=>{this.getNumberOfAttachmentsWithSha1(n.file_sha1)===0&&this.client.files.removeCache(n.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(n))}),a}}class mA extends Le{constructor(){super(...arguments);g(this,"name","Asset Attachment");g(this,"url","/asset-attachments");g(this,"initializeAttachments",Et);g(this,"addAttachments",jt);g(this,"updateAttachments",Ln);g(this,"removeAttachments",qt);g(this,"removeAttachment",Nn);g(this,"setAttachment",Gn);g(this,"selectAttachment",Wn)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelId})}buildAttachmentPayload(s){return{...s,asset:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(Et(n))}}class fA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(Zn(c));const d=this.enqueueRequest({description:"Add asset procedure fields attachments",method:u.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Qn(o.attachments))}).catch(()=>{this.dispatch(xn(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:u.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Xn(s))}}class pA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(aa(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:u.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(ca(m))}).catch(m=>{throw this.dispatch(ra(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:u.GET,url:"/asset-procedure-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(na(s))}}function Ne(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class AA extends E{async bulkAdd(e,s){var o;const n=new Date().toISOString(),a=(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,c=Ne(e,s??e.length),r=[],d=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:_,fieldIdentifier:T,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const q=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:_,submitted_at:n,field_identifier:T});r.push(q);const St={offline_id:q.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:T,field_values:_};p.push(St)}d.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(We(r));const m=d.map(h=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:u.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(ha(f))}).catch(h=>{throw this.dispatch(Ke(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=fa(e)(n);this.dispatch(Ke(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:u.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(We(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:u.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ua(s))}}const yA=t=>Array.isArray(t)&&t[0]instanceof File,ve=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:yA(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class SA extends E{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:u.POST,url:"/form-submissions/",payload:a,blockers:["add-form-entry",e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[a.offline_id]});return this.dispatch(ni(a)),c.then(d=>(this.dispatch(nt(d)),d)).catch(()=>{this.dispatch(ai(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=oi(e.offline_id)(n);if(!a)throw new Error(`Expected submission with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Jr(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:u.PATCH,url:`/form-submissions/${c.offline_id}/`,payload:e,blockers:[c.offline_id],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(nt(d))}).catch(()=>{this.dispatch(nt(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=oi(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Hr(e)(n);this.dispatch(ai(e)),this.dispatch(it(c.map(r=>r.offline_id)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:u.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ni(a)),this.dispatch(st(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:u.GET,url:"/form-submissions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Yr(s))}}class gA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:u.POST,url:"/asset-procedure-field-values/",payload:a,blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[a.offline_id]});return this.dispatch($t(a)),c.then(d=>(this.dispatch(Ee(d)),d)).catch(()=>{this.dispatch(Bt(a.offline_id))}),[a,c]}bulkAdd(e,s){var o;const n=new Date().toISOString(),{values:a}=ve(e.values),c=[],r=Ne(e.payloads,s??e.payloads.length),d=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:ve(p.values).values,created_by:(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,published_at:p.published_at,values:A.values})}d.push({submitted_at:n,values:a,field_values:f})}this.dispatch(ga(c));const m=[];for(const h of d){const f=h.field_values.map(b=>b.asset),p=h.field_values.map(b=>b.fields_revision),A=h.field_values.map(b=>b.asset_procedure_instance),_=h.field_values.map(b=>b.offline_id),T=this.enqueueRequest({description:"Bulk add asset procedure field values",method:u.POST,url:"/asset-procedure-field-values/bulk/",payload:h,blockers:[...f,...p,...A],blocks:_});m.push(T)}return Promise.all(m).then(h=>{this.dispatch(ba(h.flat()))}).catch(()=>{this.dispatch(_a(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Lt(e.offline_id)(n);if(!a)throw new Error(`Expected AssetProcedureFieldValues with offline_id ${e.offline_id} to exist`);const{values:c}=ve(e.values??{}),r={...a,...e,values:{...a.values,...c}};this.dispatch(Ee(r));const d=this.enqueueRequest({description:"Update asset procedure field values",method:u.PATCH,url:`/asset-procedure-field-values/${e.offline_id}/`,payload:{...e,values:{...a.values,...c}},blockers:[r.fields_revision,r.asset,r.asset_procedure_instance],blocks:[r.offline_id]});return d.then(m=>{this.dispatch(Ee(m))}).catch(()=>{this.dispatch(Ee(a))}),[r,d]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Lt(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=pa(e)(n);this.dispatch(Bt(e)),this.dispatch(Ke(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:u.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch($t(a)),this.dispatch(We(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:u.GET,url:"/asset-procedure-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Sa(s))}}class bA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Ht(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:u.POST,url:"/asset-procedure-instances/",payload:{...c},blockers:[e.asset_procedure,e.asset_type],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(je(d))}).catch(()=>{this.dispatch(Wt(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=Jt(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure instance with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(je(a));const c=this.enqueueRequest({description:"Update asset procedure instance",method:u.PATCH,url:`/asset-procedure-instances/${e.offline_id}/`,payload:{asset_procedure:e.asset_procedure,asset_type:e.asset_type},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(je(r))}).catch(()=>{this.dispatch(je(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Jt(e)(n);if(!a)throw new Error(`Expected asset procedure instance with offline_id ${e} to exist`);return this.dispatch(Wt(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:u.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Ht(a)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:u.GET,url:"/asset-procedure-instances/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ra(s))}}class _A extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Zt(c));const r=this.enqueueRequest({description:"Create asset procedure",method:u.POST,url:"/asset-procedures/",queryParams:{organization_id:e.organization.toString()},payload:{...c},blockers:[],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(qe(d))}).catch(()=>{this.dispatch(Qt(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=es(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(qe(a));const c=this.enqueueRequest({description:"Update asset procedure",method:u.PATCH,url:`/asset-procedures/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(qe(r))}).catch(()=>{this.dispatch(qe(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=es(e)(n);if(!a)throw new Error(`Expected asset procedure with offline_id ${e} to exist`);const c=va(e)(n);return this.dispatch(Qt(e)),this.dispatch(Oa(c.map(r=>r.offline_id))),this.enqueueRequest({description:"Delete asset procedure",method:u.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(Zt(a)),this.dispatch(Pa(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:u.GET,url:"/asset-procedures/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(ja(s))}}class TA extends R{add(e){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 n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(ss(c));const r=this.enqueueRequest({description:"Create asset",method:u.POST,url:"/assets/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(Me(d))}).catch(()=>{this.dispatch(ns(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=rs(e.offline_id)(s.getState());if(!n)throw new Error(`No asset with id ${e.offline_id} found in the store`);const a={...n,...e};if(!a.canvas_marker&&!a.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(Me(a));const c=this.enqueueRequest({description:"Edit asset",method:u.PATCH,url:`/assets/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(Me(r))}).catch(()=>{this.dispatch(Me(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=rs(e)(n);if(!a)throw new Error(`No asset with id ${e} found in the store`);const c=Kn(e)(n),r=Qr(e)(n),d=yo(e)(n);if(this.dispatch(ns(e)),c.length>0){const m=c.map(({offline_id:o})=>o);this.dispatch(qt(m))}if(r.length>0){const m=r.map(({offline_id:o})=>o);this.dispatch(ct(m))}if(d.length>0){const m=d.map(({offline_id:o})=>o);this.dispatch(Ai(m))}return this.enqueueRequest({description:"Delete asset",method:u.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(ss(a)),this.dispatch(jt(c)),this.dispatch(at(r)),this.dispatch(fi(d)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),r=O.v4(),d=Ne(e,a).map(h=>{const f=h.map(p=>F(p));return{batchId:O.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:n,assets:f}}}),m=[];let o=null;for(const h of d){const{batchId:f,payload:p}=h,A=p.assets.map(P=>P.offline_id),_=[s];o&&_.push(o);const T=A;T.push(f);const b=this.enqueueRequest({description:"Batch create assets",method:u.POST,url:"/assets/bulk/",payload:p,blockers:_,blocks:T});o=h.batchId,m.push(b)}return Promise.all(m).then(h=>{const f=h.flat();this.dispatch(is(f))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:u.GET,url:"/assets/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Da(s))}}class FA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(ds(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:u.POST,url:"/asset-stage-completions/",payload:{offline_id:c.offline_id,submitted_at:a,asset_procedure_instance:e.asset_procedure_instance,asset:e.asset,stage:e.stage},blockers:[e.asset_procedure_instance,e.stage],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(Ba(d))}).catch(()=>{this.dispatch(us(c.offline_id))}),[c,r]}delete(e){const{store:s}=this.client,n=Na(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with id ${e} to exist`);this.dispatch(us(e));const a=this.enqueueRequest({description:"Delete asset stage completion",method:u.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(ds(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.id,c=e.map(o=>F(o)),r=c.map(o=>({...o,created_by:a,submitted_at:n})),d=r.map(({offline_id:o})=>o);this.dispatch(ls(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:u.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:n,completions:c},blockers:[...e.map(o=>o.asset_procedure_instance),...e.map(o=>o.stage),...e.map(o=>o.asset)],blocks:d});return m.then(o=>{this.dispatch(Ga(o))}).catch(()=>{this.dispatch(hs(d))}),[r,m]}bulkDelete(e){const{store:s}=this.client,n=Ha(e)(s.getState());this.dispatch(hs(e));const a=this.enqueueRequest({description:"Deleting asset stage completions",method:u.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ls(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:u.GET,url:"/asset-stage-completions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch($a(s))}}class IA extends R{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.id,c=e.map(m=>F(m)),r=c.map(m=>({...m,asset_procedure:s,created_by:a,submitted_at:n}));this.dispatch(ps(r));const d=this.enqueueRequest({description:"Add asset stages",method:u.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({offline_id:m})=>m)});return d.then(m=>{this.dispatch(Ye(m))}).catch(()=>{this.dispatch(ys(r.map(({offline_id:m})=>m)))}),[r,d]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Ss(e.map(({offline_id:r})=>r))(a);return this.dispatch(Ye(e)),this.enqueueRequest({description:"Edit asset stages",method:u.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({offline_id:r})=>r)}).catch(r=>{throw this.dispatch(Ye(c)),r})}async bulkDelete(e){const{store:s}=this.client,n=Ss(e)(s.getState());this.dispatch(ys(e));const a=this.enqueueRequest({description:"Delete asset stages",method:u.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ps(n))}),a}update(e){const{store:s}=this.client,n=Xa(e.offline_id)(s.getState());if(!n)throw new Error(`No asset stage with id ${e.offline_id} found in the store`);const a={...n,...e};this.dispatch(As(a));const c=this.enqueueRequest({description:"Update asset stage",method:u.PATCH,url:`/asset-stages/${n.offline_id}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(As(r))}).catch(()=>{this.dispatch(Ya(n))}),[a,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:u.GET,url:"/asset-stages/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Ka(s))}}class RA extends Le{constructor(){super(...arguments);g(this,"name","Asset Type Attachment");g(this,"url","/asset-type-attachments");g(this,"addAttachments",bs);g(this,"updateAttachments",tc);g(this,"removeAttachments",_s);g(this,"removeAttachment",sc);g(this,"setAttachment",ec);g(this,"selectAttachment",nc)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelId})}buildAttachmentPayload(s){return{...s,asset_type:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetTypeId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset type attachments",method:u.GET,url:`${this.url}/`,queryParams:{organization:s.toString()},blocks:[],blockers:[]});this.dispatch(xa(n))}}class PA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(dc(c));const d=this.enqueueRequest({description:"Add asset type fields attachments",method:u.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(lc(o.attachments))}).catch(()=>{this.dispatch(uc(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:u.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(oc(s))}}class OA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(yc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:u.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(Sc(m))}).catch(m=>{throw this.dispatch(gc(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:u.GET,url:"/asset-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Ac(s))}}class vA extends E{async bulkAdd(e,s){var o;const n=new Date().toISOString(),a=(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,c=Ne(e,s??e.length),r=[],d=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:_,fieldIdentifier:T,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const q=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:_,submitted_at:n,field_identifier:T});r.push(q);const St={offline_id:q.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:T,field_values:_};p.push(St)}d.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(Ze(r));const m=d.map(h=>this.enqueueRequest({description:"Add asset type field values attachments",method:u.POST,url:"/asset-type-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(Ic(f))}).catch(h=>{throw this.dispatch(Qe(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Pc(e)(n);this.dispatch(Qe(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:u.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(Ze(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:u.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Fc(s))}}class wA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:u.POST,url:"/asset-type-field-values/",payload:a,blockers:[e.asset,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(vs(a)),c.then(d=>(this.dispatch(ke(d)),d)).catch(()=>{this.dispatch(ws(a.offline_id))}),[a,c]}bulkAdd(e,s){var o;const n=new Date().toISOString(),{values:a}=ve(e.values),c=[],r=Ne(e.payloads,s??e.payloads.length),d=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:ve(p.values).values,created_by:(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}d.push({submitted_at:n,values:a,field_values:f})}this.dispatch(jc(c));const m=[];for(const h of d){const f=h.field_values.map(T=>T.asset),p=h.field_values.map(T=>T.fields_revision),A=h.field_values.map(T=>T.offline_id),_=this.enqueueRequest({description:"Bulk add asset type field values",method:u.POST,url:"/asset-type-field-values/bulk/",payload:h,blockers:[...f,...p],blocks:A});m.push(_)}return Promise.all(m).then(h=>{this.dispatch(qc(h.flat()))}).catch(()=>{this.dispatch(Mc(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=js(e.offline_id)(n);if(!a)throw new Error(`Expected AssetTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(ke(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:u.PATCH,url:`/asset-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.asset],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(ke(d))}).catch(()=>{this.dispatch(ke(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=js(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Oc(e)(n);this.dispatch(ws(e)),this.dispatch(Qe(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset type field values",method:u.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(vs(a)),this.dispatch(Ze(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:u.GET,url:"/asset-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ec(s))}}class EA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Ms(c));const r=this.enqueueRequest({description:"Create asset type",method:u.POST,url:"/asset-types/",payload:c,blockers:[],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(De(d))}).catch(()=>{this.dispatch(ks(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=zs(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset type with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(De(a));const c=this.enqueueRequest({description:"Update asset type",method:u.PATCH,url:`/asset-types/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(De(r))}).catch(()=>{this.dispatch(De(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=zs(e)(n);if(!a)throw new Error(`Expected asset type with offline_id ${e} to exist`);const c=cs(e)(n),r=ac(e)(n);return this.dispatch(ks(e)),this.dispatch(za(c.map(d=>d.offline_id))),this.dispatch(_s(r.map(({offline_id:d})=>d))),this.enqueueRequest({description:"Delete asset type",method:u.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(d=>{throw this.dispatch(Ms(a)),this.dispatch(is(c)),this.dispatch(bs(r)),d})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:u.GET,url:"/asset-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Vc(s))}}class jA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Cs(c));const r=this.enqueueRequest({description:"Create Category",method:u.POST,url:"/categories/",payload:c,blockers:[e.project.toString()],blocks:[c.offline_id]});return[c,r]}update(e){const s=this.client.store.getState(),n=$s(e.offline_id)(s);if(!n)throw new Error(`Expected an existing category with offline_id ${e.offline_id}`);const a={...n,...e};this.dispatch(Nc(a));const c=this.enqueueRequest({description:"Edit Category",method:u.PATCH,url:`/categories/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return[a,c]}remove(e){const{store:s}=this.client,n=$s(e)(s.getState());if(!n)throw new Error(`No category with id ${e} found in the store`);this.dispatch(Hc(e));const a=this.enqueueRequest({description:"Delete Category",method:u.DELETE,url:`/categories/${n.offline_id}/`,blockers:[n.offline_id],blocks:[]});return a.catch(()=>{this.dispatch(Cs(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:u.GET,url:"/categories/",queryParams:{project:e.toString()},blocks:[],blockers:[]});this.dispatch(Lc(s))}}class qA extends Le{constructor(){super(...arguments);g(this,"name","Document Attachment");g(this,"url","/document-attachments");g(this,"addAttachments",Jc);g(this,"updateAttachments",Zc);g(this,"removeAttachments",xc);g(this,"removeAttachment",Qc);g(this,"setAttachment",Xc);g(this,"selectAttachment",tr)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelId})}buildAttachmentPayload(s){return{...s,document:s.modelId}}async bulkAdd(s){var f;const{store:n}=this.client,a=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,c=new Date().toISOString(),r=[],d=[],m={},o={};for(const p of s){const{documentId:A,file:_}=p,T=await this.getFilePayload(_);T.sha1 in m||(m[T.sha1]=T,o[T.sha1]=[]);const b=this.buildOfflineAttachment({file:_,file_sha1:T.sha1,submitted_at:c,created_by:a,description:"",modelId:A});r.push(b),d.push({offline_id:b.offline_id,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:T.extension,description:b.description,document:A}),o[T.sha1].push(b.offline_id)}this.dispatch(this.addAttachments(r));const h=this.enqueueRequest({description:"Attach files to document",method:u.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:d,files:Object.values(m)},blocks:r.map(p=>p.offline_id),blockers:r.map(p=>p.file_sha1)});return h.then(({attachments:p,presigned_urls:A})=>{this.dispatch(this.updateAttachments(p));const _=this.processPresignedUrls(A);for(const[T,b]of Object.entries(_))b.then(()=>{const P=o[T];for(const q of P)this.makeReadable(q)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(p=>p.offline_id)))}),[r,h.then(({attachments:p})=>p)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:u.PATCH,url:`/document-attachments/${s}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",s],blocks:["index-document-attachment"]})}async refreshStore(s,n){const a=await this.enqueueRequest({description:"Get document attachments",method:u.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Yc(a));const c=await this.enqueueRequest({description:"Get document attachments",method:u.GET,url:`/organizations/${n}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class MA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Ns([c]));const r=this.enqueueRequest({description:"Create Document",method:u.POST,url:"/documents/",payload:c,queryParams:{parent_document:c.parent_document??void 0},blockers:c.parent_document?[c.parent_document]:[],blocks:[c.offline_id]});return r.catch(()=>{this.dispatch(Hs([c.offline_id]))}),[c,r]}update(e){const{store:s}=this.client,n=s.getState().documentsReducer.documents[e.offline_id];if(!n)throw new Error(`attempting to update a document with offline_id ${e.offline_id} that does not exist in store.documents`);const a={...n,...e};this.dispatch(le([a]));const c=this.enqueueRequest({description:"Update Document",method:u.PATCH,url:`/documents/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{le([n])}),[a,c]}move(e,s,n){const{store:a}=this.client,c=_e(a.getState()),r=[],d=c[e];if(!d)throw new Error(`attempting to move a document with offline_id ${e} that does not exist in store.documents`);if(r.push(d),d.parent_document&&r.push(c[d.parent_document]),s){const o=c[s];if(!o)throw new Error(`attempting to move a document to target with offline_id ${s} that does not exist in store.documents`);r.push(o),o.parent_document&&r.push(c[o.parent_document])}this.dispatch(ar({documentId:e,targetDocumentId:s,position:n}));const m=this.enqueueRequest({description:"Move Document",method:u.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:n},blockers:[e],blocks:[]});return m.then(o=>{this.dispatch(le(o))}).catch(()=>{this.dispatch(le(r))}),m}delete(e){const{store:s}=this.client,n=_e(s.getState()),a=rr(e)(s.getState());if(!a)throw new Error(`attempting to delete a document with offline_id ${e} that does not exist in store.documents`);const c=a.parent_document?n[a.parent_document]:void 0;this.dispatch(Hs([e]));const r=this.enqueueRequest({description:"Delete Document",method:u.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(d=>{this.dispatch(le(d))}).catch(()=>{this.dispatch(le([a])),c&&this.dispatch(le([c]))}),r}async refreshStore(e,s){const n=this.enqueueRequest({description:"Get project documents",method:u.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),a=this.enqueueRequest({description:"Get organization documents",method:u.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(nr(await n)),this.dispatch(Ns(await a))}}class kA extends R{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:u.POST,url:`/organizations/${e}/email-domains/`,payload:{email:s},blockers:[e.toString(),"create-org"],blocks:[]})}async remove(e){return this.dispatch(ur(e.offline_id)),this.enqueueRequest({description:"Remove email domain from organization",method:u.DELETE,url:`/organizations/${e.organization}/email-domains/${e.offline_id}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(lr(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:u.GET,url:`/organizations/${e}/email-domains/`,blockers:[e.toString()],blocks:[]});this.dispatch(dr(s))}}class DA extends R{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:u.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:u.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const At={},An=new Set;let yt=0,yn=0,Sn=0;const zA=20;class VA extends R{constructor(){super(...arguments);g(this,"host");g(this,"_dbPromise",fu.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const n=await this.fetchCache(s);if(!n)throw new Error(`File with sha1 ${s} not found in cache`);const a=await Pt(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:u.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await be(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(yr({sha1:s,...c})),c}async addCache(s,n){if(An.has(n))return;if(!s.type){const r=s.name.split("."),d=r[r.length-1];s=new File([s],s.name,{type:d})}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 a=await this._dbPromise;!!await a.get("files",n)?(console.error("File already cached (this is unexpected at this point):",s.name,n),yt++):(await a.put("files",s,n),yn++),An.add(n),Sn++,Sn%zA===0&&console.debug(`File cache summary: ${yt} hits and ${yn} misses, ${yt/(yt+yn)*100}% hit rate over ${Sn} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),An.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return Sr(s)(n)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const n=await this.fetchCache(s);if(!n)throw new Error(`File with sha1 ${s} not found in cache`);const a=await Pt(n,s),c={file_name:n.name,file_sha1:s,file:a},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[c,Promise.resolve(void 0).then()];throw new Error(r.warning)}const d=r.url,m=this.enqueueRequest({url:d,description:"Upload file",method:u.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${a}`],blocks:[s],s3url:r});return[c,m]}async fetchFileFromUrl(s,n,a){const c=s.split("?")[0]??s,r=await this.fetchCache(n);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const h=await jn(s),f=new File([h],a??n,{type:h.type});return await this.addCache(f,n),f}let d=At[c],m=!0;d?m=!1:(d=new Promise(h=>{this.enqueueRequest({description:"Download file",method:u.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[n],blocks:[n]}).then(f=>{const p=new File([f],a??n,{type:f.type});h(p)})}),At[c]=d);let o;try{o=await d}catch(h){throw m&&h instanceof j&&delete At[c],h}if(m){const h=await be(o);if(h!==n){const A=`The hash of the file returned from the server (${h}) does not match the
8
+ `)}catch(a){console.error("Failed to extract error message from response body",a)}}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>VA?Ee:s}class q extends Error{constructor(s){super(Ee);y(this,"status");y(this,"response");y(this,"message");y(this,"options");const{response:n,innerError:a}=s;this.message=s.message??UA(n,a)??Ee,this.status=(n==null?void 0:n.status)??0,this.response=n,s.discard=s.discard??!1,this.options=s}}class $A{constructor(e){y(this,"store");this.store=e}async enqueueRequest(e,s,n){return this._enqueueRequest(e,s,n).then(a=>{if(a instanceof q)throw a;return a})}_enqueueRequest(e,s,n){const a=new wn,c={...e,BASE_URL:s,serviceName:n};if(e.immediate){const r={...c,uuid:e.uuid??O.v4()},o={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:n}}}};An(o,this).then(m=>{a.resolve(m.body)}).catch(m=>{yn(m,o),m instanceof Error?a.reject(m):a.reject(new Error((m??Ee).toString()))})}else{const r=this.store.dispatch(Dl(c)),o=d=>{if(d)a.resolve(d.body);else{const h=new q({message:"Could not get a response from the server.",response:d,discard:!0});a.reject(h)}},m=d=>{d instanceof q?d.options.discard=!0:(console.error("Received an unexpected error while processing a request:",d,`
9
+ Converting error to APIError and discarding.`),d=new q({message:"An error occurred while processing the request.",innerError:d,discard:!0})),a.reject(d)};r.then(o,m)}return a}}class je{constructor(){y(this,"graph");y(this,"requestAttemptCounter");this.graph=new Uu.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new je;for(let n=0;n<e.length;n++){const a=e[n];if(!a){console.error("Outbox item was undefined");continue}s.sneakRequest(a);for(let c=0;c<n;c++){const r=e[c];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==a.payload.uuid&&r.payload.blocks.some(o=>a.payload.blockers.includes(o))&&je._addDependency(a.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){je._addDependency(e,s,this.graph)}static _addDependency(e,s,n){if(e===s)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!n.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${s})`);if(!n.hasNode(s))throw new Error(`Tried to add dependency to non-existent node: ${s} (from node: ${e})`);n.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 n=this.graph.getNodeData(s);e.payload.blockers.some(a=>n.payload.blocks.includes(a))&&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(a=>e.payload.blocks.includes(a))&&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,n;for(const a of e){const c=this.requestAttemptCounter[a]||0;c<s&&(s=c,n=a)}return n}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(n=>this.graph.getNodeData(n)),s=this._getNextNode();if(s){const n=this.graph.getNodeData(s),a=e.findIndex(c=>c.payload.uuid===n.payload.uuid);a!==-1&&(e.splice(a,1),e.unshift(n))}return e}getReady(){let e=this.graph.overallOrder(!0).map(s=>this.graph.getNodeData(s));return e=e.sort((s,n)=>s.meta.offline.effect.timestamp.localeCompare(n.meta.offline.effect.timestamp)),e=e.sort((s,n)=>{const a=this.requestAttemptCounter[s.payload.uuid]||0,c=this.requestAttemptCounter[n.payload.uuid]||0;return a-c}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const BA=(t,e)=>{const s=new e(t);return gA(s),SA(t),s};class R extends gu{constructor(s,n){super(s);y(this,"auth");this.auth=n}}class GA extends R{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:l.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(n=>(this.dispatch(Un(n)),n))}async continueConversation(e,s,n){return this.enqueueRequest({description:"Prompt agent",method:l.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:n},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(a=>{this.dispatch(Bn(a))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:l.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch($n(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:l.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:l.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(Vn(s))}}class j extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:o,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:h,assetTypeFieldValuesAttachmentReducer:f,issueTypeFieldsAttachmentReducer:p,issueTypeFieldValuesAttachmentReducer:A}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(n.instances),Object.values(a.instances),Object.values(c.instances),Object.values(r.instances),Object.values(o.instances),Object.values(m.instances),Object.values(d.instances),Object.values(h.instances),Object.values(f.instances),Object.values(p.instances),Object.values(A.instances)).filter(_=>_.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[n,a]of Object.entries(e))s[n]=this.enqueueRequest({url:a.url,description:"Upload file to S3",method:l.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:n,blockers:[`s3-${a.fields.key}`],blocks:[n],s3url:a});return s}async getFilePayload(e){const s=await Ie(e),n={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),n}}class be extends j{async _bulkAdd(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=[],r=[],o={};for(const h of e){const{modelId:f,file:p}=h,A=await this.getFilePayload(p);A.sha1 in o||(o[A.sha1]=A);const T=this.buildOfflineAttachment({file:p,file_sha1:A.sha1,submitted_at:a,created_by:n,description:"",modelId:f});c.push(T),r.push(this.buildAttachmentPayload({offline_id:T.offline_id,file_name:T.file_name,file_sha1:T.file_sha1,file_extension:A.extension,description:T.description,modelId:f}))}this.dispatch(this.addAttachments(c));const m=this.enqueueRequest({description:`Add ${this.name}`,method:l.POST,url:`${this.url}/bulk/`,payload:{submitted_at:a,attachments:r,files:Object.values(o)},blocks:c.map(h=>h.offline_id),blockers:c.map(h=>h.file_sha1)});return m.then(({attachments:h,presigned_urls:f})=>{this.dispatch(this.updateAttachments(h)),this.processPresignedUrls(f)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(h=>h.offline_id)))}),[c,m.then(({attachments:h})=>h)]}async _delete(e){const{store:s}=this.client,n=this.selectAttachment(e)(s.getState());if(!n)throw new Error(`Attempting to delete attachment with offline_id ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(n.offline_id));const a=this.enqueueRequest({description:`Delete ${this.name}`,method:l.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return a.then(()=>{this.getNumberOfAttachmentsWithSha1(n.file_sha1)===0&&this.client.files.removeCache(n.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(n))}),a}}class LA extends be{constructor(){super(...arguments);y(this,"name","Asset Attachment");y(this,"url","/asset-attachments");y(this,"initializeAttachments",kt);y(this,"addAttachments",Ct);y(this,"updateAttachments",Hn);y(this,"removeAttachments",Dt);y(this,"removeAttachment",Wn);y(this,"setAttachment",Nn);y(this,"selectAttachment",Jn)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelId})}buildAttachmentPayload(s){return{...s,asset:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(kt(n))}}class NA extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(_)}this.dispatch(ea(c));const o=this.enqueueRequest({description:"Add asset procedure fields attachments",method:l.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(ta(d.attachments))}).catch(()=>{this.dispatch(sa(c.map(d=>d.offline_id)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:l.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(xn(s))}}class HA extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(da(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:l.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(oa(m))}).catch(m=>{throw this.dispatch(la(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:l.GET,url:"/asset-procedure-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(ra(s))}}function Ke(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class WA extends j{async bulkAdd(e,s){var d;const n=new Date().toISOString(),a=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=Ke(e,s??e.length),r=[],o=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:T,fieldIdentifier:_,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const M=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:T,submitted_at:n,field_identifier:_});r.push(M);const _t={offline_id:M.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:_,field_values:T};p.push(_t)}o.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(Je(r));const m=o.map(h=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:l.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(pa(f))}).catch(h=>{throw this.dispatch(Xe(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ya(e)(n);this.dispatch(Xe(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:l.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(Je(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:l.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(fa(s))}}const KA=t=>Array.isArray(t)&&t[0]instanceof File,qe=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:KA(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class YA extends j{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:l.POST,url:"/form-submissions/",payload:v(a),blockers:["add-form-entry",e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[a.offline_id]});return this.dispatch(ni(a)),c.then(o=>(this.dispatch(rt(o)),o)).catch(()=>{this.dispatch(ai(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=di(e.offline_id)(n);if(!a)throw new Error(`Expected submission with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(ed(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:l.PATCH,url:`/form-submissions/${c.offline_id}/`,payload:e,blockers:[c.offline_id],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(rt(o))}).catch(()=>{this.dispatch(rt(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=di(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Xr(e)(n);this.dispatch(ai(e)),this.dispatch(ct(c.map(r=>r.offline_id)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:l.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ni(a)),this.dispatch(at(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:l.GET,url:"/form-submissions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(xr(s))}}class JA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:l.POST,url:"/asset-procedure-field-values/",payload:a,blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[a.offline_id]});return this.dispatch(Lt(a)),c.then(o=>(this.dispatch(ke(o)),o)).catch(()=>{this.dispatch(Nt(a.offline_id))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=qe(e.values),c=[],r=Ke(e.payloads,s??e.payloads.length),o=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:qe(p.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,published_at:p.published_at,values:A.values})}o.push({submitted_at:n,values:a,field_values:f})}this.dispatch(_a(c));const m=[];for(const h of o){const f=h.field_values.map(b=>b.asset),p=h.field_values.map(b=>b.fields_revision),A=h.field_values.map(b=>b.asset_procedure_instance),T=h.field_values.map(b=>b.offline_id),_=this.enqueueRequest({description:"Bulk add asset procedure field values",method:l.POST,url:"/asset-procedure-field-values/bulk/",payload:h,blockers:[...f,...p,...A],blocks:T});m.push(_)}return Promise.all(m).then(h=>{this.dispatch(Fa(h.flat()))}).catch(()=>{this.dispatch(Ia(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Wt(e.offline_id)(n);if(!a)throw new Error(`Expected AssetProcedureFieldValues with offline_id ${e.offline_id} to exist`);const{values:c}=qe(e.values??{}),r={...a,...e,values:{...a.values,...c}};this.dispatch(ke(r));const o=this.enqueueRequest({description:"Update asset procedure field values",method:l.PATCH,url:`/asset-procedure-field-values/${e.offline_id}/`,payload:{...e,values:{...a.values,...c}},blockers:[r.fields_revision,r.asset,r.asset_procedure_instance],blocks:[r.offline_id]});return o.then(m=>{this.dispatch(ke(m))}).catch(()=>{this.dispatch(ke(a))}),[r,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Wt(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Sa(e)(n);this.dispatch(Nt(e)),this.dispatch(Xe(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:l.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Lt(a)),this.dispatch(Je(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:l.GET,url:"/asset-procedure-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ta(s))}}class XA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Yt(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:l.POST,url:"/asset-procedure-instances/",payload:{...c},blockers:[e.asset_procedure,e.asset_type],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Ce(o))}).catch(()=>{this.dispatch(Jt(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=Zt(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure instance with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(Ce(a));const c=this.enqueueRequest({description:"Update asset procedure instance",method:l.PATCH,url:`/asset-procedure-instances/${e.offline_id}/`,payload:{asset_procedure:e.asset_procedure,asset_type:e.asset_type},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(Ce(r))}).catch(()=>{this.dispatch(Ce(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Zt(e)(n);if(!a)throw new Error(`Expected asset procedure instance with offline_id ${e} to exist`);return this.dispatch(Jt(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:l.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Yt(a)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:l.GET,url:"/asset-procedure-instances/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(va(s))}}class QA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(es(c));const r=this.enqueueRequest({description:"Create asset procedure",method:l.POST,url:"/asset-procedures/",queryParams:{organization_id:e.organization.toString()},payload:{...c},blockers:[],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(De(o))}).catch(()=>{this.dispatch(ts(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=is(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(De(a));const c=this.enqueueRequest({description:"Update asset procedure",method:l.PATCH,url:`/asset-procedures/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(De(r))}).catch(()=>{this.dispatch(De(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=is(e)(n);if(!a)throw new Error(`Expected asset procedure with offline_id ${e} to exist`);const c=ja(e)(n);return this.dispatch(ts(e)),this.dispatch(Ea(c.map(r=>r.offline_id))),this.enqueueRequest({description:"Delete asset procedure",method:l.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(es(a)),this.dispatch(wa(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:l.GET,url:"/asset-procedures/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(ka(s))}}class ZA extends R{add(e){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 n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(as(c));const r=this.enqueueRequest({description:"Create asset",method:l.POST,url:"/assets/",payload:v(c),blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(ze(o))}).catch(()=>{this.dispatch(rs(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=ls(e.offline_id)(s.getState());if(!n)throw new Error(`No asset with id ${e.offline_id} found in the store`);const a={...n,...e};if(!a.canvas_marker&&!a.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(ze(a));const c=this.enqueueRequest({description:"Edit asset",method:l.PATCH,url:`/assets/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(ze(r))}).catch(()=>{this.dispatch(ze(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=ls(e)(n);if(!a)throw new Error(`No asset with id ${e} found in the store`);const c=Xn(e)(n),r=id(e)(n),o=Td(e)(n);if(this.dispatch(rs(e)),c.length>0){const m=c.map(({offline_id:d})=>d);this.dispatch(Dt(m))}if(r.length>0){const m=r.map(({offline_id:d})=>d);this.dispatch(ot(m))}if(o.length>0){const m=o.map(({offline_id:d})=>d);this.dispatch(Ai(m))}return this.enqueueRequest({description:"Delete asset",method:l.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(as(a)),this.dispatch(Ct(c)),this.dispatch(dt(r)),this.dispatch(fi(o)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),r=O.v4(),o=Ke(e,a).map(h=>{const f=h.map(p=>F(p));return{batchId:O.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:n,assets:f}}}),m=[];let d=null;for(const h of o){const{batchId:f,payload:p}=h,A=p.assets.map(P=>P.offline_id),T=[s];d&&T.push(d);const _=A;_.push(f);const b=this.enqueueRequest({description:"Batch create assets",method:l.POST,url:"/assets/bulk/",payload:p,blockers:T,blocks:_});d=h.batchId,m.push(b)}return Promise.all(m).then(h=>{const f=h.flat();this.dispatch(cs(f))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:l.GET,url:"/assets/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Va(s))}}class xA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(hs(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:l.POST,url:"/asset-stage-completions/",payload:v(c),blockers:[e.asset,e.stage],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Na(o))}).catch(()=>{this.dispatch(fs(c.offline_id))}),[c,r]}delete(e){const{store:s}=this.client,n=Ka(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with id ${e} to exist`);this.dispatch(fs(e));const a=this.enqueueRequest({description:"Delete asset stage completion",method:l.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(hs(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.id,c=e.map(d=>F(d)),r=c.map(d=>({...d,created_by:a,submitted_at:n})),o=r.map(({offline_id:d})=>d);this.dispatch(ms(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:l.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:n,completions:c},blockers:[...e.map(d=>d.asset_procedure_instance),...e.map(d=>d.stage),...e.map(d=>d.asset)],blocks:o});return m.then(d=>{this.dispatch(Ha(d))}).catch(()=>{this.dispatch(ps(o))}),[r,m]}bulkDelete(e){const{store:s}=this.client,n=Ya(e)(s.getState());this.dispatch(ps(e));const a=this.enqueueRequest({description:"Deleting asset stage completions",method:l.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ms(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:l.GET,url:"/asset-stage-completions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(La(s))}}class ey extends R{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.id,c=e.map(m=>F(m)),r=c.map(m=>({...m,asset_procedure:s,created_by:a,submitted_at:n}));this.dispatch(Ss(r));const o=this.enqueueRequest({description:"Add asset stages",method:l.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({offline_id:m})=>m)});return o.then(m=>{this.dispatch(Qe(m))}).catch(()=>{this.dispatch(bs(r.map(({offline_id:m})=>m)))}),[r,o]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Ts(e.map(({offline_id:r})=>r))(a);return this.dispatch(Qe(e)),this.enqueueRequest({description:"Edit asset stages",method:l.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({offline_id:r})=>r)}).catch(r=>{throw this.dispatch(Qe(c)),r})}async bulkDelete(e){const{store:s}=this.client,n=Ts(e)(s.getState());this.dispatch(bs(e));const a=this.enqueueRequest({description:"Delete asset stages",method:l.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(Ss(n))}),a}update(e){const{store:s}=this.client,n=xa(e.offline_id)(s.getState());if(!n)throw new Error(`No asset stage with id ${e.offline_id} found in the store`);const a={...n,...e};this.dispatch(gs(a));const c=this.enqueueRequest({description:"Update asset stage",method:l.PATCH,url:`/asset-stages/${n.offline_id}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(gs(r))}).catch(()=>{this.dispatch(Qa(n))}),[a,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:l.GET,url:"/asset-stages/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Xa(s))}}class ty extends be{constructor(){super(...arguments);y(this,"name","Asset Type Attachment");y(this,"url","/asset-type-attachments");y(this,"addAttachments",Fs);y(this,"updateAttachments",nc);y(this,"removeAttachments",Is);y(this,"removeAttachment",ac);y(this,"setAttachment",ic);y(this,"selectAttachment",dc)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelId})}buildAttachmentPayload(s){return{...s,asset_type:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetTypeId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset type attachments",method:l.GET,url:`${this.url}/`,queryParams:{organization:s.toString()},blocks:[],blockers:[]});this.dispatch(sc(n))}}class sy extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(_)}this.dispatch(mc(c));const o=this.enqueueRequest({description:"Add asset type fields attachments",method:l.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(fc(d.attachments))}).catch(()=>{this.dispatch(pc(c.map(d=>d.offline_id)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:l.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(hc(s))}}class iy extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Tc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:l.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(_c(m))}).catch(m=>{throw this.dispatch(Fc(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:l.GET,url:"/asset-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(bc(s))}}class ny extends j{async bulkAdd(e,s){var d;const n=new Date().toISOString(),a=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=Ke(e,s??e.length),r=[],o=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:T,fieldIdentifier:_,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const M=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:T,submitted_at:n,field_identifier:_});r.push(M);const _t={offline_id:M.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:_,field_values:T};p.push(_t)}o.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(et(r));const m=o.map(h=>this.enqueueRequest({description:"Add asset type field values attachments",method:l.POST,url:"/asset-type-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(vc(f))}).catch(h=>{throw this.dispatch(tt(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Ec(e)(n);this.dispatch(tt(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:l.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(et(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:l.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Oc(s))}}class ay extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:l.POST,url:"/asset-type-field-values/",payload:v(a),blockers:[e.asset,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(Es(a)),c.then(o=>(this.dispatch(Ve(o)),o)).catch(()=>{this.dispatch(js(a.offline_id))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=qe(e.values),c=[],r=Ke(e.payloads,s??e.payloads.length),o=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:qe(p.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}o.push({submitted_at:n,values:a,field_values:f})}this.dispatch(Cc(c));const m=[];for(const h of o){const f=h.field_values.map(_=>_.asset),p=h.field_values.map(_=>_.fields_revision),A=h.field_values.map(_=>_.offline_id),T=this.enqueueRequest({description:"Bulk add asset type field values",method:l.POST,url:"/asset-type-field-values/bulk/",payload:h,blockers:[...f,...p],blocks:A});m.push(T)}return Promise.all(m).then(h=>{this.dispatch(Dc(h.flat()))}).catch(()=>{this.dispatch(zc(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Ms(e.offline_id)(n);if(!a)throw new Error(`Expected AssetTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Ve(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:l.PATCH,url:`/asset-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.asset],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Ve(o))}).catch(()=>{this.dispatch(Ve(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Ms(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=jc(e)(n);this.dispatch(js(e)),this.dispatch(tt(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset type field values",method:l.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Es(a)),this.dispatch(et(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:l.GET,url:"/asset-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(kc(s))}}class cy extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Cs(c));const r=this.enqueueRequest({description:"Create asset type",method:l.POST,url:"/asset-types/",payload:v(c),blockers:[],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Ue(o))}).catch(()=>{this.dispatch(Ds(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=Vs(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset type with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(Ue(a));const c=this.enqueueRequest({description:"Update asset type",method:l.PATCH,url:`/asset-types/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(Ue(r))}).catch(()=>{this.dispatch(Ue(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Vs(e)(n);if(!a)throw new Error(`Expected asset type with offline_id ${e} to exist`);const c=os(e)(n),r=oc(e)(n);return this.dispatch(Ds(e)),this.dispatch(Ua(c.map(o=>o.offline_id))),this.dispatch(Is(r.map(({offline_id:o})=>o))),this.enqueueRequest({description:"Delete asset type",method:l.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(o=>{throw this.dispatch(Cs(a)),this.dispatch(cs(c)),this.dispatch(Fs(r)),o})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:l.GET,url:"/asset-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Bc(s))}}class ry extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch($s(c));const r=this.enqueueRequest({description:"Create Category",method:l.POST,url:"/categories/",payload:v(c),blockers:[e.project.toString()],blocks:[c.offline_id]});return[c,r]}update(e){const s=this.client.store.getState(),n=Gs(e.offline_id)(s);if(!n)throw new Error(`Expected an existing category with offline_id ${e.offline_id}`);const a={...n,...e};this.dispatch(Yc(a));const c=this.enqueueRequest({description:"Edit Category",method:l.PATCH,url:`/categories/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return[a,c]}remove(e){const{store:s}=this.client,n=Gs(e)(s.getState());if(!n)throw new Error(`No category with id ${e} found in the store`);this.dispatch(Jc(e));const a=this.enqueueRequest({description:"Delete Category",method:l.DELETE,url:`/categories/${n.offline_id}/`,blockers:[n.offline_id],blocks:[]});return a.catch(()=>{this.dispatch($s(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:l.GET,url:"/categories/",queryParams:{project:e.toString()},blocks:[],blockers:[]});this.dispatch(Kc(s))}}class dy extends be{constructor(){super(...arguments);y(this,"name","Document Attachment");y(this,"url","/document-attachments");y(this,"addAttachments",xc);y(this,"updateAttachments",tr);y(this,"removeAttachments",ir);y(this,"removeAttachment",sr);y(this,"setAttachment",er);y(this,"selectAttachment",cr)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelId})}buildAttachmentPayload(s){return{...s,document:s.modelId}}async bulkAdd(s){var f;const{store:n}=this.client,a=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,c=new Date().toISOString(),r=[],o=[],m={},d={};for(const p of s){const{documentId:A,file:T}=p,_=await this.getFilePayload(T);_.sha1 in m||(m[_.sha1]=_,d[_.sha1]=[]);const b=this.buildOfflineAttachment({file:T,file_sha1:_.sha1,submitted_at:c,created_by:a,description:"",modelId:A});r.push(b),o.push({offline_id:b.offline_id,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:_.extension,description:b.description,document:A}),d[_.sha1].push(b.offline_id)}this.dispatch(this.addAttachments(r));const h=this.enqueueRequest({description:"Attach files to document",method:l.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:o,files:Object.values(m)},blocks:r.map(p=>p.offline_id),blockers:r.map(p=>p.file_sha1)});return h.then(({attachments:p,presigned_urls:A})=>{this.dispatch(this.updateAttachments(p));const T=this.processPresignedUrls(A);for(const[_,b]of Object.entries(T))b.then(()=>{const P=d[_];for(const M of P)this.makeReadable(M)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(p=>p.offline_id)))}),[r,h.then(({attachments:p})=>p)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:l.PATCH,url:`/document-attachments/${s}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",s],blocks:["index-document-attachment"]})}async refreshStore(s,n){const a=await this.enqueueRequest({description:"Get document attachments",method:l.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Zc(a));const c=await this.enqueueRequest({description:"Get document attachments",method:l.GET,url:`/organizations/${n}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class oy extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(lr([c]));const r=this.enqueueRequest({description:"Create Document",method:l.POST,url:"/documents/",payload:v(c),queryParams:{parent_document:c.parent_document??void 0},blockers:c.parent_document?[c.parent_document]:[],blocks:[c.offline_id]});return r.catch(()=>{this.dispatch(Hs([c.offline_id]))}),[c,r]}update(e){const{store:s}=this.client,n=s.getState().documentsReducer.documents[e.offline_id];if(!n)throw new Error(`attempting to update a document with offline_id ${e.offline_id} that does not exist in store.documents`);const a={...n,...e};this.dispatch(me([a]));const c=this.enqueueRequest({description:"Update Document",method:l.PATCH,url:`/documents/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{me([n])}),[a,c]}move(e,s,n){const{store:a}=this.client,c=Re(a.getState()),r=[],o=c[e];if(!o)throw new Error(`attempting to move a document with offline_id ${e} that does not exist in store.documents`);if(r.push(o),o.parent_document&&r.push(c[o.parent_document]),s){const d=c[s];if(!d)throw new Error(`attempting to move a document to target with offline_id ${s} that does not exist in store.documents`);r.push(d),d.parent_document&&r.push(c[d.parent_document])}this.dispatch(ur({documentId:e,targetDocumentId:s,position:n}));const m=this.enqueueRequest({description:"Move Document",method:l.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:n},blockers:[e],blocks:[]});return m.then(d=>{this.dispatch(me(d))}).catch(()=>{this.dispatch(me(r))}),m}delete(e){const{store:s}=this.client,n=Re(s.getState()),a=mr(e)(s.getState());if(!a)throw new Error(`attempting to delete a document with offline_id ${e} that does not exist in store.documents`);const c=a.parent_document?n[a.parent_document]:void 0;this.dispatch(Hs([e]));const r=this.enqueueRequest({description:"Delete Document",method:l.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(o=>{this.dispatch(me(o))}).catch(()=>{this.dispatch(me([a])),c&&this.dispatch(me([c]))}),r}async refreshStore(e,s){const n=this.enqueueRequest({description:"Get project documents",method:l.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),a=this.enqueueRequest({description:"Get organization documents",method:l.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(or([...await n,...await a]))}}class ly extends R{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:l.POST,url:`/organizations/${e}/email-domains/`,payload:{email:s},blockers:[e.toString(),"create-org"],blocks:[]})}async remove(e){return this.dispatch(yr(e.offline_id)),this.enqueueRequest({description:"Remove email domain from organization",method:l.DELETE,url:`/organizations/${e.organization}/email-domains/${e.offline_id}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(Ar(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:l.GET,url:`/organizations/${e}/email-domains/`,blockers:[e.toString()],blocks:[]});this.dispatch(pr(s))}}class uy extends R{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:l.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:l.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const bt={},Sn=new Set;let Tt=0,gn=0,bn=0;const hy=20;class my extends R{constructor(){super(...arguments);y(this,"host");y(this,"_dbPromise",$u.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const n=await this.fetchCache(s);if(!n)throw new Error(`File with sha1 ${s} not found in cache`);const a=await Et(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:l.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await Ie(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(Fr({sha1:s,...c})),c}async addCache(s,n){if(Sn.has(n))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 a=await this._dbPromise;!!await a.get("files",n)?(console.error("File already cached (this is unexpected at this point):",s.name,n),Tt++):(await a.put("files",s,n),gn++),Sn.add(n),bn++,bn%hy===0&&console.debug(`File cache summary: ${Tt} hits and ${gn} misses, ${Tt/(Tt+gn)*100}% hit rate over ${bn} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),Sn.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return Ir(s)(n)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const n=await this.fetchCache(s);if(!n)throw new Error(`File with sha1 ${s} not found in cache`);const a=await Et(n,s),c={file_name:n.name,file_sha1:s,file:a},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[c,Promise.resolve(void 0).then()];throw new Error(r.warning)}const o=r.url,m=this.enqueueRequest({url:o,description:"Upload file",method:l.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${a}`],blocks:[s],s3url:r});return[c,m]}async fetchFileFromUrl(s,n,a){const c=s.split("?")[0]??s,r=await this.fetchCache(n);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const h=await qn(s),f=new File([h],a??n,{type:h.type});return await this.addCache(f,n),f}let o=bt[c],m=!0;o?m=!1:(o=new Promise(h=>{this.enqueueRequest({description:"Download file",method:l.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[n],blocks:[n]}).then(f=>{const p=new File([f],a??n,{type:f.type});h(p)})}),bt[c]=o);let d;try{d=await o}catch(h){throw m&&h instanceof q&&delete bt[c],h}if(m){const h=await Ie(d);if(h!==n){const A=`The hash of the file returned from the server (${h}) does not match the
10
10
  expected hash (${n}). This can happen if you're using a local development server and the
11
11
  isExternalUrl flag in the request details is set to true, because instead of requesting the local
12
12
  REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
13
13
  (with an offline_id attached) being returned. Alternatively, you may be running with
14
14
  import.meta.env.PROD, which will result in some file requests being treated as
15
- external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(A)}const f=o.type.split("/")[1];if(!f)throw new Error("File has no extension");const p=a??h+"."+f;if(o=En(o,p),!o.name)throw new Error("Failed to set file's name");await this.addCache(o,h),At[c]=new Promise(A=>{A(o)})}return o}}class CA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{revisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,form_revision:h};r.push(T)}this.dispatch(Tr(c));const d=this.enqueueRequest({description:"Attach files to form revision",method:u.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.form_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Fr(o.attachments))}).catch(()=>{this.dispatch(Ir(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:u.GET,url:"/form-revision-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(_r(s))}}class UA extends E{add(e){var d;const{store:s}=this.client,a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=F({...e,created_by:a,revision:"Pending",submitted_at:new Date().toISOString()});this.dispatch(Xs(c));const r=this.enqueueRequest({description:"Create form revision",method:u.POST,url:"/form-revisions/",payload:c,blockers:[e.form],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(vr(m))}).catch(()=>{this.dispatch(Zs(c.offline_id))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:u.GET,url:"/form-revisions/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(wr(s))}}const $A=async t=>{const e={},s=[];for(const n of t){if(n.type!=="section")throw new Error(`Expected ISerializedField type to be a section. Got ${n.type} instead.`);const{fields:a}=n,c=[];for(const r of a){if(r.image){if(r.image instanceof Promise)try{e[r.identifier]=await r.image}catch(d){console.error("Failed to get image from promise",d)}else e[r.identifier]=r.image;delete r.image}c.push(r)}s.push({...n,fields:c})}return{fields:s,images:e}};class BA extends E{add(e,s){var o;const{store:n}=this.client,a=new Date().toISOString(),c=(o=n.getState().userReducer.currentUser)==null?void 0:o.id,r=F({...e,submitted_at:a,created_by:c}),d=F({...s,form:r.offline_id,revision:"Pending",submitted_at:a,created_by:c});this.dispatch(xs(r)),this.dispatch(Xs(d));const m=this.enqueueRequest({description:"Create form",method:u.POST,url:"/forms/",payload:{...r,initial_revision:{offline_id:d.offline_id,submitted_at:d.submitted_at,title:d.title,description:d.description,fields:d.fields}},blockers:[],blocks:[r.offline_id,d.offline_id]});return m.catch(h=>{throw this.dispatch(ei(r.offline_id)),this.dispatch(Zs(d.offline_id)),h}),[r,d,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=$r(e)(n);if(!a)throw new Error("Expected form to exist");const c=Xr(e)(n);c.length>0&&this.dispatch(ct(c.map(({offline_id:d})=>d)));const r=kr(e)(n);r.length>0&&this.dispatch(jr(r.map(({offline_id:d})=>d))),this.dispatch(ei(e));try{return await this.enqueueRequest({description:"Delete form",method:u.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(d){throw this.dispatch(xs(a)),r.length>0&&this.dispatch(Er(r)),c.length>0&&this.dispatch(at(c)),d}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:u.GET,url:"/forms/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Vr(s))}}class GA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{submissionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_submission:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,form_submission:h};r.push(T)}this.dispatch(st(c));const d=this.enqueueRequest({description:"Attach files to form submission",method:u.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.form_submission),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Lr(o.attachments))}).catch(o=>{throw this.dispatch(it(c.map(h=>h.offline_id))),o}),[c,d.then(({attachments:o})=>o)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Nr(e)(n);this.dispatch(it(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:u.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(st(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:u.GET,url:"/form-submission-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Gr(s))}}class LA extends E{async add(e){var f;const{store:s}=this.client,{file:n,...a}=e,c=new Date().toISOString(),r=(f=s.getState().userReducer.currentUser)==null?void 0:f.id,d=a.project,m=await this.getFilePayload(n),o=F({...a,file_name:n.name,file_sha1:m.sha1,file:URL.createObjectURL(n),submitted_at:c,created_by:r});this.dispatch(io(o));const h=this.enqueueRequest({description:"Add geo image",method:u.POST,url:"/geo-images/",payload:{offline_id:o.offline_id,submitted_at:c,title:o.title,description:o.description,geo_marker:o.geo_marker,canvas_marker:o.canvas_marker,sha1:o.file_sha1,project:o.project,file_name:o.file_name,direction:o.direction,original_date:o.original_date,file:m},blocks:[d.toString()],blockers:[d.toString()]});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(Ve(p.geo_image))}).catch(()=>{this.dispatch(li(o.offline_id))}),[o,h.then(p=>p.geo_image)]}async bulkAdd(e,s){var f;const{store:n}=this.client,a=new Date().toISOString(),c=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,r=[],d=[],m=[],o={};for(const p of e){const{file:A,..._}=p,T=await this.getFilePayload(A);T.sha1 in o||(o[T.sha1]=T);const b=F({..._,file_name:A.name,file_sha1:T.sha1,file:URL.createObjectURL(A),submitted_at:a,created_by:c,project:s});r.push(b),d.push(b.offline_id),m.push({offline_id:b.offline_id,sha1:b.file_sha1,file_name:b.file_name,title:b.title,description:b.description,geo_marker:b.geo_marker,canvas_marker:b.canvas_marker,direction:b.direction,original_date:b.original_date})}this.dispatch(no(r));const h=this.enqueueRequest({description:"Bulk add geo images",method:u.POST,url:"/geo-images/bulk/",payload:{submitted_at:a,project:s,geo_images:m,files:Object.values(o)},blocks:[s.toString()],blockers:d});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(so(p.geo_images))}).catch(()=>{this.dispatch(co(d))}),[r,h.then(p=>p.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=ui(e.offline_id)(n);if(!a)throw new Error(`Map image with offline_id ${e.offline_id} does not exist in the store`);const c={...a,...e};this.dispatch(ao(c));const r=this.enqueueRequest({description:"Update geo image",method:u.PATCH,url:`/geo-images/${e.offline_id}/`,payload:e,blocks:[e.offline_id],blockers:[e.offline_id]});return r.then(d=>{this.dispatch(Ve(d))}).catch(()=>{this.dispatch(Ve(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ui(e)(n);if(!a)throw new Error(`Map image with offline_id ${e} does not exist in the store`);this.dispatch(li(e));const c=this.enqueueRequest({description:"Delete geo image",method:u.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(Ve(a))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:u.GET,url:`/projects/${e}/geo-images/`,blocks:[e.toString()],blockers:[]});this.dispatch(to(s))}}class NA extends R{add(e){var d;const{store:s}=this.client,n=new Date().toISOString(),a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=F({...e,submitted_at:n,created_by:a});this.dispatch(mi(c));const r=this.enqueueRequest({description:"Add issue association",method:u.POST,url:"/issue-associations/",payload:{offline_id:c.offline_id,submitted_at:n,...e},blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(mo(m))}).catch(()=>{this.dispatch(pi(c.offline_id))}),[c,r]}async delete(e){const{store:s}=this.client,n=fo(e)(s.getState());if(!n)throw new Error(`Issue association with id ${e} not found in store.`);this.dispatch(pi(e));const a=this.enqueueRequest({description:"Delete issue association",method:u.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(mi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:u.GET,url:"/issue-associations/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ho(s))}}class HA extends Le{constructor(){super(...arguments);g(this,"name","Issue Attachment");g(this,"url","/issue-attachments");g(this,"addAttachments",Si);g(this,"updateAttachments",To);g(this,"removeAttachments",gi);g(this,"removeAttachment",Fo);g(this,"setAttachment",_o);g(this,"selectAttachment",Po)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue:s.modelId})}buildAttachmentPayload(s){return{...s,issue:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(bo(n))}}class WA extends R{add(e){var c;const{store:s}=this.client,n=F({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Fi(n));const a=this.enqueueRequest({description:"Add issue comment",method:u.POST,url:"/issue-comments/",payload:n,blockers:[e.issue],blocks:[n.offline_id]});return a.catch(()=>{this.dispatch(Ii(n.offline_id))}),[n,a]}update(e){const{store:s}=this.client,n=jo(e.offline_id)(s.getState());if(!n)throw new Error(`Comment with offline_id ${e.offline_id} not found in store`);const a={...n,...e};this.dispatch(Ti(a));const c=this.enqueueRequest({description:"Edit issue comment",method:u.PATCH,url:`/issue-comments/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{this.dispatch(Ti(n))}),[a,c]}remove(e){const s=this.client.store.getState().issueCommentReducer.instances[e];if(!s)throw new Error(`Comment with offline_id ${e} not found in store`);this.dispatch(Ii(e));const n=this.enqueueRequest({description:"Delete comment",method:u.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Fi(s))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:u.GET,url:"/issue-comments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(wo(s))}}class KA extends R{add(e){var m;const{store:s}=this.client,n=s.getState(),a=new Date().toISOString(),c=(m=n.userReducer.currentUser)==null?void 0:m.id,r=F({...e,submitted_at:a,created_by:c});this.dispatch(Pi(r));const d=this.enqueueRequest({description:"Create issue",method:u.POST,url:"/issues/",payload:r,blockers:["add-issue",r.project.toString()],blocks:[r.offline_id]});return d.then(o=>{this.dispatch(rt(o))}).catch(o=>{throw this.dispatch(Oi(r.offline_id)),o}),[r,d]}update(e){var m;const s=this.client.store.getState(),n=vi(e.offline_id)(s);if(!n)throw new Error(`Attempting to update an issue with offline_id ${e.offline_id} that doesn't exist in the store`);const a={...n,...e};this.dispatch(rt(a));const c={};for(const o of[v.TITLE,v.DESCRIPTION,v.STATUS,v.CATEGORY,v.PRIORITY,v.ASSIGNED_TO,v.DUE_DATE])if(o in e&&e[o]!==n[o])switch(o){case v.PRIORITY:case v.STATUS:{const h=e[o];c[o]=h!==void 0?Number(h):null;break}case v.DUE_DATE:case v.DESCRIPTION:case v.TITLE:c[o]=e[o]??null;break;case v.CATEGORY:{let h=null;const f=e[o];if(f&&(h=s.categoryReducer.instances[f]??null,!h))throw new Error(`Trying to update issue category to ${f} which does not exist in store`);c[o]=h?{name:h.name,color:h.color,offline_id:h.offline_id}:null;break}case v.ASSIGNED_TO:{let h=null;const f=e[o];if(f&&(h=s.userReducer.users[f]??null,!h))throw new Error(`Trying to update issue assigned_to to ${f} which does not exist in store`);c[o]=h?{full_name:h.username,id:h.id}:null;break}}const r=F({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:n.offline_id,changes:c});this.dispatch(bd(r));const d=this.enqueueRequest({description:"Edit issue",method:u.PATCH,url:`/issues/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return d.catch(()=>{this.dispatch(rt(n)),this.dispatch(Td(r.offline_id))}),[a,d]}async remove(e){const{store:s}=this.client,n=s.getState(),a=vi(e)(n);if(!a)throw new Error(`No issue with id ${e} found in the store`);const c=Ro(e)(n),r=Rd(e)(n),d=Zr(e)(n),m={};for(const h of po(e)(n))m[h.offline_id]=h;for(const h of Ao(e)(n))m[h.offline_id]=h;const o=Object.values(m);this.dispatch(Oi(e)),c.length>0&&this.dispatch(gi(c.map(({offline_id:h})=>h))),r.length>0&&this.dispatch(Fd(r.map(({offline_id:h})=>h))),d.length>0&&this.dispatch(ct(d.map(({offline_id:h})=>h))),o.length>0&&this.dispatch(Ai(o.map(({offline_id:h})=>h)));try{return await this.enqueueRequest({description:"Delete issue",method:u.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(h){throw this.dispatch(Pi(a)),this.dispatch(Si(c)),this.dispatch(_d(r)),this.dispatch(at(d)),this.dispatch(fi(o)),h}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:u.GET,url:"/issues/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ko(s))}}class YA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_extension:A.extension,field_identifier:f,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(Bo(c));const d=this.enqueueRequest({description:"Add issue type fields attachments",method:u.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Go(o.attachments))}).catch(()=>{this.dispatch(Lo(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:u.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch($o(s))}}class JA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(xo(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:u.POST,url:"/issue-type-fields/",payload:c,blockers:[c.issue_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(ed(m))}).catch(m=>{throw this.dispatch(td(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:u.GET,url:"/issue-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Qo(s))}}class XA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldValuesId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,field_values:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,field_values:h};r.push(T)}this.dispatch(dt(c));const d=this.enqueueRequest({description:"Add issue type field values attachments",method:u.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.field_values),blocks:c.map(o=>o.offline_id)});return d.then(({presigned_urls:o,attachments:h})=>{this.processPresignedUrls(o),this.dispatch(cd(h))}).catch(o=>{throw this.dispatch(lt(c.map(h=>h.offline_id))),o}),[c,d.then(({attachments:o})=>o)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=od(e)(n);this.dispatch(lt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:u.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(dt(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values attachments",method:u.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ad(s))}}class ZA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:u.POST,url:"/issue-type-field-values/",payload:a,blockers:[e.issue,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(ji(a)),c.then(d=>(this.dispatch(Ue(d)),d)).catch(()=>{this.dispatch(qi(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=ki(e.offline_id)(n);if(!a)throw new Error(`Expected IssueTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Ue(c));const r=this.enqueueRequest({description:"Update issue type field values",method:u.PATCH,url:`/issue-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.issue],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(Ue(d))}).catch(()=>{this.dispatch(Ue(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ki(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=dd(e)(n);this.dispatch(qi(e)),this.dispatch(lt(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete issue type field values",method:u.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ji(a)),this.dispatch(dt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:u.GET,url:"/issue-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Yo(s))}}class QA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,submitted_at:new Date().toISOString(),created_by:(r=n.userReducer.currentUser)==null?void 0:r.id});this.dispatch(md(a));const c=this.enqueueRequest({method:u.POST,url:"/issue-types/",payload:a,blockers:[],blocks:[a.offline_id]});return c.then(d=>{this.dispatch($e(d))}).catch(()=>{this.dispatch(Ui(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=$i(e.offline_id)(n);if(!a)throw new Error(`IssueType with offline_id ${e.offline_id} does not exist in the store.`);const c={...a,...e};this.dispatch(fd(c));const r=this.enqueueRequest({method:u.PATCH,url:`/issue-types/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return r.then(d=>{this.dispatch($e(d))}).catch(()=>{this.dispatch($e(a))}),[c,r]}delete(e){const{store:s}=this.client,n=s.getState(),a=$i(e)(n);if(!a)throw new Error(`IssueType with offline_id ${e} does not exist in the store.`);const c=Bi(e)(n);this.dispatch(Ui(e)),this.dispatch(zo(c.map(d=>d.offline_id)));const r=this.enqueueRequest({method:u.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch($e(a)),this.dispatch(Do(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:u.GET,url:"/issue-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(hd(s))}}class xA extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:u.GET,url:"/issue-updates/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(gd(s))}}class ey extends Kl{constructor(e){super(e)}}const ty=1800;function sy(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 iy extends ey{constructor(){super(...arguments);g(this,"_getRenewedTokens",async s=>{const n=this.enqueueRequest({description:"Get renewed tokens",method:u.POST,url:this.refreshTokensUrl,payload:{refresh:s},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let a;try{a=await n}catch(c){console.error("Could not renew tokens; clearing auth",c),this.clearAuth();return}if(!a.access)throw new Error("Missing access token");return{accessToken:a.access,refreshToken:a.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch($c(!1)),this.clearTokens(),this.dispatch({type:pu.RESET_STATE}),this.dispatch({type:tu})}async renewTokens(){const s=this.getRefreshToken();if(!s)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const n=await this._getRenewedTokens(s);if(!n)return;console.log("Got renewed tokens"),this.setTokens(n)}catch(n){throw console.error("Could not renew tokens; clearing auth",n),this.clearAuth(),n}}tokenIsExpiringSoon(){const s=this.getAccessToken();if(!s)return!1;const n=Date.now()/1e3;let a;try{a=Au(s).exp??n}catch{a=n}return a-n<ty}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 j&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??Pe).toString()))}}}async handleUnauthorized(s,n){const a=this.client.store.getState();if(s.url.endsWith("/token/refresh/"))throw a.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new j({message:"You have been signed out due to inactivity.",response:n,discard:!0});if(a.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new j({message:"Incorrect username or password.",response:n,discard:!0})}async initAuth(s){const n=O.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:n,description:"Get token pair",method:u.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(a=>{this.setTokens(sy(a))})}}class ny extends R{async getLicense(e){const s=await this.enqueueRequest({description:"Get license",method:u.GET,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:u.DELETE,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:u.PATCH,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:u.DELETE,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async attachLicenseToProject(e,s){const n=await this.enqueueRequest({description:"Attach license",method:u.PATCH,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,payload:{project:s.id},blockers:[e.organization_owner?e.organization_owner.toString():"",s.id?s.id.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(oe(n)),n}async detachLicenseFromProject(e){const s=await this.enqueueRequest({description:"Detach license",method:u.DELETE,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(oe(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:u.GET,url:`/billing/${e.offline_id}/transaction/`,isAuthNeeded:!0,blockers:[e.offline_id],blocks:[e.offline_id]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get licenses",method:u.GET,url:`/organizations/${s}/licenses/`,isAuthNeeded:!0,blockers:[s.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of a)n[r.offline_id]=r;const c=await this.enqueueRequest({description:"Get licenses",method:u.GET,url:`/projects/${e}/licenses/`,isAuthNeeded:!0,blockers:[e.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of c)n[r.offline_id]=r;this.dispatch(vd(Object.values(n)))}}class ay extends R{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:u.PATCH,url:`/organizations/${e.organization}/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return s.then(()=>{this.dispatch(Vd(e))}),s}async remove(e){return this.dispatch(Cd(e.offline_id)),this.dispatch(Md(e.user)),this.enqueueRequest({description:"Remove organization access",method:u.DELETE,url:`/organizations/${e.organization}/access/${e.offline_id}/`,blockers:[e.offline_id],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:u.GET,url:`/organizations/${e}/access/`,blockers:[],blocks:[]});this.dispatch(zd(s))}}class cy extends R{create(e){return this.enqueueRequest({description:"Create organization",method:u.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:u.PATCH,url:`/organizations/${e.id}/`,payload:e,blockers:[`add-org-${e.name}`,e.id.toString()],blocks:[e.id.toString()]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:u.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get organizations",method:u.GET,url:`/projects/${e}/organizations/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Get organization",method:u.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.id]=c,this.dispatch(il(Object.values(n)))}}class ry extends R{async update(e){return this.dispatch(Gd(e)),this.enqueueRequest({description:"Edit project access",method:u.PATCH,url:`/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id,"change-access-level"],blocks:[e.offline_id]})}async remove(e){return this.dispatch(Ld(e)),this.enqueueRequest({description:"Delete project access",method:u.DELETE,url:`/access/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:u.GET,url:`/projects/${e}/access/`,blockers:[],blocks:[]});this.dispatch(Yi(s))}}class oy extends Le{constructor(){super(...arguments);g(this,"name","Project Attachment");g(this,"url","/project-attachments");g(this,"addAttachments",yl);g(this,"updateAttachments",bl);g(this,"removeAttachments",tn);g(this,"removeAttachment",_l);g(this,"setAttachment",Sl);g(this,"selectAttachment",Fl)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,project:s.modelId})}buildAttachmentPayload(s){return{...s,project:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.projectId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get project attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blockers:[],blocks:[]});this.dispatch(Al(n))}}class dy extends R{async saveExisting(e){if(!e.offline_id)throw new Error("You can only use this method to save existing project files. The one provided has no offline_id.");const s={...e};delete s.file;const n=this.enqueueRequest({method:u.PATCH,url:`/projects/files/${e.offline_id}/`,payload:s,blockers:[e.offline_id],blocks:[e.offline_id]});return n.then(a=>{this.dispatch(an(a))}),n}saveActive(){const{store:e}=this.client,s=e.getState(),n=s.projectFileReducer.activeProjectFileId;if(!n)throw new Error("No active project file");const a=s.projectFileReducer.instances[n];if(!a)throw new Error("No active project file");if(!a.bounds&&!a.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let c;if(typeof a.file=="string"&&!a.file.startsWith("blob:")){const m={...a};delete m.file,c={method:u.PATCH,url:`/projects/files/${n}/`,payload:m,blockers:[n],blocks:[n]}}else c=new Promise((m,o)=>{this.client.files.uploadFileToS3(a.file_sha1).then(([h])=>{m({method:u.POST,url:`/projects/${a.project}/files/`,payload:{...a,...h},blockers:[n],blocks:[n]})}).catch(o)});const d=Promise.resolve(c).then(m=>this.enqueueRequest(m));return d.then(m=>{this.dispatch(an(m))}),this.dispatch(Ml),this.dispatch(ql(null)),this.dispatch(jl(!1)),[a,d]}delete(e){return this.dispatch(wl(e)),this.enqueueRequest({method:u.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:u.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(Ol(s))}}class ly 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:u.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(Xd(e)),await this.enqueueRequest({description:"Update project",method:u.PATCH,url:`/projects/${e.id}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.id.toString()],blocks:[e.id.toString()]})}async delete(e){const{store:s}=this.client,n=s.getState(),a=Zi(n),c=a[e];if(!c)throw new Error("Expected project to exist");const r=Dl(n).filter(h=>h.project===e);this.dispatch(El(r.map(({offline_id:h})=>h)));const d=Il(c.id)(n);this.dispatch(tn(d.map(({offline_id:h})=>h)));const m=Hd(n);this.dispatch(Nd(m.map(({offline_id:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(Zd(c));const o=wd(c.id)(n);o&&this.dispatch(oe({...o,project:null}));try{await this.enqueueRequest({description:"Delete project",method:u.DELETE,url:`/projects/${e}/`,blockers:[e.toString()],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(h){throw this.dispatch(Jd(Object.values(a))),this.dispatch(Yi(Object.values(m))),this.dispatch(vl(r)),this.dispatch(gl(d)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),o&&this.dispatch(oe({...o,project:c.id})),h}}invite(e,s){const n=O.v4();return this.enqueueRequest({description:"Invite user to project",method:u.POST,url:`/projects/${e}/invite/${s}/`,payload:{offline_id:n},blockers:[],blocks:[n]})}joinProject(e,s,n){return this.enqueueRequest({description:"Join project",method:u.GET,url:`/projects/${e}/join-project/${s}/${n}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:u.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e.toString()],blocks:[e.toString()]}).then(()=>{this.dispatch(Qd(e))})}}class uy extends R{add(e){const s=F({...e,submitted_at:new Date().toISOString()});this.dispatch($l(s));const n=this.enqueueRequest({description:"Create team",method:u.POST,url:`/organizations/${e.organization}/teams/`,payload:s,blockers:[],blocks:[s.offline_id]});return n.then(a=>{this.dispatch(Ie(a))}).catch(()=>{this.dispatch(dn(s.offline_id))}),[s,n]}update(e){const{store:s}=this.client,n=Re(e.offline_id)(s.getState());if(!n)throw new Error(`Expected team with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(on(a));const c=this.enqueueRequest({description:"Update team",method:u.PATCH,url:`/organizations/teams/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(Ie(r))}).catch(()=>{this.dispatch(Ie(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Re(e)(n);if(!a)throw new Error(`Expected team with id ${e} to exist`);this.dispatch(dn(e));try{return await this.enqueueRequest({description:"Delete team",method:u.DELETE,url:`/organizations/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(Ie(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);if(s.length!==new Set(s).size)throw new Error("Duplicate members found in the list");this.dispatch(on({...a,members:s}));const c=this.enqueueRequest({description:"Set team members",method:u.PUT,url:`/organizations/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(Ie(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=[...a.members,...s];return this.setMembers(e,c)}async removeMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=a.members.filter(r=>!s.includes(r));return this.setMembers(e,c)}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:u.GET,url:`/organizations/${e}/teams/`,blockers:[],blocks:[]});this.dispatch(Ul(s))}}class hy extends R{async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Fetch organization users",method:u.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:u.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)n[r.id]=r;this.dispatch(qd(Object.values(n)))}}var ru=(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))(ru||{});i.APIError=j,i.AgentService=hA,i.AssetAttachmentService=mA,i.AssetProcedureFieldValuesAttachmentService=AA,i.AssetProcedureFieldValuesService=gA,i.AssetProcedureFieldsAttachmentService=fA,i.AssetProcedureFieldsService=pA,i.AssetProcedureInstanceService=bA,i.AssetProcedureService=_A,i.AssetService=TA,i.AssetStageCompletionService=FA,i.AssetStageService=IA,i.AssetTypeAttachmentService=RA,i.AssetTypeFieldValuesAttachmentService=vA,i.AssetTypeFieldValuesService=wA,i.AssetTypeFieldsAttachmentService=PA,i.AssetTypeFieldsService=OA,i.AssetTypeService=EA,i.AttachmentModel=Tn,i.BaseApiService=R,i.BaseSDK=lA,i.CategoryService=jA,i.DEFAULT_ISSUE_PRIORITY=Su,i.DEFAULT_ISSUE_STATUS=yu,i.DeferredPromise=On,i.DocumentAttachmentService=qA,i.DocumentService=MA,i.EMPTY_ARRAY=bn,i.EMPTY_OBJECT=_n,i.EmailDomainsService=kA,i.EmailVerificationService=DA,i.FileService=VA,i.FormRevisionAttachmentService=CA,i.FormRevisionService=UA,i.FormService=BA,i.FormSubmissionAttachmentService=GA,i.FormSubmissionService=SA,i.GeoImageService=LA,i.HttpMethod=u,i.IssueAssociationService=NA,i.IssueAttachmentService=HA,i.IssueCommentService=WA,i.IssuePriority=_t,i.IssueService=KA,i.IssueStatus=Tt,i.IssueTypeFieldValuesAttachmentService=XA,i.IssueTypeFieldValuesService=ZA,i.IssueTypeFieldsAttachmentService=YA,i.IssueTypeFieldsService=JA,i.IssueTypeService=QA,i.IssueUpdateChange=v,i.IssueUpdateService=xA,i.JWTService=iy,i.LicenseLevel=In,i.LicenseService=ny,i.LicenseStatus=Rn,i.OUTBOX_RETRY_DELAY=Pn,i.OrganizationAccessLevel=bt,i.OrganizationAccessService=ay,i.OrganizationService=cy,i.OutboxCoordinator=Oe,i.PaddleCheckoutEvent=Fn,i.ProjectAccessLevel=gt,i.ProjectAccessService=ry,i.ProjectAttachmentService=oy,i.ProjectFileService=dy,i.ProjectService=ly,i.TeamService=uy,i.UNKNOWN_ERROR_MESSAGE=Pe,i.UserService=hy,i.VERSION_REDUCER_KEY=hn,i.VerificationCodeType=ru,i._selectLatestFormRevision=Mr,i._setLatestRetryTime=ml,i.acceptProjectInvite=Qd,i.addAsset=ss,i.addAssetAttachment=Gu,i.addAssetAttachments=jt,i.addAssetProcedure=Zt,i.addAssetProcedureFieldValues=$t,i.addAssetProcedureFieldValuesAttachment=rh,i.addAssetProcedureFieldValuesAttachments=We,i.addAssetProcedureFieldValuesMany=ga,i.addAssetProcedureFields=aa,i.addAssetProcedureFieldsAttachment=Wu,i.addAssetProcedureFieldsAttachments=Zn,i.addAssetProcedureFieldsMany=xu,i.addAssetProcedureInstance=Ht,i.addAssetProcedureInstances=Pa,i.addAssetProcedures=Th,i.addAssetStage=zh,i.addAssetStageCompletion=ds,i.addAssetStageCompletions=ls,i.addAssetStages=ps,i.addAssetType=Ms,i.addAssetTypeAttachment=$h,i.addAssetTypeAttachments=bs,i.addAssetTypeFieldValues=vs,i.addAssetTypeFieldValuesAttachment=am,i.addAssetTypeFieldValuesAttachments=Ze,i.addAssetTypeFieldValuesMany=jc,i.addAssetTypeFields=yc,i.addAssetTypeFieldsAttachment=Nh,i.addAssetTypeFieldsAttachments=dc,i.addAssetTypeFieldsMany=Zh,i.addAssetTypes=ym,i.addAssets=is,i.addCategory=Cs,i.addConversation=Vn,i.addDocumentAttachment=wm,i.addDocumentAttachments=Jc,i.addDocuments=Ns,i.addEmailDomain=lr,i.addForm=xs,i.addFormRevision=Xs,i.addFormRevisionAttachment=$m,i.addFormRevisionAttachments=Tr,i.addFormRevisions=Er,i.addFormSubmission=ni,i.addFormSubmissionAttachment=ef,i.addFormSubmissionAttachments=st,i.addFormSubmissions=at,i.addForms=Xm,i.addGeoImage=io,i.addGeoImages=no,i.addIssue=Pi,i.addIssueAssociation=mi,i.addIssueAssociations=fi,i.addIssueAttachment=ff,i.addIssueAttachments=Si,i.addIssueComment=Fi,i.addIssueComments=Sf,i.addIssueType=md,i.addIssueTypeFieldValues=ji,i.addIssueTypeFieldValuesAttachment=Nf,i.addIssueTypeFieldValuesAttachments=dt,i.addIssueTypeFieldValuesMany=wf,i.addIssueTypeFields=xo,i.addIssueTypeFieldsAttachment=Tf,i.addIssueTypeFieldsAttachments=Bo,i.addIssueTypeFieldsMany=Df,i.addIssueUpdate=bd,i.addIssueUpdates=_d,i.addIssues=Do,i.addLicenses=ep,i.addProjectAttachment=Ip,i.addProjectAttachments=yl,i.addProjectFile=wp,i.addProjectFiles=vl,i.addTeam=$l,i.addUsers=cp,i.agentsReducer=$n,i.agentsSlice=Ot,i.areArraysEqual=Tu,i.assetAttachmentReducer=Yn,i.assetAttachmentSlice=wt,i.assetProcedureFieldValuesAttachmentReducer=Aa,i.assetProcedureFieldValuesAttachmentSlice=Vt,i.assetProcedureFieldValuesReducer=Fa,i.assetProcedureFieldValuesSlice=Ut,i.assetProcedureFieldsAttachmentReducer=sa,i.assetProcedureFieldsAttachmentSlice=kt,i.assetProcedureFieldsReducer=da,i.assetProcedureFieldsSlice=Dt,i.assetProcedureInstanceReducer=wa,i.assetProcedureInstanceSlice=Nt,i.assetProcedureReducer=Ma,i.assetProcedureSlice=Xt,i.assetReducer=Ca,i.assetSlice=ts,i.assetStageCompletionReducer=La,i.assetStageCompletionSlice=os,i.assetStageReducer=Ja,i.assetStageSlice=fs,i.assetTypeAttachmentReducer=cc,i.assetTypeAttachmentSlice=gs,i.assetTypeFieldValuesAttachmentReducer=vc,i.assetTypeFieldValuesAttachmentSlice=Rs,i.assetTypeFieldValuesReducer=Dc,i.assetTypeFieldValuesSlice=Os,i.assetTypeFieldsAttachmentReducer=fc,i.assetTypeFieldsAttachmentSlice=Fs,i.assetTypeFieldsReducer=_c,i.assetTypeFieldsSlice=Is,i.assetTypeReducer=Cc,i.assetTypeSlice=qs,i.authReducer=Bc,i.authSlice=xe,i.blobToBase64=ju,i.categoryReducer=Wc,i.categorySlice=Vs,i.clearTokens=Fm,i.constructUploadedFilePayloads=Eu,i.coordinatesAreEqual=_u,i.createModelAdapter=I,i.createMultiPointGeometry=bu,i.createOfflineAction=dl,i.createPointGeometry=gu,i.deleteAsset=ns,i.deleteAssetAttachment=Nn,i.deleteAssetAttachments=qt,i.deleteAssetProcedure=Qt,i.deleteAssetProcedureFieldValues=Bt,i.deleteAssetProcedureFieldValuesAttachment=uh,i.deleteAssetProcedureFieldValuesAttachments=Ke,i.deleteAssetProcedureFieldValuesMany=_a,i.deleteAssetProcedureFields=ra,i.deleteAssetProcedureFieldsAttachment=Xu,i.deleteAssetProcedureFieldsAttachments=xn,i.deleteAssetProcedureFieldsMany=ih,i.deleteAssetProcedureInstance=Wt,i.deleteAssetProcedureInstances=Oa,i.deleteAssetProcedures=Ih,i.deleteAssetStage=Vh,i.deleteAssetStageCompletion=us,i.deleteAssetStageCompletions=hs,i.deleteAssetStages=ys,i.deleteAssetType=ks,i.deleteAssetTypeAttachment=sc,i.deleteAssetTypeAttachments=_s,i.deleteAssetTypeFieldValues=ws,i.deleteAssetTypeFieldValuesAttachment=dm,i.deleteAssetTypeFieldValuesAttachments=Qe,i.deleteAssetTypeFieldValuesMany=Mc,i.deleteAssetTypeFields=gc,i.deleteAssetTypeFieldsAttachment=Yh,i.deleteAssetTypeFieldsAttachments=uc,i.deleteAssetTypeFieldsMany=tm,i.deleteAssetTypes=gm,i.deleteAssets=za,i.deleteCategory=Hc,i.deleteDocumentAttachment=Qc,i.deleteDocumentAttachments=xc,i.deleteEmailDomain=ur,i.deleteForm=ei,i.deleteFormRevision=Zs,i.deleteFormRevisionAttachment=Nm,i.deleteFormRevisionAttachments=Ir,i.deleteFormRevisions=jr,i.deleteFormSubmission=ai,i.deleteFormSubmissionAttachment=af,i.deleteFormSubmissionAttachments=it,i.deleteFormSubmissions=ct,i.deleteGeoImage=li,i.deleteGeoImages=co,i.deleteIssue=Oi,i.deleteIssueAssociation=pi,i.deleteIssueAssociations=Ai,i.deleteIssueAttachment=Fo,i.deleteIssueAttachments=gi,i.deleteIssueComment=Ii,i.deleteIssueComments=gf,i.deleteIssueTypeFieldValues=qi,i.deleteIssueTypeFieldValuesAttachment=Yf,i.deleteIssueTypeFieldValuesAttachments=lt,i.deleteIssueTypeFieldValuesMany=Mf,i.deleteIssueTypeFields=td,i.deleteIssueTypeFieldsAttachment=Pf,i.deleteIssueTypeFieldsAttachments=Lo,i.deleteIssueTypeFieldsMany=Uf,i.deleteIssueUpdate=Td,i.deleteIssueUpdates=Fd,i.deleteIssues=zo,i.deleteOrganizationAccess=Cd,i.deleteProject=Zd,i.deleteProjectAccess=Ld,i.deleteProjectAccesses=Nd,i.deleteProjectAttachment=_l,i.deleteProjectAttachments=tn,i.deleteProjectFile=wl,i.deleteProjectFiles=El,i.deleteTeam=dn,i.dequeue=iu,i.discard=pn,i.documentAttachmentReducer=sr,i.documentAttachmentSlice=Bs,i.documentSlice=Ls,i.documentsReducer=or,i.downloadFile=qu,i.downloadInMemoryFile=wu,i.emailDomainsReducer=fr,i.emailDomainsSlice=Ws,i.emailRegex=Uu,i.enqueue=su,i.enqueueRequest=ul,i.fallbackToEmptyArray=S,i.fallbackToEmptyObject=ge,i.fileReducer=gr,i.fileSlice=Ks,i.fileToBlob=jn,i.formReducer=Cr,i.formRevisionAttachmentReducer=Pr,i.formRevisionAttachmentSlice=Ys,i.formRevisionReducer=Dr,i.formRevisionsSlice=Js,i.formSlice=Qs,i.formSubmissionAttachmentReducer=Wr,i.formSubmissionAttachmentSlice=ti,i.formSubmissionReducer=xr,i.formSubmissionSlice=ii,i.geoImageReducer=lo,i.geoImageSlice=di,i.getFileIdentifier=vu,i.getFileS3Key=Pt,i.getLocalDateString=wn,i.getLocalRelativeDateString=Pu,i.getOutboxCoordinator=Ae,i.getRenamedFile=En,i.hashFile=be,i.initSDK=uA,i.initializeAssetAttachments=Et,i.initializeAssetProcedureFieldValues=Sa,i.initializeAssetProcedureFieldValuesAttachments=ua,i.initializeAssetProcedureFields=na,i.initializeAssetProcedureFieldsAttachments=Xn,i.initializeAssetProcedureInstances=Ra,i.initializeAssetProcedures=ja,i.initializeAssetStageCompletions=$a,i.initializeAssetStages=Ka,i.initializeAssetTypeAttachments=xa,i.initializeAssetTypeFieldValues=Ec,i.initializeAssetTypeFieldValuesAttachments=Fc,i.initializeAssetTypeFields=Ac,i.initializeAssetTypeFieldsAttachments=oc,i.initializeAssetTypes=Vc,i.initializeAssets=Da,i.initializeCategories=Lc,i.initializeConversations=zn,i.initializeDocumentAttachments=Yc,i.initializeEmailDomains=dr,i.initializeFormRevisionAttachments=_r,i.initializeFormRevisions=wr,i.initializeFormSubmissionAttachments=Gr,i.initializeFormSubmissions=Yr,i.initializeForms=Vr,i.initializeGeoImages=to,i.initializeIssueAssociations=ho,i.initializeIssueAttachments=bo,i.initializeIssueTypeFieldValues=Yo,i.initializeIssueTypeFieldValuesAttachments=ad,i.initializeIssueTypeFields=Qo,i.initializeIssueTypeFieldsAttachments=$o,i.initializeIssueTypes=hd,i.initializeIssueUpdates=gd,i.initializeIssues=ko,i.initializeLicences=vd,i.initializeOrganizationAccesses=zd,i.initializeProjectAccesses=Yi,i.initializeProjectAttachments=Al,i.initializeProjectFiles=Ol,i.initializeTeams=Ul,i.isToday=Ru,i.issueAssociationReducer=So,i.issueAssociationSlice=hi,i.issueAttachmentReducer=Oo,i.issueAttachmentSlice=yi,i.issueCommentReducer=qo,i.issueCommentSlice=_i,i.issueReducer=Co,i.issueSlice=Ri,i.issueTypeFieldValuesAttachmentReducer=ld,i.issueTypeFieldValuesAttachmentSlice=zi,i.issueTypeFieldValuesReducer=Xo,i.issueTypeFieldValuesSlice=Ei,i.issueTypeFieldsAttachmentReducer=Wo,i.issueTypeFieldsAttachmentSlice=wi,i.issueTypeFieldsReducer=id,i.issueTypeFieldsSlice=Di,i.issueTypeReducer=yd,i.issueTypeSlice=Ci,i.issueUpdateReducer=Pd,i.issueUpdateSlice=Gi,i.licenseReducer=Ed,i.licenseSlice=Li,i.logOnlyOnce=Mu,i.markAsDeleted=hl,i.markForDeletion=Fp,i.memoize=It,i.moveDocument=ar,i.offline=F,i.onlyUniqueHashes=Cu,i.onlyUniqueOfflineIds=kn,i.organizationAccessReducer=$d,i.organizationAccessSlice=Hi,i.organizationReducer=ol,i.organizationSlice=Qi,i.outboxReducer=fl,i.outboxSlice=xi,i.overmapEnhancer=xp,i.overmapReducers=xl,i.overmapRootReducer=Yp,i.performRequest=fn,i.projectAccessReducer=Kd,i.projectAccessSlice=Ki,i.projectAttachmentReducer=Rl,i.projectAttachmentSlice=en,i.projectFileReducer=zl,i.projectFileSlice=nn,i.projectReducer=xd,i.projectSlice=Xi,i.rehydratedReducer=Vl,i.rehydratedSlice=cn,i.removeDocuments=Hs,i.removeIssueType=Ui,i.removeUser=Md,i.resetProjectFileObjectUrls=jp,i.resetStore=tu,i.restructureCreateSelectorWithArgs=y,i.saveActiveProjectFileBounds=Ml,i.selectAccessToken=Im,i.selectActiveOrganizationAccess=lp,i.selectActiveProjectFileId=Mp,i.selectActiveStatusLicenses=sp,i.selectAllDocumentAttachments=Gs,i.selectAllProjectAttachments=sn,i.selectAncestorIdsOfDocument=Dm,i.selectAssetAttachmentById=Wn,i.selectAssetAttachmentMapping=Hn,i.selectAssetAttachments=Mt,i.selectAssetById=rs,i.selectAssetProcedureById=es,i.selectAssetProcedureFieldValues=Gt,i.selectAssetProcedureFieldValuesAttachmentById=hh,i.selectAssetProcedureFieldValuesAttachments=ma,i.selectAssetProcedureFieldValuesAttachmentsByIds=fa,i.selectAssetProcedureFieldValuesAttachmentsMapping=Ct,i.selectAssetProcedureFieldValuesById=Lt,i.selectAssetProcedureFieldValuesMapping=Ta,i.selectAssetProcedureFieldValuesOfAsset=ph,i.selectAssetProcedureFields=zt,i.selectAssetProcedureFieldsAttachmentById=Qu,i.selectAssetProcedureFieldsAttachments=ta,i.selectAssetProcedureFieldsAttachmentsMapping=ea,i.selectAssetProcedureFieldsById=ch,i.selectAssetProcedureFieldsMapping=oa,i.selectAssetProcedureFieldsOfAssetProcedure=nh,i.selectAssetProcedureInstanceById=Jt,i.selectAssetProcedureInstances=Yt,i.selectAssetProcedureInstancesByIds=_h,i.selectAssetProcedureInstancesMapping=Kt,i.selectAssetProcedureInstancesOfAssetProcedure=va,i.selectAssetProcedureInstancesOfAssetType=bh,i.selectAssetProcedures=qa,i.selectAssetProceduresByIds=vh,i.selectAssetProceduresMapping=xt,i.selectAssetProceduresOfOrganization=Oh,i.selectAssetStageById=Xa,i.selectAssetStageCompletionById=Na,i.selectAssetStageCompletionMapping=ms,i.selectAssetStageCompletions=kh,i.selectAssetStageCompletionsByIds=Ha,i.selectAssetStages=Za,i.selectAssetStagesByIds=Ss,i.selectAssetStagesMappingOfAssetProcedure=Ch,i.selectAssetStagesOfAssetProcedure=Uh,i.selectAssetTypeAttachmentById=nc,i.selectAssetTypeAttachmentMapping=ic,i.selectAssetTypeAttachments=Ts,i.selectAssetTypeById=zs,i.selectAssetTypeFieldValues=Es,i.selectAssetTypeFieldValuesAttachmentById=lm,i.selectAssetTypeFieldValuesAttachments=Rc,i.selectAssetTypeFieldValuesAttachmentsByIds=Pc,i.selectAssetTypeFieldValuesAttachmentsMapping=Ps,i.selectAssetTypeFieldValuesById=js,i.selectAssetTypeFieldValuesMapping=kc,i.selectAssetTypeFieldValuesOfAsset=mm,i.selectAssetTypeFields=Xe,i.selectAssetTypeFieldsAttachmentById=Xh,i.selectAssetTypeFieldsAttachments=mc,i.selectAssetTypeFieldsAttachmentsMapping=hc,i.selectAssetTypeFieldsById=nm,i.selectAssetTypeFieldsMapping=bc,i.selectAssetTypeFieldsOfAssetType=sm,i.selectAssetTypeValuesOfAssetType=fm,i.selectAssetTypes=bm,i.selectAssetTypesByIds=_m,i.selectAssetTypesMapping=Ds,i.selectAssets=Va,i.selectAssetsByIds=qh,i.selectAssetsMapping=as,i.selectAssetsOfAssetType=cs,i.selectAttachmentsOfAsset=Kn,i.selectAttachmentsOfAssetByType=Hu,i.selectAttachmentsOfAssetProcedureFieldValues=pa,i.selectAttachmentsOfAssetProcedureFields=Zu,i.selectAttachmentsOfAssetType=ac,i.selectAttachmentsOfAssetTypeByType=Lh,i.selectAttachmentsOfAssetTypeFieldValues=Oc,i.selectAttachmentsOfAssetTypeFields=Jh,i.selectAttachmentsOfDocument=qm,i.selectAttachmentsOfDocumentByType=Mm,i.selectAttachmentsOfFormRevision=Hm,i.selectAttachmentsOfFormSubmission=Hr,i.selectAttachmentsOfIssue=Ro,i.selectAttachmentsOfIssueByType=yf,i.selectAttachmentsOfIssueTypeFieldValues=dd,i.selectAttachmentsOfIssueTypeFields=Of,i.selectAttachmentsOfProject=Il,i.selectAttachmentsOfProjectByType=Pp,i.selectCategories=Pm,i.selectCategoriesByIds=Om,i.selectCategoryById=$s,i.selectCategoryMapping=Us,i.selectCommentsOfIssue=bf,i.selectConversation=Bu,i.selectConversationMapping=vt,i.selectConversations=$u,i.selectCurrentUser=mt,i.selectDeletedRequests=_p,i.selectDocumentAttachmentById=tr,i.selectDocumentAttachmentMapping=er,i.selectDocumentById=rr,i.selectDocuments=cr,i.selectDocumentsByIds=km,i.selectDocumentsMapping=_e,i.selectEmailDomains=mr,i.selectEmailDomainsAsMapping=hr,i.selectEmailDomainsOfOrganization=Cm,i.selectFieldValuesOfAssetProcedureInstance=Ah,i.selectFilteredForms=xm,i.selectFormById=$r,i.selectFormMapping=Ur,i.selectFormRevisionAttachmentsMapping=Rr,i.selectFormRevisionById=Km,i.selectFormRevisionMapping=tt,i.selectFormRevisions=qr,i.selectFormRevisionsOfForm=kr,i.selectFormSubmissionAttachemntsByIds=Nr,i.selectFormSubmissionAttachmentsMapping=si,i.selectFormSubmissionById=oi,i.selectFormSubmissions=ri,i.selectFormSubmissionsMapping=ci,i.selectFormSubmissionsOfAsset=Qr,i.selectFormSubmissionsOfForm=Xr,i.selectFormSubmissionsOfIssue=Zr,i.selectForms=Qm,i.selectGeoImageById=ui,i.selectGeoImageMapping=ro,i.selectGeoImages=oo,i.selectGeoImagesOfProject=df,i.selectIsImportingProjectFile=kp,i.selectIsLoggedIn=Rm,i.selectIssueAssociationById=fo,i.selectIssueAssociationMapping=Ce,i.selectIssueAssociations=mf,i.selectIssueAssociationsOfAsset=yo,i.selectIssueAssociationsOfIssue=Ao,i.selectIssueAssociationsToIssue=po,i.selectIssueAttachmentById=Po,i.selectIssueAttachmentMapping=Io,i.selectIssueAttachments=bi,i.selectIssueById=vi,i.selectIssueCommentById=jo,i.selectIssueCommentMapping=Eo,i.selectIssueCountOfCategory=vm,i.selectIssueMapping=Vo,i.selectIssueTypeById=$i,i.selectIssueTypeFieldValues=Mi,i.selectIssueTypeFieldValuesAttachmentById=Jf,i.selectIssueTypeFieldValuesAttachments=rd,i.selectIssueTypeFieldValuesAttachmentsByIds=od,i.selectIssueTypeFieldValuesAttachmentsMapping=Vi,i.selectIssueTypeFieldValuesById=ki,i.selectIssueTypeFieldValuesMapping=Jo,i.selectIssueTypeFieldValuesOfIssue=kf,i.selectIssueTypeFields=ot,i.selectIssueTypeFieldsAttachmentById=vf,i.selectIssueTypeFieldsAttachments=Ho,i.selectIssueTypeFieldsAttachmentsMapping=No,i.selectIssueTypeFieldsById=Lf,i.selectIssueTypeFieldsMapping=sd,i.selectIssueTypeFieldsOfIssueType=$f,i.selectIssueTypeMapping=pd,i.selectIssueTypeValuesOfIssueType=Gf,i.selectIssueTypes=Ad,i.selectIssueTypesByIds=Xf,i.selectIssueTypesOfOrganization=Zf,i.selectIssueUpdateMapping=Id,i.selectIssueUpdatesOfIssue=Rd,i.selectIssuesByIds=_f,i.selectIssuesOfIssueType=Bi,i.selectIssuesOfIssueTypeCount=Qf,i.selectLatestAssetProcedureFieldsOfAssetProcedure=ah,i.selectLatestAssetTypeFieldsOfAssetType=im,i.selectLatestFormRevisionOfForm=Ym,i.selectLatestIssueTypeFieldsOfIssueType=Bf,i.selectLatestRetryTime=Tp,i.selectLicense=tp,i.selectLicenseForProject=wd,i.selectLicenses=ht,i.selectLicensesForProjectsMapping=ip,i.selectLicensesOfOrganization=gp,i.selectNumberOfAssetsOfAssetType=Mh,i.selectOrganizationAccessById=dp,i.selectOrganizationAccessForUser=up,i.selectOrganizationAccessUserMapping=Ud,i.selectOrganizationAccesses=Wi,i.selectOrganizationById=Ap,i.selectOrganizationUsersAsMapping=rl,i.selectOrganizationUsersIds=cl,i.selectOrganizations=al,i.selectOrganizationsMapping=nl,i.selectOrganizationsWithAccess=yp,i.selectProjectAccessById=hp,i.selectProjectAccessForUser=mp,i.selectProjectAccessMapping=Ji,i.selectProjectAccessUserMapping=Wd,i.selectProjectAccesses=Hd,i.selectProjectAttachmentById=Fl,i.selectProjectAttachmentMapping=Tl,i.selectProjectById=fp,i.selectProjectFileById=qp,i.selectProjectFileMapping=kl,i.selectProjectFiles=Dl,i.selectProjectMapping=Zi,i.selectProjectUsersAsMapping=tl,i.selectProjectUsersIds=el,i.selectProjectsOfOrganization=Sp,i.selectRehydrated=Vp,i.selectRootDocuments=zm,i.selectSortedOrganizationUsers=bp,i.selectSortedProjectUsers=pp,i.selectStageMapping=Je,i.selectTeamById=Re,i.selectTeams=un,i.selectTeamsByIds=Cp,i.selectTeamsMapping=ln,i.selectTeamsOfOrganization=Up,i.selectTeamsOfUser=$p,i.selectUploadUrl=Sr,i.selectUserById=rp,i.selectUsersByIds=op,i.selectUsersMapping=ft,i.separateFilesFromValues=ve,i.separateImageFromFields=$A,i.setActiveProjectFileId=ql,i.setAsset=Eh,i.setAssetAttachment=Gn,i.setAssetAttachments=Lu,i.setAssetProcedure=Rh,i.setAssetProcedureFieldValues=mh,i.setAssetProcedureFieldValuesAttachment=oh,i.setAssetProcedureFieldValuesAttachments=dh,i.setAssetProcedureFieldValuesMany=fh,i.setAssetProcedureFields=eh,i.setAssetProcedureFieldsAttachment=Ku,i.setAssetProcedureFieldsAttachments=Yu,i.setAssetProcedureFieldsMany=th,i.setAssetProcedureInstance=Sh,i.setAssetProcedureInstances=gh,i.setAssetProcedures=Ph,i.setAssetStage=Ya,i.setAssetStages=Dh,i.setAssetType=pm,i.setAssetTypeAttachment=ec,i.setAssetTypeAttachments=Bh,i.setAssetTypeFieldValues=um,i.setAssetTypeFieldValuesAttachment=cm,i.setAssetTypeFieldValuesAttachments=rm,i.setAssetTypeFieldValuesMany=hm,i.setAssetTypeFields=Qh,i.setAssetTypeFieldsAttachment=Hh,i.setAssetTypeFieldsAttachments=Wh,i.setAssetTypeFieldsMany=xh,i.setAssetTypes=Am,i.setAssets=jh,i.setConversation=Cn,i.setCurrentUser=np,i.setDocumentAttachment=Xc,i.setDocumentAttachments=Em,i.setDocuments=nr,i.setForm=Jm,i.setFormRevision=vr,i.setFormRevisionAttachment=Bm,i.setFormRevisionAttachments=Gm,i.setFormSubmission=nt,i.setFormSubmissionAttachment=tf,i.setFormSubmissionAttachments=sf,i.setFormSubmissions=cf,i.setGeoImage=Ve,i.setGeoImages=so,i.setIsImportingProjectFile=jl,i.setIssueAssociation=uf,i.setIssueAssociations=lf,i.setIssueAttachment=_o,i.setIssueAttachments=pf,i.setIssueComment=Ti,i.setIssueComments=wo,i.setIssueType=$e,i.setIssueTypeFieldValues=Ef,i.setIssueTypeFieldValuesAttachment=Hf,i.setIssueTypeFieldValuesAttachments=Wf,i.setIssueTypeFieldValuesMany=jf,i.setIssueTypeFields=zf,i.setIssueTypeFieldsAttachment=Ff,i.setIssueTypeFieldsAttachments=If,i.setIssueTypeFieldsMany=Vf,i.setIssueUpdate=xf,i.setLoggedIn=$c,i.setOrganizations=il,i.setProfilePicture=ap,i.setProjectAttachment=Sl,i.setProjectAttachments=gl,i.setProjectFile=Op,i.setProjectFiles=vp,i.setProjects=Jd,i.setRehydrated=zp,i.setTeam=Ie,i.setTokens=Tm,i.setUploadUrl=yr,i.setUsers=qd,i.shallowEqual=vn,i.slugify=zu,i.spacesToDashesLower=Du,i.teamReducer=Bl,i.teamSlice=rn,i.toFileNameSafeString=ku,i.toOfflineIdRecord=Mn,i.truncate=Vu,i.updateAsset=Me,i.updateAssetAttachment=Nu,i.updateAssetAttachments=Ln,i.updateAssetProcedure=qe,i.updateAssetProcedureFieldValues=Ee,i.updateAssetProcedureFieldValuesAttachment=lh,i.updateAssetProcedureFieldValuesAttachments=ha,i.updateAssetProcedureFieldValuesMany=ba,i.updateAssetProcedureFields=ca,i.updateAssetProcedureFieldsAttachment=Ju,i.updateAssetProcedureFieldsAttachments=Qn,i.updateAssetProcedureFieldsMany=sh,i.updateAssetProcedureInstance=je,i.updateAssetProcedureInstances=yh,i.updateAssetProcedures=Fh,i.updateAssetStage=As,i.updateAssetStageCompletion=Ba,i.updateAssetStageCompletions=Ga,i.updateAssetStages=Ye,i.updateAssetType=De,i.updateAssetTypeAttachment=Gh,i.updateAssetTypeAttachments=tc,i.updateAssetTypeFieldValues=ke,i.updateAssetTypeFieldValuesAttachment=om,i.updateAssetTypeFieldValuesAttachments=Ic,i.updateAssetTypeFieldValuesMany=qc,i.updateAssetTypeFields=Sc,i.updateAssetTypeFieldsAttachment=Kh,i.updateAssetTypeFieldsAttachments=lc,i.updateAssetTypeFieldsMany=em,i.updateAssetTypes=Sm,i.updateAssets=wh,i.updateCategory=Nc,i.updateConversation=Un,i.updateDocumentAttachment=jm,i.updateDocumentAttachments=Zc,i.updateDocuments=le,i.updateForm=Zm,i.updateFormRevisionAttachment=Lm,i.updateFormRevisionAttachments=Fr,i.updateFormSubmission=Jr,i.updateFormSubmissionAttachment=nf,i.updateFormSubmissionAttachments=Lr,i.updateFormSubmissions=rf,i.updateGeoImage=ao,i.updateGeoImages=of,i.updateIssue=rt,i.updateIssueAssociation=mo,i.updateIssueAssociations=hf,i.updateIssueAttachment=Af,i.updateIssueAttachments=To,i.updateIssueType=fd,i.updateIssueTypeFieldValues=Ue,i.updateIssueTypeFieldValuesAttachment=Kf,i.updateIssueTypeFieldValuesAttachments=cd,i.updateIssueTypeFieldValuesMany=qf,i.updateIssueTypeFields=ed,i.updateIssueTypeFieldsAttachment=Rf,i.updateIssueTypeFieldsAttachments=Go,i.updateIssueTypeFieldsMany=Cf,i.updateLicense=oe,i.updateOrganizationAccess=Vd,i.updateProject=Xd,i.updateProjectAccess=Gd,i.updateProjectAttachment=Rp,i.updateProjectAttachments=bl,i.updateProjectFile=an,i.updateProjectFiles=Ep,i.updateTeam=on,i.userReducer=kd,i.userSlice=Ni,i.versioningReducer=Ll,i.versioningSlice=Gl,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
15
+ external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(A)}const f=d.type.split("/")[1];if(!f)throw new Error("File has no extension");const p=a??h+"."+f;if(d=jn(d,p),!d.name)throw new Error("Failed to set file's name");await this.addCache(d,h),bt[c]=new Promise(A=>{A(d)})}return d}}class fy extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{revisionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_revision:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,form_revision:h};r.push(_)}this.dispatch(vr(c));const o=this.enqueueRequest({description:"Attach files to form revision",method:l.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.form_revision),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(wr(d.attachments))}).catch(()=>{this.dispatch(Er(c.map(d=>d.offline_id)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:l.GET,url:"/form-revision-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Or(s))}}class py extends j{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=F({...e,created_by:a,submitted_at:new Date().toISOString()});this.dispatch(Xs(c));const r=this.enqueueRequest({description:"Create form revision",method:l.POST,url:"/form-revisions/",payload:v(c),blockers:[e.form],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(kr(m))}).catch(()=>{this.dispatch(Qs(c.offline_id))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:l.GET,url:"/form-revisions/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Cr(s))}}const Ay=async t=>{const e={},s=[];for(const n of t){if(n.type!=="section")throw new Error(`Expected ISerializedField type to be a section. Got ${n.type} instead.`);const{fields:a}=n,c=[];for(const r of a){if(r.image){if(r.image instanceof Promise)try{e[r.identifier]=await r.image}catch(o){console.error("Failed to get image from promise",o)}else e[r.identifier]=r.image;delete r.image}c.push(r)}s.push({...n,fields:c})}return{fields:s,images:e}};class yy extends j{add(e,s){var d;const{store:n}=this.client,a=new Date().toISOString(),c=(d=n.getState().userReducer.currentUser)==null?void 0:d.id,r=F({...e,submitted_at:a,created_by:c}),o=F({...s,form:r.offline_id,submitted_at:a,created_by:c});this.dispatch(xs(r)),this.dispatch(Xs(o));const m=this.enqueueRequest({description:"Create form",method:l.POST,url:"/forms/",payload:{...v(r),initial_revision:{offline_id:o.offline_id,submitted_at:o.submitted_at,title:o.title,description:o.description,fields:o.fields}},blockers:[],blocks:[r.offline_id,o.offline_id]});return m.catch(h=>{throw this.dispatch(ei(r.offline_id)),this.dispatch(Qs(o.offline_id)),h}),[r,o,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Hr(e)(n);if(!a)throw new Error("Expected form to exist");const c=td(e)(n);c.length>0&&this.dispatch(ot(c.map(({offline_id:o})=>o)));const r=Ur(e)(n);r.length>0&&this.dispatch(zr(r.map(({offline_id:o})=>o))),this.dispatch(ei(e));try{return await this.enqueueRequest({description:"Delete form",method:l.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(xs(a)),r.length>0&&this.dispatch(Dr(r)),c.length>0&&this.dispatch(dt(c)),o}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:l.GET,url:"/forms/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Gr(s))}}class Sy extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{submissionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_submission:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,form_submission:h};r.push(_)}this.dispatch(at(c));const o=this.enqueueRequest({description:"Attach files to form submission",method:l.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.form_submission),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Yr(d.attachments))}).catch(d=>{throw this.dispatch(ct(c.map(h=>h.offline_id))),d}),[c,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Jr(e)(n);this.dispatch(ct(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:l.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(at(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:l.GET,url:"/form-submission-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Kr(s))}}class gy extends j{async add(e){var f;const{store:s}=this.client,{file:n,...a}=e,c=new Date().toISOString(),r=(f=s.getState().userReducer.currentUser)==null?void 0:f.id,o=a.project,m=await this.getFilePayload(n),d=F({...a,file_name:n.name,file_sha1:m.sha1,file:URL.createObjectURL(n),submitted_at:c,created_by:r});this.dispatch(dd(d));const h=this.enqueueRequest({description:"Add geo image",method:l.POST,url:"/geo-images/",payload:{offline_id:d.offline_id,submitted_at:c,title:d.title,description:d.description,geo_marker:d.geo_marker,canvas_marker:d.canvas_marker,sha1:d.file_sha1,project:d.project,file_name:d.file_name,direction:d.direction,original_date:d.original_date,file:m},blocks:[o.toString()],blockers:[o.toString()]});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(Be(p.geo_image))}).catch(()=>{this.dispatch(li(d.offline_id))}),[d,h.then(p=>p.geo_image)]}async bulkAdd(e,s){var f;const{store:n}=this.client,a=new Date().toISOString(),c=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,r=[],o=[],m=[],d={};for(const p of e){const{file:A,...T}=p,_=await this.getFilePayload(A);_.sha1 in d||(d[_.sha1]=_);const b=F({...T,file_name:A.name,file_sha1:_.sha1,file:URL.createObjectURL(A),submitted_at:a,created_by:c,project:s});r.push(b),o.push(b.offline_id),m.push({offline_id:b.offline_id,sha1:b.file_sha1,file_name:b.file_name,title:b.title,description:b.description,geo_marker:b.geo_marker,canvas_marker:b.canvas_marker,direction:b.direction,original_date:b.original_date})}this.dispatch(od(r));const h=this.enqueueRequest({description:"Bulk add geo images",method:l.POST,url:"/geo-images/bulk/",payload:{submitted_at:a,project:s,geo_images:m,files:Object.values(d)},blocks:[s.toString()],blockers:o});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(rd(p.geo_images))}).catch(()=>{this.dispatch(ud(o))}),[r,h.then(p=>p.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=ui(e.offline_id)(n);if(!a)throw new Error(`Map image with offline_id ${e.offline_id} does not exist in the store`);const c={...a,...e};this.dispatch(ld(c));const r=this.enqueueRequest({description:"Update geo image",method:l.PATCH,url:`/geo-images/${e.offline_id}/`,payload:e,blocks:[e.offline_id],blockers:[e.offline_id]});return r.then(o=>{this.dispatch(Be(o))}).catch(()=>{this.dispatch(Be(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ui(e)(n);if(!a)throw new Error(`Map image with offline_id ${e} does not exist in the store`);this.dispatch(li(e));const c=this.enqueueRequest({description:"Delete geo image",method:l.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(Be(a))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:l.GET,url:`/projects/${e}/geo-images/`,blocks:[e.toString()],blockers:[]});this.dispatch(cd(s))}}class by extends R{add(e){var o;const{store:s}=this.client,n=new Date().toISOString(),a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=F({...e,submitted_at:n,created_by:a});this.dispatch(mi(c));const r=this.enqueueRequest({description:"Add issue association",method:l.POST,url:"/issue-associations/",payload:v(c),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(yd(m))}).catch(()=>{this.dispatch(pi(c.offline_id))}),[c,r]}async delete(e){const{store:s}=this.client,n=Sd(e)(s.getState());if(!n)throw new Error(`Issue association with id ${e} not found in store.`);this.dispatch(pi(e));const a=this.enqueueRequest({description:"Delete issue association",method:l.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(mi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:l.GET,url:"/issue-associations/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ad(s))}}class Ty extends be{constructor(){super(...arguments);y(this,"name","Issue Attachment");y(this,"url","/issue-attachments");y(this,"initializeAttachments",Si);y(this,"addAttachments",gi);y(this,"updateAttachments",Rd);y(this,"removeAttachments",bi);y(this,"removeAttachment",Pd);y(this,"setAttachment",Id);y(this,"selectAttachment",Ed)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue:s.modelId})}buildAttachmentPayload(s){return{...s,issue:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(Si(n))}}class _y extends be{constructor(){super(...arguments);y(this,"name","Issue Comment Attachment");y(this,"url","/issue-comment-attachments");y(this,"initializeAttachments",_i);y(this,"addAttachments",Md);y(this,"updateAttachments",Cd);y(this,"removeAttachments",zd);y(this,"removeAttachment",Dd);y(this,"setAttachment",kd);y(this,"selectAttachment",$d)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_comment:s.modelId})}buildAttachmentPayload(s){return{...s,issue_comment:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueCommentId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue comment attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(_i(n))}}class Fy extends R{add(e){var c;const{store:s}=this.client,n=F({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Ri(n));const a=this.enqueueRequest({description:"Add issue comment",method:l.POST,url:"/issue-comments/",payload:v(n),blockers:[e.issue],blocks:[n.offline_id]});return a.catch(()=>{this.dispatch(Pi(n.offline_id))}),[n,a]}update(e){const{store:s}=this.client,n=Hd(e.offline_id)(s.getState());if(!n)throw new Error(`Comment with offline_id ${e.offline_id} not found in store`);const a={...n,...e};this.dispatch(Ii(a));const c=this.enqueueRequest({description:"Edit issue comment",method:l.PATCH,url:`/issue-comments/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{this.dispatch(Ii(n))}),[a,c]}remove(e){const s=this.client.store.getState().issueCommentReducer.instances[e];if(!s)throw new Error(`Comment with offline_id ${e} not found in store`);this.dispatch(Pi(e));const n=this.enqueueRequest({description:"Delete comment",method:l.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Ri(s))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:l.GET,url:"/issue-comments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ld(s))}}class Iy extends R{add(e){var m;const{store:s}=this.client,n=s.getState(),a=new Date().toISOString(),c=(m=n.userReducer.currentUser)==null?void 0:m.id,r=F({...e,submitted_at:a,created_by:c});this.dispatch(vi(r));const o=this.enqueueRequest({description:"Create issue",method:l.POST,url:"/issues/",payload:v(r),blockers:["add-issue",r.project.toString(),r.issue_type,...r.category?[r.category]:[]],blocks:[r.offline_id]});return o.then(d=>{this.dispatch(lt(d))}).catch(d=>{throw this.dispatch(wi(r.offline_id)),d}),[r,o]}update(e){var m;const s=this.client.store.getState(),n=Ei(e.offline_id)(s);if(!n)throw new Error(`Attempting to update an issue with offline_id ${e.offline_id} that doesn't exist in the store`);const a={...n,...e};this.dispatch(lt(a));const c={};for(const d of[w.TITLE,w.DESCRIPTION,w.STATUS,w.CATEGORY,w.PRIORITY,w.ASSIGNED_TO,w.DUE_DATE])if(d in e&&e[d]!==n[d])switch(d){case w.PRIORITY:case w.STATUS:{const h=e[d];c[d]=h!==void 0?Number(h):null;break}case w.DUE_DATE:case w.DESCRIPTION:case w.TITLE:c[d]=e[d]??null;break;case w.CATEGORY:{let h=null;const f=e[d];if(f&&(h=s.categoryReducer.instances[f]??null,!h))throw new Error(`Trying to update issue category to ${f} which does not exist in store`);c[d]=h?{name:h.name,color:h.color,offline_id:h.offline_id}:null;break}case w.ASSIGNED_TO:{let h=null;const f=e[d];if(f&&(h=s.userReducer.users[f]??null,!h))throw new Error(`Trying to update issue assigned_to to ${f} which does not exist in store`);c[d]=h?{full_name:h.username,id:h.id}:null;break}}const r=F({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:n.offline_id,changes:c});this.dispatch(Ho(r));const o=this.enqueueRequest({description:"Edit issue",method:l.PATCH,url:`/issues/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return o.catch(()=>{this.dispatch(lt(n)),this.dispatch(Ko(r.offline_id))}),[a,o]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Ei(e)(n);if(!a)throw new Error(`No issue with id ${e} found in the store`);const c=wd(e)(n),r=Xo(e)(n),o=sd(e)(n),m={};for(const h of gd(e)(n))m[h.offline_id]=h;for(const h of bd(e)(n))m[h.offline_id]=h;const d=Object.values(m);this.dispatch(wi(e)),c.length>0&&this.dispatch(bi(c.map(({offline_id:h})=>h))),r.length>0&&this.dispatch(Yo(r.map(({offline_id:h})=>h))),o.length>0&&this.dispatch(ot(o.map(({offline_id:h})=>h))),d.length>0&&this.dispatch(Ai(d.map(({offline_id:h})=>h)));try{return await this.enqueueRequest({description:"Delete issue",method:l.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(h){throw this.dispatch(vi(a)),this.dispatch(gi(c)),this.dispatch(Wo(r)),this.dispatch(dt(o)),this.dispatch(fi(d)),h}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:l.GET,url:"/issues/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Yd(s))}}class Ry extends be{constructor(){super(...arguments);y(this,"name","Issue Type Attachment");y(this,"url","/issue-type-attachments");y(this,"initializeAttachments",qi);y(this,"addAttachments",eo);y(this,"updateAttachments",so);y(this,"removeAttachments",no);y(this,"removeAttachment",io);y(this,"setAttachment",to);y(this,"selectAttachment",ro)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_type:s.modelId})}buildAttachmentPayload(s){return{...s,issue_type:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueTypeId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue type attachments",method:l.GET,url:`${this.url}/`,queryParams:{organization:s.toString()},blocks:[],blockers:[]});this.dispatch(qi(n))}}class Py extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,file_extension:A.extension,field_identifier:f,file_sha1:A.sha1,fields_revision:h};r.push(_)}this.dispatch(ho(c));const o=this.enqueueRequest({description:"Add issue type fields attachments",method:l.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(mo(d.attachments))}).catch(()=>{this.dispatch(fo(c.map(d=>d.offline_id)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:l.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(uo(s))}}class Oy extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Io(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:l.POST,url:"/issue-type-fields/",payload:v(c),blockers:[c.issue_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(Ro(m))}).catch(m=>{throw this.dispatch(Po(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:l.GET,url:"/issue-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Fo(s))}}class vy extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldValuesId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,field_values:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,field_values:h};r.push(_)}this.dispatch(ht(c));const o=this.enqueueRequest({description:"Add issue type field values attachments",method:l.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.field_values),blocks:c.map(d=>d.offline_id)});return o.then(({presigned_urls:d,attachments:h})=>{this.processPresignedUrls(d),this.dispatch(jo(h))}).catch(d=>{throw this.dispatch(mt(c.map(h=>h.offline_id))),d}),[c,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Mo(e)(n);this.dispatch(mt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:l.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(ht(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values attachments",method:l.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Eo(s))}}class wy extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:l.POST,url:"/issue-type-field-values/",payload:v(a),blockers:[e.issue,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(Ci(a)),c.then(o=>(this.dispatch(Le(o)),o)).catch(()=>{this.dispatch(Di(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Vi(e.offline_id)(n);if(!a)throw new Error(`Expected IssueTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Le(c));const r=this.enqueueRequest({description:"Update issue type field values",method:l.PATCH,url:`/issue-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.issue],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Le(o))}).catch(()=>{this.dispatch(Le(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Vi(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=ko(e)(n);this.dispatch(Di(e)),this.dispatch(mt(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete issue type field values",method:l.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Ci(a)),this.dispatch(ht(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:l.GET,url:"/issue-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(go(s))}}class Ey extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,submitted_at:new Date().toISOString(),created_by:(r=n.userReducer.currentUser)==null?void 0:r.id});this.dispatch(Vo(a));const c=this.enqueueRequest({method:l.POST,url:"/issue-types/",payload:v(a),blockers:[],blocks:[a.offline_id]});return c.then(o=>{this.dispatch(Ne(o))}).catch(()=>{this.dispatch(Li(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Ni(e.offline_id)(n);if(!a)throw new Error(`IssueType with offline_id ${e.offline_id} does not exist in the store.`);const c={...a,...e};this.dispatch(Uo(c));const r=this.enqueueRequest({method:l.PATCH,url:`/issue-types/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return r.then(o=>{this.dispatch(Ne(o))}).catch(()=>{this.dispatch(Ne(a))}),[c,r]}delete(e){const{store:s}=this.client,n=s.getState(),a=Ni(e)(n);if(!a)throw new Error(`IssueType with offline_id ${e} does not exist in the store.`);const c=Hi(e)(n);this.dispatch(Li(e)),this.dispatch(Xd(c.map(o=>o.offline_id)));const r=this.enqueueRequest({method:l.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(Ne(a)),this.dispatch(Jd(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:l.GET,url:"/issue-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(zo(s))}}class jy extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:l.GET,url:"/issue-updates/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(No(s))}}class qy extends gu{constructor(e){super(e)}}const My=1800;function ky(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 Cy extends qy{constructor(){super(...arguments);y(this,"_getRenewedTokens",async s=>{const n=this.enqueueRequest({description:"Get renewed tokens",method:l.POST,url:this.refreshTokensUrl,payload:{refresh:s},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let a;try{a=await n}catch(c){console.error("Could not renew tokens; clearing auth",c),this.clearAuth();return}if(!a.access)throw new Error("Missing access token");return{accessToken:a.access,refreshToken:a.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Nc(!1)),this.clearTokens(),this.dispatch({type:Bu.RESET_STATE}),this.dispatch({type:Ou})}async renewTokens(){const s=this.getRefreshToken();if(!s)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const n=await this._getRenewedTokens(s);if(!n)return;console.log("Got renewed tokens"),this.setTokens(n)}catch(n){throw console.error("Could not renew tokens; clearing auth",n),this.clearAuth(),n}}tokenIsExpiringSoon(){const s=this.getAccessToken();if(!s)return!1;const n=Date.now()/1e3;let a;try{a=Gu(s).exp??n}catch{a=n}return a-n<My}getAuthHeader(){return`Bearer ${this.getAccessToken()}`}async prepareAuth(){if(this.tokenIsExpiringSoon()){console.debug(this.constructor.name,"preparing auth");try{await this.renewTokens()}catch(s){return s instanceof q&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??Ee).toString()))}}}async handleUnauthorized(s,n){const a=this.client.store.getState();if(s.url.endsWith("/token/refresh/"))throw a.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new q({message:"You have been signed out due to inactivity.",response:n,discard:!0});if(a.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new q({message:"Incorrect username or password.",response:n,discard:!0})}async initAuth(s){const n=O.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:n,description:"Get token pair",method:l.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(a=>{this.setTokens(ky(a))})}}class Dy extends R{async getLicense(e){const s=await this.enqueueRequest({description:"Get license",method:l.GET,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(ue(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:l.DELETE,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(ue(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:l.PATCH,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(ue(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:l.DELETE,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(ue(s)),s}async attachLicenseToProject(e,s){const n=await this.enqueueRequest({description:"Attach license",method:l.PATCH,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,payload:{project:s.id},blockers:[e.organization_owner?e.organization_owner.toString():"",s.id?s.id.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(ue(n)),n}async detachLicenseFromProject(e){const s=await this.enqueueRequest({description:"Detach license",method:l.DELETE,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(ue(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:l.GET,url:`/billing/${e.offline_id}/transaction/`,isAuthNeeded:!0,blockers:[e.offline_id],blocks:[e.offline_id]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get licenses",method:l.GET,url:`/organizations/${s}/licenses/`,isAuthNeeded:!0,blockers:[s.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of a)n[r.offline_id]=r;const c=await this.enqueueRequest({description:"Get licenses",method:l.GET,url:`/projects/${e}/licenses/`,isAuthNeeded:!0,blockers:[e.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of c)n[r.offline_id]=r;this.dispatch(xo(Object.values(n)))}}class zy extends R{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:l.PATCH,url:`/organizations/${e.organization}/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return s.then(()=>{this.dispatch(dl(e))}),s}async remove(e){return this.dispatch(ol(e.offline_id)),this.dispatch(nl(e.user)),this.enqueueRequest({description:"Remove organization access",method:l.DELETE,url:`/organizations/${e.organization}/access/${e.offline_id}/`,blockers:[e.offline_id],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:l.GET,url:`/organizations/${e}/access/`,blockers:[],blocks:[]});this.dispatch(rl(s))}}class Vy extends R{create(e){return this.enqueueRequest({description:"Create organization",method:l.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:l.PATCH,url:`/organizations/${e.id}/`,payload:e,blockers:[`add-org-${e.name}`,e.id.toString()],blocks:[e.id.toString()]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:l.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get organizations",method:l.GET,url:`/projects/${e}/organizations/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Get organization",method:l.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.id]=c,this.dispatch(vl(Object.values(n)))}}class Uy extends R{async update(e){return this.dispatch(ml(e)),this.enqueueRequest({description:"Edit project access",method:l.PATCH,url:`/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id,"change-access-level"],blocks:[e.offline_id]})}async remove(e){return this.dispatch(fl(e)),this.enqueueRequest({description:"Delete project access",method:l.DELETE,url:`/access/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:l.GET,url:`/projects/${e}/access/`,blockers:[],blocks:[]});this.dispatch(Zi(s))}}class $y extends be{constructor(){super(...arguments);y(this,"name","Project Attachment");y(this,"url","/project-attachments");y(this,"addAttachments",Gl);y(this,"updateAttachments",Hl);y(this,"removeAttachments",an);y(this,"removeAttachment",Wl);y(this,"setAttachment",Ll);y(this,"selectAttachment",Jl)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,project:s.modelId})}buildAttachmentPayload(s){return{...s,project:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.projectId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get project attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blockers:[],blocks:[]});this.dispatch(Bl(n))}}class By extends R{async saveExisting(e){if(!e.offline_id)throw new Error("You can only use this method to save existing project files. The one provided has no offline_id.");const s={...e};delete s.file;const n=this.enqueueRequest({method:l.PATCH,url:`/projects/files/${e.offline_id}/`,payload:s,blockers:[e.offline_id],blocks:[e.offline_id]});return n.then(a=>{this.dispatch(rn(a))}),n}saveActive(){const{store:e}=this.client,s=e.getState(),n=s.projectFileReducer.activeProjectFileId;if(!n)throw new Error("No active project file");const a=s.projectFileReducer.instances[n];if(!a)throw new Error("No active project file");if(!a.bounds&&!a.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let c;if(typeof a.file=="string"&&!a.file.startsWith("blob:")){const m={...a};delete m.file,c={method:l.PATCH,url:`/projects/files/${n}/`,payload:m,blockers:[n],blocks:[n]}}else c=new Promise((m,d)=>{this.client.files.uploadFileToS3(a.file_sha1).then(([h])=>{m({method:l.POST,url:`/projects/${a.project}/files/`,payload:{...a,...h},blockers:[n],blocks:[n]})}).catch(d)});const o=Promise.resolve(c).then(m=>this.enqueueRequest(m));return o.then(m=>{this.dispatch(rn(m))}),this.dispatch(au),this.dispatch(nu(null)),this.dispatch(iu(!1)),[a,o]}delete(e){return this.dispatch(tu(e)),this.enqueueRequest({method:l.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:l.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(xl(s))}}class Gy 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:l.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(Tl(e)),await this.enqueueRequest({description:"Update project",method:l.PATCH,url:`/projects/${e.id}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.id.toString()],blocks:[e.id.toString()]})}async delete(e){const{store:s}=this.client,n=s.getState(),a=gt(n),c=a[e];if(!c)throw new Error("Expected project to exist");const r=ru(n).filter(h=>h.project===e);this.dispatch(su(r.map(({offline_id:h})=>h)));const o=Xl(c.id)(n);this.dispatch(an(o.map(({offline_id:h})=>h)));const m=Al(n);this.dispatch(pl(m.map(({offline_id:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(_l(c));const d=el(c.id)(n);d&&this.dispatch(ue({...d,project:null}));try{await this.enqueueRequest({description:"Delete project",method:l.DELETE,url:`/projects/${e}/`,blockers:[e.toString()],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(h){throw this.dispatch(bl(Object.values(a))),this.dispatch(Zi(Object.values(m))),this.dispatch(eu(r)),this.dispatch(Nl(o)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),d&&this.dispatch(ue({...d,project:c.id})),h}}invite(e,s){const n=O.v4();return this.enqueueRequest({description:"Invite user to project",method:l.POST,url:`/projects/${e}/invite/${s}/`,payload:{offline_id:n},blockers:[],blocks:[n]})}joinProject(e,s,n){return this.enqueueRequest({description:"Join project",method:l.GET,url:`/projects/${e}/join-project/${s}/${n}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:l.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e.toString()],blocks:[e.toString()]}).then(()=>{this.dispatch(Fl(e))})}}class Ly extends R{add(e){const s=F({...e,submitted_at:new Date().toISOString()});this.dispatch(hu(s));const n=this.enqueueRequest({description:"Create team",method:l.POST,url:`/organizations/${e.organization}/teams/`,payload:s,blockers:[],blocks:[s.offline_id]});return n.then(a=>{this.dispatch(ve(a))}).catch(()=>{this.dispatch(un(s.offline_id))}),[s,n]}update(e){const{store:s}=this.client,n=we(e.offline_id)(s.getState());if(!n)throw new Error(`Expected team with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(ln(a));const c=this.enqueueRequest({description:"Update team",method:l.PATCH,url:`/organizations/teams/${e.offline_id}/`,payload:v(e),blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(ve(r))}).catch(()=>{this.dispatch(ve(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=we(e)(n);if(!a)throw new Error(`Expected team with id ${e} to exist`);this.dispatch(un(e));try{return await this.enqueueRequest({description:"Delete team",method:l.DELETE,url:`/organizations/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(ve(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=we(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);if(s.length!==new Set(s).size)throw new Error("Duplicate members found in the list");this.dispatch(ln({...a,members:s}));const c=this.enqueueRequest({description:"Set team members",method:l.PUT,url:`/organizations/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(ve(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=we(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=[...a.members,...s];return this.setMembers(e,c)}async removeMembers(e,s){const{store:n}=this.client,a=we(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=a.members.filter(r=>!s.includes(r));return this.setMembers(e,c)}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:l.GET,url:`/organizations/${e}/teams/`,blockers:[],blocks:[]});this.dispatch(uu(s))}}class Ny extends R{async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Fetch organization users",method:l.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:l.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)n[r.id]=r;this.dispatch(il(Object.values(n)))}}var Mu=(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))(Mu||{});i.APIError=q,i.AgentService=GA,i.AssetAttachmentService=LA,i.AssetProcedureFieldValuesAttachmentService=WA,i.AssetProcedureFieldValuesService=JA,i.AssetProcedureFieldsAttachmentService=NA,i.AssetProcedureFieldsService=HA,i.AssetProcedureInstanceService=XA,i.AssetProcedureService=QA,i.AssetService=ZA,i.AssetStageCompletionService=xA,i.AssetStageService=ey,i.AssetTypeAttachmentService=ty,i.AssetTypeFieldValuesAttachmentService=ny,i.AssetTypeFieldValuesService=ay,i.AssetTypeFieldsAttachmentService=sy,i.AssetTypeFieldsService=iy,i.AssetTypeService=cy,i.AttachmentModel=In,i.BaseApiService=R,i.BaseSDK=$A,i.COMMON_AUTO_FIELDS=kn,i.CategoryService=ry,i.DEFAULT_ISSUE_PRIORITY=Nu,i.DEFAULT_ISSUE_STATUS=Lu,i.DeferredPromise=wn,i.DocumentAttachmentService=dy,i.DocumentService=oy,i.EMPTY_ARRAY=_n,i.EMPTY_OBJECT=Fn,i.EmailDomainsService=ly,i.EmailVerificationService=uy,i.FileService=my,i.FormRevisionAttachmentService=fy,i.FormRevisionService=py,i.FormService=yy,i.FormSubmissionAttachmentService=Sy,i.FormSubmissionService=YA,i.GeoImageService=gy,i.HttpMethod=l,i.IssueAssociationService=by,i.IssueAttachmentService=Ty,i.IssueCommentAttachmentService=_y,i.IssueCommentService=Fy,i.IssuePriority=Rt,i.IssueService=Iy,i.IssueStatus=Pt,i.IssueTypeAttachmentService=Ry,i.IssueTypeFieldValuesAttachmentService=vy,i.IssueTypeFieldValuesService=wy,i.IssueTypeFieldsAttachmentService=Py,i.IssueTypeFieldsService=Oy,i.IssueTypeService=Ey,i.IssueUpdateChange=w,i.IssueUpdateService=jy,i.JWTService=Cy,i.LicenseLevel=Pn,i.LicenseService=Dy,i.LicenseStatus=On,i.OUTBOX_RETRY_DELAY=vn,i.OrganizationAccessLevel=It,i.OrganizationAccessService=zy,i.OrganizationService=Vy,i.OutboxCoordinator=je,i.PaddleCheckoutEvent=Rn,i.ProjectAccessLevel=Ft,i.ProjectAccessService=Uy,i.ProjectAttachmentService=$y,i.ProjectFileService=By,i.ProjectService=Gy,i.TeamService=Ly,i.UNKNOWN_ERROR_MESSAGE=Ee,i.UserService=Ny,i.VERSION_REDUCER_KEY=fn,i.VerificationCodeType=Mu,i._setLatestRetryTime=Vl,i.acceptProjectInvite=Fl,i.addAsset=as,i.addAssetAttachment=ph,i.addAssetAttachments=Ct,i.addAssetProcedure=es,i.addAssetProcedureFieldValues=Lt,i.addAssetProcedureFieldValuesAttachment=Mh,i.addAssetProcedureFieldValuesAttachments=Je,i.addAssetProcedureFieldValuesMany=_a,i.addAssetProcedureFields=da,i.addAssetProcedureFieldsAttachment=Sh,i.addAssetProcedureFieldsAttachments=ea,i.addAssetProcedureFieldsMany=Rh,i.addAssetProcedureInstance=Yt,i.addAssetProcedureInstances=wa,i.addAssetProcedures=Yh,i.addAssetStage=dm,i.addAssetStageCompletion=hs,i.addAssetStageCompletions=ms,i.addAssetStages=Ss,i.addAssetType=Cs,i.addAssetTypeAttachment=hm,i.addAssetTypeAttachments=Fs,i.addAssetTypeFieldValues=Es,i.addAssetTypeFieldValuesAttachment=Em,i.addAssetTypeFieldValuesAttachments=et,i.addAssetTypeFieldValuesMany=Cc,i.addAssetTypeFields=Tc,i.addAssetTypeFieldsAttachment=pm,i.addAssetTypeFieldsAttachments=mc,i.addAssetTypeFieldsMany=_m,i.addAssetTypes=Gm,i.addAssets=cs,i.addCategory=$s,i.addConversation=Un,i.addDocumentAttachment=ef,i.addDocumentAttachments=xc,i.addDocuments=lr,i.addEmailDomain=Ar,i.addForm=xs,i.addFormRevision=Xs,i.addFormRevisionAttachment=uf,i.addFormRevisionAttachments=vr,i.addFormRevisions=Dr,i.addFormSubmission=ni,i.addFormSubmissionAttachment=If,i.addFormSubmissionAttachments=at,i.addFormSubmissions=dt,i.addForms=Tf,i.addGeoImage=dd,i.addGeoImages=od,i.addIssue=vi,i.addIssueAssociation=mi,i.addIssueAssociations=fi,i.addIssueAttachment=zf,i.addIssueAttachments=gi,i.addIssueComment=Ri,i.addIssueCommentAttachment=$f,i.addIssueCommentAttachments=Md,i.addIssueComments=Nf,i.addIssueType=Vo,i.addIssueTypeAttachment=Yf,i.addIssueTypeAttachments=eo,i.addIssueTypeFieldValues=Ci,i.addIssueTypeFieldValuesAttachment=bp,i.addIssueTypeFieldValuesAttachments=ht,i.addIssueTypeFieldValuesMany=ap,i.addIssueTypeFields=Io,i.addIssueTypeFieldsAttachment=Zf,i.addIssueTypeFieldsAttachments=ho,i.addIssueTypeFieldsMany=up,i.addIssueUpdate=Ho,i.addIssueUpdates=Wo,i.addIssues=Jd,i.addLicenses=Ep,i.addProjectAttachment=tA,i.addProjectAttachments=Gl,i.addProjectFile=aA,i.addProjectFiles=eu,i.addTeam=hu,i.addUsers=Dp,i.agentsReducer=Gn,i.agentsSlice=jt,i.areArraysEqual=Ju,i.assetAttachmentReducer=Qn,i.assetAttachmentSlice=Mt,i.assetProcedureFieldValuesAttachmentReducer=ga,i.assetProcedureFieldValuesAttachmentSlice=$t,i.assetProcedureFieldValuesReducer=Pa,i.assetProcedureFieldValuesSlice=Gt,i.assetProcedureFieldsAttachmentReducer=aa,i.assetProcedureFieldsAttachmentSlice=zt,i.assetProcedureFieldsReducer=ha,i.assetProcedureFieldsSlice=Vt,i.assetProcedureInstanceReducer=qa,i.assetProcedureInstanceSlice=Kt,i.assetProcedureReducer=Da,i.assetProcedureSlice=xt,i.assetReducer=Ba,i.assetSlice=ns,i.assetStageCompletionReducer=Wa,i.assetStageCompletionSlice=us,i.assetStageReducer=Za,i.assetStageSlice=ys,i.assetTypeAttachmentReducer=lc,i.assetTypeAttachmentSlice=_s,i.assetTypeFieldValuesAttachmentReducer=qc,i.assetTypeFieldValuesAttachmentSlice=Os,i.assetTypeFieldValuesReducer=Uc,i.assetTypeFieldValuesSlice=ws,i.assetTypeFieldsAttachmentReducer=Sc,i.assetTypeFieldsAttachmentSlice=Rs,i.assetTypeFieldsReducer=Rc,i.assetTypeFieldsSlice=Ps,i.assetTypeReducer=Gc,i.assetTypeSlice=ks,i.authReducer=Hc,i.authSlice=st,i.blobToBase64=nh,i.categoryReducer=Xc,i.categorySlice=Us,i.clearTokens=Ym,i.constructUploadedFilePayloads=ih,i.coordinatesAreEqual=Ku,i.createModelAdapter=I,i.createMultiPointGeometry=Wu,i.createOfflineAction=kl,i.createPayload=v,i.createPointGeometry=Hu,i.deleteAsset=rs,i.deleteAssetAttachment=Wn,i.deleteAssetAttachments=Dt,i.deleteAssetProcedure=ts,i.deleteAssetProcedureFieldValues=Nt,i.deleteAssetProcedureFieldValuesAttachment=zh,i.deleteAssetProcedureFieldValuesAttachments=Xe,i.deleteAssetProcedureFieldValuesMany=Ia,i.deleteAssetProcedureFields=la,i.deleteAssetProcedureFieldsAttachment=_h,i.deleteAssetProcedureFieldsAttachments=sa,i.deleteAssetProcedureFieldsMany=wh,i.deleteAssetProcedureInstance=Jt,i.deleteAssetProcedureInstances=Ea,i.deleteAssetProcedures=Xh,i.deleteAssetStage=om,i.deleteAssetStageCompletion=fs,i.deleteAssetStageCompletions=ps,i.deleteAssetStages=bs,i.deleteAssetType=Ds,i.deleteAssetTypeAttachment=ac,i.deleteAssetTypeAttachments=Is,i.deleteAssetTypeFieldValues=js,i.deleteAssetTypeFieldValuesAttachment=km,i.deleteAssetTypeFieldValuesAttachments=tt,i.deleteAssetTypeFieldValuesMany=zc,i.deleteAssetTypeFields=Fc,i.deleteAssetTypeFieldsAttachment=gm,i.deleteAssetTypeFieldsAttachments=pc,i.deleteAssetTypeFieldsMany=Pm,i.deleteAssetTypes=Nm,i.deleteAssets=Ua,i.deleteCategory=Jc,i.deleteDocumentAttachment=sr,i.deleteDocumentAttachments=ir,i.deleteEmailDomain=yr,i.deleteForm=ei,i.deleteFormRevision=Qs,i.deleteFormRevisionAttachment=pf,i.deleteFormRevisionAttachments=Er,i.deleteFormRevisions=zr,i.deleteFormSubmission=ai,i.deleteFormSubmissionAttachment=vf,i.deleteFormSubmissionAttachments=ct,i.deleteFormSubmissions=ot,i.deleteGeoImage=li,i.deleteGeoImages=ud,i.deleteIssue=wi,i.deleteIssueAssociation=pi,i.deleteIssueAssociations=Ai,i.deleteIssueAttachment=Pd,i.deleteIssueAttachments=bi,i.deleteIssueComment=Pi,i.deleteIssueCommentAttachment=Dd,i.deleteIssueCommentAttachments=zd,i.deleteIssueComments=Hf,i.deleteIssueTypeAttachment=io,i.deleteIssueTypeAttachments=no,i.deleteIssueTypeFieldValues=Di,i.deleteIssueTypeFieldValuesAttachment=Ip,i.deleteIssueTypeFieldValuesAttachments=mt,i.deleteIssueTypeFieldValuesMany=op,i.deleteIssueTypeFields=Po,i.deleteIssueTypeFieldsAttachment=sp,i.deleteIssueTypeFieldsAttachments=fo,i.deleteIssueTypeFieldsMany=pp,i.deleteIssueUpdate=Ko,i.deleteIssueUpdates=Yo,i.deleteIssues=Xd,i.deleteOrganizationAccess=ol,i.deleteProject=_l,i.deleteProjectAccess=fl,i.deleteProjectAccesses=pl,i.deleteProjectAttachment=Wl,i.deleteProjectAttachments=an,i.deleteProjectFile=tu,i.deleteProjectFiles=su,i.deleteTeam=un,i.dequeue=wu,i.discard=yn,i.documentAttachmentReducer=rr,i.documentAttachmentSlice=Ls,i.documentSlice=Ns,i.documentsReducer=fr,i.downloadFile=ah,i.downloadInMemoryFile=sh,i.emailDomainsReducer=br,i.emailDomainsSlice=Ws,i.emailRegex=hh,i.enqueue=vu,i.enqueueRequest=Dl,i.fallbackToEmptyArray=g,i.fallbackToEmptyObject=Fe,i.fileReducer=Rr,i.fileSlice=Ks,i.fileToBlob=qn,i.formReducer=Lr,i.formRevisionAttachmentReducer=qr,i.formRevisionAttachmentSlice=Ys,i.formRevisionReducer=$r,i.formRevisionsSlice=Js,i.formSlice=Zs,i.formSubmissionAttachmentReducer=Qr,i.formSubmissionAttachmentSlice=ti,i.formSubmissionReducer=nd,i.formSubmissionSlice=ii,i.geoImageReducer=fd,i.geoImageSlice=oi,i.getFileIdentifier=th,i.getFileS3Key=Et,i.getLocalDateString=En,i.getLocalRelativeDateString=xu,i.getOutboxCoordinator=ge,i.getRenamedFile=jn,i.hashFile=Ie,i.initSDK=BA,i.initializeAssetAttachments=kt,i.initializeAssetProcedureFieldValues=Ta,i.initializeAssetProcedureFieldValuesAttachments=fa,i.initializeAssetProcedureFields=ra,i.initializeAssetProcedureFieldsAttachments=xn,i.initializeAssetProcedureInstances=va,i.initializeAssetProcedures=ka,i.initializeAssetStageCompletions=La,i.initializeAssetStages=Xa,i.initializeAssetTypeAttachments=sc,i.initializeAssetTypeFieldValues=kc,i.initializeAssetTypeFieldValuesAttachments=Oc,i.initializeAssetTypeFields=bc,i.initializeAssetTypeFieldsAttachments=hc,i.initializeAssetTypes=Bc,i.initializeAssets=Va,i.initializeCategories=Kc,i.initializeConversations=Vn,i.initializeDocumentAttachments=Zc,i.initializeEmailDomains=pr,i.initializeFormRevisionAttachments=Or,i.initializeFormRevisions=Cr,i.initializeFormSubmissionAttachments=Kr,i.initializeFormSubmissions=xr,i.initializeForms=Gr,i.initializeGeoImages=cd,i.initializeIssueAssociations=Ad,i.initializeIssueAttachments=Si,i.initializeIssueCommentAttachments=_i,i.initializeIssueTypeAttachments=qi,i.initializeIssueTypeFieldValues=go,i.initializeIssueTypeFieldValuesAttachments=Eo,i.initializeIssueTypeFields=Fo,i.initializeIssueTypeFieldsAttachments=uo,i.initializeIssueTypes=zo,i.initializeIssueUpdates=No,i.initializeIssues=Yd,i.initializeLicences=xo,i.initializeOrganizationAccesses=rl,i.initializeProjectAccesses=Zi,i.initializeProjectAttachments=Bl,i.initializeProjectFiles=xl,i.initializeTeams=uu,i.isToday=Zu,i.issueAssociationReducer=_d,i.issueAssociationSlice=hi,i.issueAttachmentReducer=jd,i.issueAttachmentSlice=yi,i.issueCommentAttachmentReducer=Bd,i.issueCommentAttachmentSlice=Ti,i.issueCommentReducer=Wd,i.issueCommentSlice=Fi,i.issueReducer=Zd,i.issueSlice=Oi,i.issueTypeAttachmentReducer=oo,i.issueTypeAttachmentSlice=ji,i.issueTypeFieldValuesAttachmentReducer=Co,i.issueTypeFieldValuesAttachmentSlice=$i,i.issueTypeFieldValuesReducer=To,i.issueTypeFieldValuesSlice=ki,i.issueTypeFieldsAttachmentReducer=yo,i.issueTypeFieldsAttachmentSlice=Mi,i.issueTypeFieldsReducer=vo,i.issueTypeFieldsSlice=Ui,i.issueTypeReducer=Go,i.issueTypeSlice=Gi,i.issueUpdateReducer=Qo,i.issueUpdateSlice=Wi,i.licenseReducer=tl,i.licenseSlice=Ki,i.logOnlyOnce=ch,i.markAsDeleted=zl,i.markForDeletion=eA,i.memoize=vt,i.moveDocument=ur,i.offline=F,i.onlyUniqueHashes=uh,i.onlyUniqueOfflineIds=Dn,i.organizationAccessReducer=ul,i.organizationAccessSlice=Ji,i.organizationReducer=Ml,i.organizationSlice=tn,i.outboxReducer=Ul,i.outboxSlice=sn,i.overmapEnhancer=wA,i.overmapReducers=Ru,i.overmapRootReducer=IA,i.performRequest=An,i.projectAccessReducer=Sl,i.projectAccessSlice=Qi,i.projectAttachmentReducer=Ql,i.projectAttachmentSlice=nn,i.projectFileReducer=du,i.projectFileSlice=cn,i.projectReducer=Il,i.projectSlice=en,i.rehydratedReducer=ou,i.rehydratedSlice=dn,i.removeDocuments=Hs,i.removeIssueType=Li,i.removeUser=nl,i.resetProjectFileObjectUrls=rA,i.resetStore=Ou,i.restructureCreateSelectorWithArgs=S,i.saveActiveProjectFileBounds=au,i.selectAccessToken=Jm,i.selectActiveOrganizationAccess=$p,i.selectActiveProjectFileId=oA,i.selectActiveStatusLicenses=qp,i.selectAllDocumentAttachments=ar,i.selectAllProjectAttachments=Yl,i.selectAncestorIdsOfDocument=cf,i.selectAssetAttachmentById=Jn,i.selectAssetAttachmentMapping=Kn,i.selectAssetAttachments=Yn,i.selectAssetById=ls,i.selectAssetProcedureById=is,i.selectAssetProcedureFieldValues=Ht,i.selectAssetProcedureFieldValuesAttachmentById=Vh,i.selectAssetProcedureFieldValuesAttachments=Aa,i.selectAssetProcedureFieldValuesAttachmentsByIds=ya,i.selectAssetProcedureFieldValuesAttachmentsMapping=Bt,i.selectAssetProcedureFieldValuesById=Wt,i.selectAssetProcedureFieldValuesMapping=Ra,i.selectAssetProcedureFieldValuesOfAsset=Bh,i.selectAssetProcedureFields=Ut,i.selectAssetProcedureFieldsAttachmentById=Ih,i.selectAssetProcedureFieldsAttachments=na,i.selectAssetProcedureFieldsAttachmentsMapping=ia,i.selectAssetProcedureFieldsById=qh,i.selectAssetProcedureFieldsMapping=ua,i.selectAssetProcedureFieldsOfAssetProcedure=Eh,i.selectAssetProcedureInstanceById=Zt,i.selectAssetProcedureInstances=Qt,i.selectAssetProcedureInstancesByIds=Kh,i.selectAssetProcedureInstancesMapping=Xt,i.selectAssetProcedureInstancesOfAssetProcedure=ja,i.selectAssetProcedureInstancesOfAssetType=Wh,i.selectAssetProcedures=Ca,i.selectAssetProceduresByIds=em,i.selectAssetProceduresMapping=ss,i.selectAssetProceduresOfOrganization=xh,i.selectAssetStageById=xa,i.selectAssetStageCompletionById=Ka,i.selectAssetStageCompletionMapping=As,i.selectAssetStageCompletions=cm,i.selectAssetStageCompletionsByIds=Ya,i.selectAssetStages=ec,i.selectAssetStagesByIds=Ts,i.selectAssetStagesMappingOfAssetProcedure=lm,i.selectAssetStagesOfAssetProcedure=um,i.selectAssetTypeAttachmentById=dc,i.selectAssetTypeAttachmentMapping=cc,i.selectAssetTypeAttachments=rc,i.selectAssetTypeById=Vs,i.selectAssetTypeFieldValues=qs,i.selectAssetTypeFieldValuesAttachmentById=Cm,i.selectAssetTypeFieldValuesAttachments=wc,i.selectAssetTypeFieldValuesAttachmentsByIds=Ec,i.selectAssetTypeFieldValuesAttachmentsMapping=vs,i.selectAssetTypeFieldValuesById=Ms,i.selectAssetTypeFieldValuesMapping=Vc,i.selectAssetTypeFieldValuesOfAsset=Vm,i.selectAssetTypeFields=xe,i.selectAssetTypeFieldsAttachmentById=Tm,i.selectAssetTypeFieldsAttachments=yc,i.selectAssetTypeFieldsAttachmentsMapping=Ac,i.selectAssetTypeFieldsById=wm,i.selectAssetTypeFieldsMapping=Ic,i.selectAssetTypeFieldsOfAssetType=Om,i.selectAssetTypeValuesOfAssetType=Um,i.selectAssetTypes=Hm,i.selectAssetTypesByIds=Wm,i.selectAssetTypesMapping=zs,i.selectAssets=$a,i.selectAssetsByIds=nm,i.selectAssetsMapping=ds,i.selectAssetsOfAssetType=os,i.selectAttachmentsOfAsset=Xn,i.selectAttachmentsOfAssetProcedureFieldValues=Sa,i.selectAttachmentsOfAssetProcedureFields=Fh,i.selectAttachmentsOfAssetType=oc,i.selectAttachmentsOfAssetTypeFieldValues=jc,i.selectAttachmentsOfAssetTypeFields=bm,i.selectAttachmentsOfDocument=nf,i.selectAttachmentsOfFormRevision=Af,i.selectAttachmentsOfFormSubmission=Xr,i.selectAttachmentsOfIssue=wd,i.selectAttachmentsOfIssueComment=Lf,i.selectAttachmentsOfIssueType=Qf,i.selectAttachmentsOfIssueTypeFieldValues=ko,i.selectAttachmentsOfIssueTypeFields=ip,i.selectAttachmentsOfProject=Xl,i.selectCategories=Qm,i.selectCategoriesByIds=Zm,i.selectCategoryById=Gs,i.selectCategoryMapping=Bs,i.selectCommentsOfIssue=Wf,i.selectConversation=fh,i.selectConversationMapping=qt,i.selectConversations=mh,i.selectCurrentUser=At,i.selectDeletedRequests=Zp,i.selectDocumentAttachmentById=cr,i.selectDocumentAttachmentMapping=nr,i.selectDocumentById=mr,i.selectDocuments=hr,i.selectDocumentsByIds=af,i.selectDocumentsMapping=Re,i.selectEmailDomains=gr,i.selectEmailDomainsAsMapping=Sr,i.selectEmailDomainsOfOrganization=of,i.selectFieldValuesOfAssetProcedureInstance=Gh,i.selectFormById=Hr,i.selectFormMapping=Nr,i.selectFormRevisionAttachmentsMapping=jr,i.selectFormRevisionById=Sf,i.selectFormRevisionMapping=nt,i.selectFormRevisions=Vr,i.selectFormRevisionsOfForm=Ur,i.selectFormSubmissionAttachemntsByIds=Jr,i.selectFormSubmissionAttachmentsMapping=si,i.selectFormSubmissionById=di,i.selectFormSubmissions=ri,i.selectFormSubmissionsMapping=ci,i.selectFormSubmissionsOfAsset=id,i.selectFormSubmissionsOfForm=td,i.selectFormSubmissionsOfIssue=sd,i.selectForms=Ff,i.selectGeoImageById=ui,i.selectGeoImageMapping=hd,i.selectGeoImages=md,i.selectGeoImagesOfProject=qf,i.selectIsImportingProjectFile=lA,i.selectIsLoggedIn=Xm,i.selectIssueAssociationById=Sd,i.selectIssueAssociationMapping=Ge,i.selectIssueAssociations=Df,i.selectIssueAssociationsOfAsset=Td,i.selectIssueAssociationsOfIssue=bd,i.selectIssueAssociationsToIssue=gd,i.selectIssueAttachmentById=Ed,i.selectIssueAttachmentMapping=Od,i.selectIssueAttachments=vd,i.selectIssueById=Ei,i.selectIssueCommentAttachmentById=$d,i.selectIssueCommentAttachmentMapping=Vd,i.selectIssueCommentAttachments=Ud,i.selectIssueCommentById=Hd,i.selectIssueCommentMapping=Nd,i.selectIssueCountOfCategory=xm,i.selectIssueMapping=Qd,i.selectIssueTypeAttachmentById=ro,i.selectIssueTypeAttachmentMapping=ao,i.selectIssueTypeAttachments=co,i.selectIssueTypeById=Ni,i.selectIssueTypeFieldValues=zi,i.selectIssueTypeFieldValuesAttachmentById=Rp,i.selectIssueTypeFieldValuesAttachments=qo,i.selectIssueTypeFieldValuesAttachmentsByIds=Mo,i.selectIssueTypeFieldValuesAttachmentsMapping=Bi,i.selectIssueTypeFieldValuesById=Vi,i.selectIssueTypeFieldValuesMapping=bo,i.selectIssueTypeFieldValuesOfIssue=lp,i.selectIssueTypeFields=ut,i.selectIssueTypeFieldsAttachmentById=np,i.selectIssueTypeFieldsAttachments=Ao,i.selectIssueTypeFieldsAttachmentsMapping=po,i.selectIssueTypeFieldsById=gp,i.selectIssueTypeFieldsMapping=Oo,i.selectIssueTypeFieldsOfIssueType=Ap,i.selectIssueTypeMapping=$o,i.selectIssueTypeValuesOfIssueType=Sp,i.selectIssueTypes=Bo,i.selectIssueTypesByIds=Pp,i.selectIssueTypesOfOrganization=Op,i.selectIssueUpdateMapping=Jo,i.selectIssueUpdatesOfIssue=Xo,i.selectIssuesByIds=Kf,i.selectIssuesOfIssueType=Hi,i.selectIssuesOfIssueTypeCount=vp,i.selectLatestAssetProcedureFieldsOfAssetProcedure=jh,i.selectLatestAssetTypeFieldsOfAssetType=vm,i.selectLatestFormRevisionOfForm=gf,i.selectLatestIssueTypeFieldsOfIssueType=yp,i.selectLatestRetryTime=xp,i.selectLicense=jp,i.selectLicenseForProject=el,i.selectLicenses=pt,i.selectLicensesForProjectsMapping=Mp,i.selectLicensesOfOrganization=Xp,i.selectNumberOfAssetsOfAssetType=am,i.selectOrganizationAccessById=Up,i.selectOrganizationAccessForUser=Bp,i.selectOrganizationAccessUserMapping=ll,i.selectOrganizationAccesses=Xi,i.selectOrganizationById=Kp,i.selectOrganizationUsersAsMapping=ql,i.selectOrganizationUsersIds=jl,i.selectOrganizations=El,i.selectOrganizationsMapping=wl,i.selectOrganizationsWithAccess=Yp,i.selectProjectAccessById=Gp,i.selectProjectAccessForUser=Lp,i.selectProjectAccessMapping=xi,i.selectProjectAccessUserMapping=yl,i.selectProjectAccesses=Al,i.selectProjectAttachmentById=Jl,i.selectProjectAttachmentMapping=Kl,i.selectProjectById=Hp,i.selectProjectFileById=dA,i.selectProjectFileMapping=cu,i.selectProjectFiles=ru,i.selectProjectMapping=gt,i.selectProjectUsersAsMapping=Pl,i.selectProjectUsersIds=Rl,i.selectProjects=Np,i.selectProjectsOfOrganization=Jp,i.selectRehydrated=mA,i.selectRootDocuments=rf,i.selectSortedOrganizationUsers=Qp,i.selectSortedProjectUsers=Wp,i.selectStageMapping=Ze,i.selectTeamById=we,i.selectTeams=mn,i.selectTeamsByIds=fA,i.selectTeamsMapping=hn,i.selectTeamsOfOrganization=pA,i.selectTeamsOfUser=AA,i.selectUploadUrl=Ir,i.selectUserById=zp,i.selectUsersByIds=Vp,i.selectUsersMapping=yt,i.separateFilesFromValues=qe,i.separateImageFromFields=Ay,i.setActiveProjectFileId=nu,i.setAsset=sm,i.setAssetAttachment=Nn,i.setAssetAttachments=Ah,i.setAssetProcedure=Qh,i.setAssetProcedureFieldValues=Uh,i.setAssetProcedureFieldValuesAttachment=kh,i.setAssetProcedureFieldValuesAttachments=Ch,i.setAssetProcedureFieldValuesMany=$h,i.setAssetProcedureFields=Ph,i.setAssetProcedureFieldsAttachment=gh,i.setAssetProcedureFieldsAttachments=bh,i.setAssetProcedureFieldsMany=Oh,i.setAssetProcedureInstance=Nh,i.setAssetProcedureInstances=Hh,i.setAssetProcedures=Zh,i.setAssetStage=Qa,i.setAssetStages=rm,i.setAssetType=$m,i.setAssetTypeAttachment=ic,i.setAssetTypeAttachments=mm,i.setAssetTypeFieldValues=Dm,i.setAssetTypeFieldValuesAttachment=jm,i.setAssetTypeFieldValuesAttachments=qm,i.setAssetTypeFieldValuesMany=zm,i.setAssetTypeFields=Fm,i.setAssetTypeFieldsAttachment=Am,i.setAssetTypeFieldsAttachments=ym,i.setAssetTypeFieldsMany=Im,i.setAssetTypes=Bm,i.setAssets=im,i.setConversation=$n,i.setCurrentUser=kp,i.setDocumentAttachment=er,i.setDocumentAttachments=tf,i.setDocuments=or,i.setForm=bf,i.setFormRevision=kr,i.setFormRevisionAttachment=hf,i.setFormRevisionAttachments=mf,i.setFormSubmission=rt,i.setFormSubmissionAttachment=Rf,i.setFormSubmissionAttachments=Pf,i.setFormSubmissions=wf,i.setGeoImage=Be,i.setGeoImages=rd,i.setIsImportingProjectFile=iu,i.setIssueAssociation=kf,i.setIssueAssociations=Mf,i.setIssueAttachment=Id,i.setIssueAttachments=Vf,i.setIssueComment=Ii,i.setIssueCommentAttachment=kd,i.setIssueCommentAttachments=Bf,i.setIssueComments=Ld,i.setIssueType=Ne,i.setIssueTypeAttachment=to,i.setIssueTypeAttachments=Jf,i.setIssueTypeFieldValues=cp,i.setIssueTypeFieldValuesAttachment=Tp,i.setIssueTypeFieldValuesAttachments=_p,i.setIssueTypeFieldValuesMany=rp,i.setIssueTypeFields=hp,i.setIssueTypeFieldsAttachment=xf,i.setIssueTypeFieldsAttachments=ep,i.setIssueTypeFieldsMany=mp,i.setIssueUpdate=wp,i.setLoggedIn=Nc,i.setOrganizations=vl,i.setProfilePicture=Cp,i.setProjectAttachment=Ll,i.setProjectAttachments=Nl,i.setProjectFile=iA,i.setProjectFiles=nA,i.setProjects=bl,i.setRehydrated=hA,i.setTeam=ve,i.setTokens=Km,i.setUploadUrl=Fr,i.setUsers=il,i.shallowEqual=Yu,i.slugify=oh,i.spacesToDashesLower=dh,i.teamReducer=mu,i.teamSlice=on,i.toFileNameSafeString=rh,i.toOfflineIdRecord=Cn,i.truncate=lh,i.updateAsset=ze,i.updateAssetAttachment=yh,i.updateAssetAttachments=Hn,i.updateAssetProcedure=De,i.updateAssetProcedureFieldValues=ke,i.updateAssetProcedureFieldValuesAttachment=Dh,i.updateAssetProcedureFieldValuesAttachments=pa,i.updateAssetProcedureFieldValuesMany=Fa,i.updateAssetProcedureFields=oa,i.updateAssetProcedureFieldsAttachment=Th,i.updateAssetProcedureFieldsAttachments=ta,i.updateAssetProcedureFieldsMany=vh,i.updateAssetProcedureInstance=Ce,i.updateAssetProcedureInstances=Lh,i.updateAssetProcedures=Jh,i.updateAssetStage=gs,i.updateAssetStageCompletion=Na,i.updateAssetStageCompletions=Ha,i.updateAssetStages=Qe,i.updateAssetType=Ue,i.updateAssetTypeAttachment=fm,i.updateAssetTypeAttachments=nc,i.updateAssetTypeFieldValues=Ve,i.updateAssetTypeFieldValuesAttachment=Mm,i.updateAssetTypeFieldValuesAttachments=vc,i.updateAssetTypeFieldValuesMany=Dc,i.updateAssetTypeFields=_c,i.updateAssetTypeFieldsAttachment=Sm,i.updateAssetTypeFieldsAttachments=fc,i.updateAssetTypeFieldsMany=Rm,i.updateAssetTypes=Lm,i.updateAssets=tm,i.updateCategory=Yc,i.updateConversation=Bn,i.updateDocumentAttachment=sf,i.updateDocumentAttachments=tr,i.updateDocuments=me,i.updateForm=_f,i.updateFormRevisionAttachment=ff,i.updateFormRevisionAttachments=wr,i.updateFormSubmission=ed,i.updateFormSubmissionAttachment=Of,i.updateFormSubmissionAttachments=Yr,i.updateFormSubmissions=Ef,i.updateGeoImage=ld,i.updateGeoImages=jf,i.updateIssue=lt,i.updateIssueAssociation=yd,i.updateIssueAssociations=Cf,i.updateIssueAttachment=Uf,i.updateIssueAttachments=Rd,i.updateIssueCommentAttachment=Gf,i.updateIssueCommentAttachments=Cd,i.updateIssueType=Uo,i.updateIssueTypeAttachment=Xf,i.updateIssueTypeAttachments=so,i.updateIssueTypeFieldValues=Le,i.updateIssueTypeFieldValuesAttachment=Fp,i.updateIssueTypeFieldValuesAttachments=jo,i.updateIssueTypeFieldValuesMany=dp,i.updateIssueTypeFields=Ro,i.updateIssueTypeFieldsAttachment=tp,i.updateIssueTypeFieldsAttachments=mo,i.updateIssueTypeFieldsMany=fp,i.updateLicense=ue,i.updateOrganizationAccess=dl,i.updateProject=Tl,i.updateProjectAccess=ml,i.updateProjectAttachment=sA,i.updateProjectAttachments=Hl,i.updateProjectFile=rn,i.updateProjectFiles=cA,i.updateTeam=ln,i.userReducer=al,i.userSlice=Yi,i.versioningReducer=pu,i.versioningSlice=fu,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});