@overmap-ai/core 1.0.75-more-clean-ups.0 → 1.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/overmap-core.js +2486 -2378
- package/dist/overmap-core.umd.cjs +7 -7
- package/dist/sdk/services/BaseAttachmentService.d.ts +3 -3
- package/dist/sdk/services/IssueAttachmentService.d.ts +1 -0
- package/dist/sdk/services/IssueCommentAttachmentService.d.ts +40 -0
- package/dist/sdk/services/IssueTypeAttachmentService.d.ts +40 -0
- package/dist/sdk/services/ProjectAttachmentService.d.ts +1 -1
- package/dist/sdk/services/index.d.ts +2 -0
- package/dist/store/slices/assetAttachmentSlice.d.ts +0 -4
- package/dist/store/slices/assetSlice.d.ts +2 -2
- package/dist/store/slices/assetStageCompletionSlice.d.ts +19 -19
- package/dist/store/slices/assetStageSlice.d.ts +9 -9
- package/dist/store/slices/assetTypeAttachmentSlice.d.ts +0 -4
- package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +1 -1
- package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +2 -2
- package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +2 -2
- package/dist/store/slices/assetTypeFieldsSlice.d.ts +3 -3
- package/dist/store/slices/assetTypeSlice.d.ts +2 -2
- package/dist/store/slices/documentAttachmentSlice.d.ts +0 -4
- package/dist/store/slices/emailDomainsSlice.d.ts +10 -10
- package/dist/store/slices/formRevisionSlice.d.ts +0 -1
- package/dist/store/slices/formSlice.d.ts +0 -1
- package/dist/store/slices/geoImageSlice.d.ts +17 -17
- package/dist/store/slices/index.d.ts +2 -0
- package/dist/store/slices/issueAttachmentSlice.d.ts +0 -4
- package/dist/store/slices/issueCommentAttachmentSlice.d.ts +42 -0
- package/dist/store/slices/issueTypeAttachmentSlice.d.ts +42 -0
- package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +2 -2
- package/dist/store/slices/issueTypeFieldsSlice.d.ts +1 -1
- package/dist/store/slices/licenseSlice.d.ts +9 -9
- package/dist/store/slices/organizationAccessSlice.d.ts +9 -9
- package/dist/store/slices/projectAccessSlice.d.ts +9 -9
- package/dist/store/slices/projectAttachmentSlice.d.ts +0 -4
- package/dist/store/store.d.ts +3 -1
- package/dist/typings/models/assets.d.ts +2 -3
- package/dist/typings/models/attachments.d.ts +6 -0
- package/dist/typings/models/base.d.ts +7 -6
- package/dist/typings/models/fields.d.ts +1 -1
- package/dist/typings/models/forms.d.ts +4 -4
- package/dist/typings/models/geoImages.d.ts +3 -3
- package/dist/typings/models/issues.d.ts +22 -34
- package/dist/typings/models/store.d.ts +3 -1
- package/dist/utils/offline.d.ts +1 -0
- package/dist/utils/utils.d.ts +1 -0
- 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,u,Yd,Kd,Ui,Jd,Xd,me,Zd,Qd,xd,el){"use strict";var dp=Object.defineProperty;var lp=(i,O,u)=>O in i?dp(i,O,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[O]=u;var A=(i,O,u)=>lp(i,typeof O!="symbol"?O+"":O,u);var Hd;const Vi=Object.freeze([]),$i=Object.freeze({});var rt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(rt||{}),dt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(dt||{}),l=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(l||{}),Bi=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(Bi||{}),lt=(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))(lt||{}),ut=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(ut||{}),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||{}),Gi=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Gi||{}),Li=(t=>(t[t.PRO=0]="PRO",t))(Li||{}),Ni=(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))(Ni||{});const tl=ut.BACKLOG,sl=lt.MEDIUM,Hi=6e4;function I(t){return{addOne:(f,p)=>{const y=t(p.payload);f.instances[y]=p.payload},addMany:(f,p)=>{for(const y of p.payload){const T=t(y);f.instances[T]=y}},setOne:(f,p)=>{const y=t(p.payload);f.instances[y]=p.payload},setMany:(f,p)=>{for(const y of p.payload){const T=t(y);f.instances[T]=y}},updateOne:(f,p)=>{const y=t(p.payload);f.instances[y]=p.payload},updateMany:(f,p)=>{for(const y of p.payload){const T=t(y);f.instances[T]=y}},deleteOne:(f,p)=>{delete f.instances[p.payload]},deleteMany:(f,p)=>{for(const y of p.payload)delete f.instances[y]},initialize:(f,p)=>{f.instances={};for(const y of p.payload){const T=t(y);f.instances[T]=y}},getInitialState:f=>({...f,instances:{}})}}Hd=Symbol.toStringTag;class Wi{constructor(){A(this,Hd,"Promise");A(this,"_promise");A(this,"_resolve");A(this,"_reject");A(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 il=t=>({type:"Point",coordinates:t}),nl=t=>({type:"MultiPoint",coordinates:t}),al=(t,e)=>t[0]===e[0]&&t[1]===e[1];let ht=!1;["true","1"].includes("".toLowerCase())&&(ht=!0);function Yi(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 o=s[c];if(!Object.prototype.hasOwnProperty.call(e,o)||t[o]!==e[o])return!1}return!0}function mt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(ht&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(ht&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function cl(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?Vi:t,ae=t=>Object.keys(t).length===0?$i:t,Ki=mt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===ft.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),ol=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),rl=1e3*86400,ft=new Date,dl=t=>new Date(t).toDateString()===ft.toDateString(),ll=mt((t,e,s)=>{const n=Math.round((new Date(t).getTime()-ft.getTime())/rl);return n<e||n>s?Ki(t):ol.format(n,"days")});function ul(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const pt=async(t,e)=>{e||(e=await fe(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 fe(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 o=ul(c);e(o)})},n.readAsArrayBuffer(t)})}function hl(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 Ji(t,e){return new File([t],e,{type:t.type})}function ml(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 fl=async t=>{const e={};for(const s of t){const n=await fe(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},Xi=async t=>(await fetch(t)).blob(),pl=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 yl(t){const e=new Blob([t]);Yd.saveAs(e,t.name)}const Zi={};function Al(t,e,s,...n){const a=Zi[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(Zi[t]={[e]:!0},c=!0),c&&console[s](...n)}function R(t){return{...t,offline_id:O.v4()}}function Qi(t){const e={};for(const s of t)e[s.offline_id]=s;return e}function gl(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 Sl(t){return t.toLowerCase().replace(" ","-")}function Tl(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function bl(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const g=t=>e=>s=>t(s,e);function xi(t,e,s){return s.findIndex(n=>n.offline_id===t.offline_id)===e}function _l(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const Il=/^.+@.+\..+$/,_e=I(t=>t.offline_id),en=_e.getInitialState({}),yt=u.createSlice({name:"agents",initialState:en,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,en)),reducers:{initializeConversations:_e.initialize,addConversation:_e.addOne,setConversation:_e.setOne,updateConversation:_e.updateOne}}),{initializeConversations:tn,addConversation:sn,setConversation:nn,updateConversation:an}=yt.actions,At=t=>t.agentsReducer.instances,Rl=u.createSelector([At],t=>Object.values(t)),Fl=g(u.createSelector([At,(t,e)=>e],(t,e)=>t[e])),cn=yt.reducer,q=I(t=>t.offline_id),on=q.getInitialState({}),gt=u.createSlice({name:"assetAttachments",initialState:on,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,on)),reducers:{initializeAssetAttachments:q.initialize,addAssetAttachment:q.addOne,addAssetAttachments:q.addMany,setAssetAttachment:q.setOne,setAssetAttachments:q.setMany,updateAssetAttachment:q.updateOne,updateAssetAttachments:q.updateMany,deleteAssetAttachment:q.deleteOne,deleteAssetAttachments:q.deleteMany}}),{initializeAssetAttachments:St,addAssetAttachment:Ol,addAssetAttachments:Tt,setAssetAttachment:rn,setAssetAttachments:vl,updateAssetAttachment:wl,updateAssetAttachments:dn,deleteAssetAttachment:ln,deleteAssetAttachments:bt}=gt.actions,un=t=>t.assetAttachmentReducer.instances,_t=u.createSelector([un],t=>Object.values(t)),hn=t=>e=>e.assetAttachmentReducer.instances[t],mn=g(u.createSelector([_t,(t,e)=>e],(t,e)=>S(t.filter(({asset:s})=>e===s)))),El=g(u.createSelector([_t,(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}})),fn=gt.reducer,k=I(t=>t.offline_id),pn=k.getInitialState({}),It=u.createSlice({name:"assets",initialState:pn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pn)),reducers:{initializeAssets:k.initialize,addAsset:k.addOne,addAssets:k.addMany,setAsset:k.setOne,setAssets:k.setMany,updateAsset:k.updateOne,updateAssets:k.updateMany,deleteAsset:k.deleteOne,deleteAssets:k.deleteMany}}),{initializeAssets:yn,addAsset:Rt,addAssets:Ft,updateAsset:Ie,updateAssets:jl,deleteAsset:Ot,deleteAssets:An,setAsset:Pl,setAssets:ql}=It.actions,vt=t=>t.assetReducer.instances,gn=u.createSelector([vt],t=>S(Object.values(t))),wt=g(u.createSelector([gn,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),Et=t=>e=>e.assetReducer.instances[t],kl=g(u.createSelector([vt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),Dl=t=>e=>wt(t)(e).length,Sn=It.reducer,ie=I(t=>t.offline_id),Tn=ie.getInitialState({}),jt=u.createSlice({name:"assetStageCompletions",initialState:Tn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Tn)),reducers:{initializeAssetStageCompletions:ie.initialize,addAssetStageCompletion:ie.addOne,addAssetStageCompletions:ie.addMany,updateAssetStageCompletion:ie.updateOne,updateAssetStageCompletions:ie.updateMany,deleteAssetStageCompletion:ie.deleteOne,deleteAssetStageCompletions:ie.deleteMany}}),{initializeAssetStageCompletions:bn,addAssetStageCompletion:Pt,addAssetStageCompletions:qt,updateAssetStageCompletion:_n,updateAssetStageCompletions:In,deleteAssetStageCompletion:kt,deleteAssetStageCompletions:Dt}=jt.actions,Ct=t=>t.assetStageCompletionReducer.instances,Cl=u.createSelector([Ct],t=>{const e={};for(const s of Object.values(t)){const{asset:n,stage:a,submitted_at:c}=s;e[n]||(e[n]={}),e[n][a]=c}return ae(e)}),Rn=t=>e=>e.assetStageCompletionReducer.instances[t],Fn=g(u.createSelector([Ct,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),On=jt.reducer,D=I(t=>t.offline_id),vn=D.getInitialState({}),Mt=u.createSlice({name:"assetStages",initialState:vn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vn)),reducers:{initializeAssetStages:D.initialize,setAssetStage:D.setOne,setAssetStages:D.setMany,addAssetStage:D.addOne,addAssetStages:D.addMany,updateAssetStage:D.updateOne,updateAssetStages:D.updateMany,deleteAssetStage:D.deleteOne,deleteAssetStages:D.deleteMany}}),{initializeAssetStages:wn,setAssetStage:En,setAssetStages:Ml,addAssetStage:zl,addAssetStages:Ce,updateAssetStage:zt,updateAssetStages:Me,deleteAssetStage:Ul,deleteAssetStages:ze}=Mt.actions,jn=Mt.reducer,Ue=t=>t.assetStageReducer.instances,Pn=t=>e=>e.assetStageReducer.instances[t],qn=u.createSelector([Ue],t=>Object.values(t)),Vl=g(u.createSelector([Ue,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_type===e&&(s[n]=a);return ae(s)})),kn=g(u.createSelector([qn,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e).sort((s,n)=>s.priority-n.priority)))),Ut=g(u.createSelector([Ue,(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)})),C=I(t=>t.offline_id),Dn=C.getInitialState({}),Vt=u.createSlice({name:"assetTypeAttachments",initialState:Dn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dn)),reducers:{initializeAssetTypeAttachments:C.initialize,addAssetTypeAttachment:C.addOne,addAssetTypeAttachments:C.addMany,setAssetTypeAttachment:C.setOne,setAssetTypeAttachments:C.setMany,updateAssetTypeAttachment:C.updateOne,updateAssetTypeAttachments:C.updateMany,deleteAssetTypeAttachment:C.deleteOne,deleteAssetTypeAttachments:C.deleteMany}}),{initializeAssetTypeAttachments:Cn,addAssetTypeAttachment:$l,addAssetTypeAttachments:$t,setAssetTypeAttachment:Mn,setAssetTypeAttachments:Bl,updateAssetTypeAttachment:Gl,updateAssetTypeAttachments:zn,deleteAssetTypeAttachment:Un,deleteAssetTypeAttachments:Bt}=Vt.actions,Vn=t=>t.assetTypeAttachmentReducer.instances,Gt=u.createSelector([Vn],t=>Object.values(t)),$n=t=>e=>e.assetTypeAttachmentReducer.instances[t],Bn=g(u.createSelector([Gt,(t,e)=>e],(t,e)=>S(t.filter(({asset_type:s})=>e===s)))),Ll=g(u.createSelector([Gt,(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}})),Gn=Vt.reducer,M=I(t=>t.offline_id),Ln=M.getInitialState({}),Lt=u.createSlice({name:"assetTypeFieldsAttachments",initialState:Ln,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ln)),reducers:{initializeAssetTypeFieldsAttachments:M.initialize,addAssetTypeFieldsAttachment:M.addOne,addAssetTypeFieldsAttachments:M.addMany,setAssetTypeFieldsAttachment:M.setOne,setAssetTypeFieldsAttachments:M.setMany,updateAssetTypeFieldsAttachment:M.updateOne,updateAssetTypeFieldsAttachments:M.updateMany,deleteAssetTypeFieldsAttachment:M.deleteOne,deleteAssetTypeFieldsAttachments:M.deleteMany}}),{initializeAssetTypeFieldsAttachments:Nn,addAssetTypeFieldsAttachment:Nl,addAssetTypeFieldsAttachments:Hn,setAssetTypeFieldsAttachment:Hl,setAssetTypeFieldsAttachments:Wl,updateAssetTypeFieldsAttachment:Yl,updateAssetTypeFieldsAttachments:Wn,deleteAssetTypeFieldsAttachment:Kl,deleteAssetTypeFieldsAttachments:Yn}=Lt.actions,Kn=t=>t.assetTypeFieldsAttachmentReducer.instances,Jn=u.createSelector([Kn],t=>Object.values(t)),Jl=g(u.createSelector([Jn,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),Xl=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Xn=Lt.reducer,z=I(t=>t.offline_id),Zn=z.getInitialState({}),Nt=u.createSlice({name:"assetTypeFields",initialState:Zn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zn)),reducers:{initializeAssetTypeFields:z.initialize,addAssetTypeFields:z.addOne,addAssetTypeFieldsMany:z.addMany,setAssetTypeFields:z.setOne,setAssetTypeFieldsMany:z.setMany,updateAssetTypeFields:z.updateOne,updateAssetTypeFieldsMany:z.updateMany,deleteAssetTypeFields:z.deleteOne,deleteAssetTypeFieldsMany:z.deleteMany}}),{initializeAssetTypeFields:Qn,addAssetTypeFields:xn,addAssetTypeFieldsMany:Zl,setAssetTypeFields:Ql,setAssetTypeFieldsMany:xl,updateAssetTypeFields:ea,updateAssetTypeFieldsMany:eu,deleteAssetTypeFields:ta,deleteAssetTypeFieldsMany:tu}=Nt.actions,sa=t=>t.assetTypeFieldsReducer.instances,Ve=u.createSelector([sa],t=>Object.values(t)),su=g(u.createSelector([Ve,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),iu=g(u.createSelector([Ve,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),nu=t=>e=>e.assetTypeFieldsReducer.instances[t],ia=Nt.reducer,U=I(t=>t.offline_id),na=U.getInitialState({}),Ht=u.createSlice({name:"assetTypeFieldValuesAttachments",initialState:na,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,na)),reducers:{initializeAssetTypeFieldValuesAttachments:U.initialize,addAssetTypeFieldValuesAttachment:U.addOne,addAssetTypeFieldValuesAttachments:U.addMany,setAssetTypeFieldValuesAttachment:U.setOne,setAssetTypeFieldValuesAttachments:U.setMany,updateAssetTypeFieldValuesAttachment:U.updateOne,updateAssetTypeFieldValuesAttachments:U.updateMany,deleteAssetTypeFieldValuesAttachment:U.deleteOne,deleteAssetTypeFieldValuesAttachments:U.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:aa,addAssetTypeFieldValuesAttachment:au,addAssetTypeFieldValuesAttachments:$e,setAssetTypeFieldValuesAttachment:cu,setAssetTypeFieldValuesAttachments:ou,updateAssetTypeFieldValuesAttachment:ru,updateAssetTypeFieldValuesAttachments:ca,deleteAssetTypeFieldValuesAttachment:du,deleteAssetTypeFieldValuesAttachments:Be}=Ht.actions,Wt=t=>t.assetTypeFieldValuesAttachmentReducer.instances,oa=u.createSelector([Wt],t=>Object.values(t)),lu=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],ra=g(u.createSelector([Wt,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),da=g(u.createSelector([oa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),la=Ht.reducer,V=I(t=>t.offline_id),ua=V.getInitialState({}),Yt=u.createSlice({name:"assetTypeFieldValues",initialState:ua,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ua)),reducers:{initializeAssetTypeFieldValues:V.initialize,addAssetTypeFieldValues:V.addOne,addAssetTypeFieldValuesMany:V.addMany,setAssetTypeFieldValues:V.setOne,setAssetTypeFieldValuesMany:V.setMany,updateAssetTypeFieldValues:V.updateOne,updateAssetTypeFieldValuesMany:V.updateMany,deleteAssetTypeFieldValues:V.deleteOne,deleteAssetTypeFieldValuesMany:V.deleteMany}}),{initializeAssetTypeFieldValues:ha,addAssetTypeFieldValues:Kt,addAssetTypeFieldValuesMany:ma,setAssetTypeFieldValues:uu,setAssetTypeFieldValuesMany:hu,updateAssetTypeFieldValues:Re,updateAssetTypeFieldValuesMany:fa,deleteAssetTypeFieldValues:Jt,deleteAssetTypeFieldValuesMany:pa}=Yt.actions,ya=t=>t.assetTypeFieldValuesReducer.instances,Xt=u.createSelector([ya],t=>Object.values(t)),mu=g(u.createSelector([Xt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),fu=g(u.createSelector([Ve,Xt,(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)))})),Zt=t=>e=>e.assetTypeFieldValuesReducer.instances[t],Aa=Yt.reducer,$=I(t=>t.offline_id),ga=$.getInitialState({}),Qt=u.createSlice({name:"assetTypes",initialState:ga,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ga)),reducers:{initializeAssetTypes:$.initialize,setAssetType:$.setOne,setAssetTypes:$.setMany,addAssetType:$.addOne,addAssetTypes:$.addMany,updateAssetType:$.updateOne,updateAssetTypes:$.updateMany,deleteAssetType:$.deleteOne,deleteAssetTypes:$.deleteMany}}),{initializeAssetTypes:Sa,setAssetType:pu,setAssetTypes:yu,addAssetType:xt,addAssetTypes:Au,updateAssetType:Fe,updateAssetTypes:gu,deleteAssetType:es,deleteAssetTypes:Su}=Qt.actions,ts=t=>t.assetTypeReducer.instances,Tu=u.createSelector([ts],t=>Object.values(t)),ss=t=>e=>e.assetTypeReducer.instances[t],bu=g(u.createSelector([ts,(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)})),Ta=Qt.reducer,ba={accessToken:"",refreshToken:"",isLoggedIn:!1},Ge=u.createSlice({name:"auth",initialState:ba,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ba)),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||Ge.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:_u,clearTokens:Iu,setLoggedIn:_a}=Ge.actions,Ru=t=>t.authReducer.accessToken,Fu=t=>t.authReducer.isLoggedIn,Ia=Ge.reducer,Oe=I(t=>t.offline_id),Ra=Oe.getInitialState({}),is=u.createSlice({name:"categories",initialState:Ra,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ra)),reducers:{initializeCategories:Oe.initialize,addCategory:Oe.addOne,updateCategory:Oe.updateOne,deleteCategory:Oe.deleteOne}}),{initializeCategories:Fa,addCategory:ns,updateCategory:Oa,deleteCategory:va}=is.actions,as=t=>t.categoryReducer.instances,Ou=u.createSelector([as],t=>Object.values(t)),cs=t=>e=>e.categoryReducer.instances[t],vu=g(u.createSelector([as,(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)})),wu=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,wa=is.reducer,B=I(t=>t.offline_id),Ea=B.getInitialState({}),os=u.createSlice({name:"documentAttachments",initialState:Ea,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ea)),reducers:{initializeDocumentAttachments:B.initialize,addDocumentAttachment:B.addOne,addDocumentAttachments:B.addMany,setDocumentAttachment:B.setOne,setDocumentAttachments:B.setMany,updateDocumentAttachment:B.updateOne,updateDocumentAttachments:B.updateMany,deleteDocumentAttachment:B.deleteOne,deleteDocumentAttachments:B.deleteMany}}),{initializeDocumentAttachments:ja,addDocumentAttachment:Eu,addDocumentAttachments:Pa,setDocumentAttachment:qa,setDocumentAttachments:ju,updateDocumentAttachment:Pu,updateDocumentAttachments:ka,deleteDocumentAttachment:Da,deleteDocumentAttachments:Ca}=os.actions,Ma=t=>t.documentAttachmentReducer.instances,rs=u.createSelector([Ma],t=>Object.values(t)),za=t=>e=>e.documentAttachmentReducer.instances[t],qu=g(u.createSelector([rs,(t,e)=>e],(t,e)=>S(t.filter(({document:s})=>e===s)))),ku=g(u.createSelector([rs,(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}})),Ua=os.reducer,Va={documents:{}},ds=u.createSlice({name:"documents",initialState:Va,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Va)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(xi).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Qi(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:o}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(o.indexOf(c.offline_id),1)}if(n){const o=t.documents[n],d=o!=null&&o.parent_document?t.documents[o.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[o.parent_document].children_documents.splice(d.children_documents.indexOf(o.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[o.parent_document].children_documents.splice(d.children_documents.indexOf(o.offline_id)+1,0,c.offline_id),t.documents[s].parent_document=d.offline_id;break;case"left-child":if(!o)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=o.offline_id;break;case"right-child":if(!o)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=o.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:$a,addDocuments:Ba,updateDocuments:ne,moveDocument:Ga,removeDocuments:ls}=ds.actions,pe=t=>t.documentsReducer.documents,La=u.createSelector([pe],t=>Object.values(t)),Na=t=>e=>e.documentsReducer.documents[t],Du=g(u.createSelector([pe,(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)})),Cu=g(u.createSelector([pe,(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)})),Mu=u.createSelector([La],t=>S(t.filter(e=>!e.parent_document))),Ha=ds.reducer,Le=I(t=>t.offline_id),zu=Le.getInitialState({}),us=u.createSlice({name:"emailDomains",initialState:zu,reducers:{initializeEmailDomains:Le.initialize,addEmailDomain:Le.addOne,deleteEmailDomain:Le.deleteOne}}),{initializeEmailDomains:Wa,addEmailDomain:Ya,deleteEmailDomain:Ka}=us.actions,Ja=t=>t.emailDomainsReducer.instances,Xa=u.createSelector([Ja],t=>Object.values(t)),Uu=g(u.createSelector([Xa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),Za=us.reducer,Qa={s3Urls:{}},xa=1e3*60*60,Vu=xa*24*7,hs=u.createSlice({name:"file",initialState:Qa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qa)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:n,sha1:a}=e.payload,c=new Date,o=new Date(c.getTime()+Vu);t.s3Urls[a]={url:s,fields:n,exp:o.getTime()}}}}),{setUploadUrl:ec}=hs.actions,tc=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<xa))return s},sc=hs.reducer,G=I(t=>t.offline_id),ic=G.getInitialState({}),ms=u.createSlice({name:"formRevisionAttachments",initialState:ic,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ic)),reducers:{initializeFormRevisionAttachments:G.initialize,addFormRevisionAttachment:G.addOne,addFormRevisionAttachments:G.addMany,setFormRevisionAttachment:G.setOne,setFormRevisionAttachments:G.setMany,updateFormRevisionAttachment:G.updateOne,updateFormRevisionAttachments:G.updateMany,deleteFormRevisionAttachment:G.deleteOne,deleteFormRevisionAttachments:G.deleteMany}}),{initializeFormRevisionAttachments:nc,addFormRevisionAttachment:$u,addFormRevisionAttachments:ac,setFormRevisionAttachment:Bu,setFormRevisionAttachments:Gu,updateFormRevisionAttachment:Lu,updateFormRevisionAttachments:cc,deleteFormRevisionAttachment:Nu,deleteFormRevisionAttachments:oc}=ms.actions,rc=t=>t.formRevisionAttachmentReducer.instances,Hu=g(u.createSelector([rc,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_revision===e)))),dc=ms.reducer,Wu=(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},ce=I(t=>t.offline_id),lc=ce.getInitialState({}),fs=u.createSlice({name:"formRevisions",initialState:lc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,lc)),reducers:{initializeFormRevisions:ce.initialize,setFormRevision:ce.setOne,addFormRevision:ce.addOne,addFormRevisions:ce.addMany,deleteFormRevision:ce.deleteOne,deleteFormRevisions:ce.deleteMany}}),{setFormRevision:uc,initializeFormRevisions:hc,addFormRevision:ps,addFormRevisions:mc,deleteFormRevision:ys,deleteFormRevisions:fc}=fs.actions,Ne=t=>t.formRevisionReducer.instances,pc=u.createSelector([Ne],t=>Object.values(t)),Yu=t=>e=>e.formRevisionReducer.instances[t],yc=(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},Ku=g(u.createSelector([Ne,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(Wu)[s.length-1];return t[a.offline_id]})),Ac=g(u.createSelector([pc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.form===e)))),gc=fs.reducer,oe=I(t=>t.offline_id),Sc=oe.getInitialState({}),As=u.createSlice({name:"forms",initialState:Sc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sc)),reducers:{initializeForms:oe.initialize,setForm:oe.setOne,addForm:oe.addOne,addForms:oe.addMany,updateForm:oe.updateOne,deleteForm:oe.deleteOne}}),{initializeForms:Tc,setForm:Ju,addForm:gs,addForms:Xu,updateForm:Zu,deleteForm:Ss}=As.actions,bc=As.reducer,_c=t=>t.formReducer.instances,Qu=u.createSelector([_c],t=>Object.values(t)),Ic=t=>e=>e.formReducer.instances[t],xu=g(u.createSelector([t=>t.formReducer.instances,t=>t.formRevisionReducer.instances,(t,e)=>e],(t,e,s)=>{const{searchTerm:n,maxResults:a,organization:c}=s,o=[];for(const[d,m]of Object.entries(t)){if(Number.isInteger(c)&&c!==m.organization)continue;yc(e,d).title.toLowerCase().includes(n.toLowerCase())&&o.push(m)}return[...o.slice(0,a)]},{memoizeOptions:{resultEqualityCheck:Yi}})),L=I(t=>t.offline_id),Rc=L.getInitialState({}),Ts=u.createSlice({name:"formSubmissionAttachments",initialState:Rc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Rc)),reducers:{initializeFormSubmissionAttachments:L.initialize,addFormSubmissionAttachment:L.addOne,addFormSubmissionAttachments:L.addMany,setFormSubmissionAttachment:L.setOne,setFormSubmissionAttachments:L.setMany,updateFormSubmissionAttachment:L.updateOne,updateFormSubmissionAttachments:L.updateMany,deleteFormSubmissionAttachment:L.deleteOne,deleteFormSubmissionAttachments:L.deleteMany}}),{initializeFormSubmissionAttachments:Fc,addFormSubmissionAttachment:eh,addFormSubmissionAttachments:He,setFormSubmissionAttachment:th,setFormSubmissionAttachments:sh,updateFormSubmissionAttachment:ih,updateFormSubmissionAttachments:Oc,deleteFormSubmissionAttachment:nh,deleteFormSubmissionAttachments:We}=Ts.actions,bs=t=>t.formSubmissionAttachmentReducer.instances,vc=g(u.createSelector([bs,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),wc=g(u.createSelector([bs,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_submission===e)))),Ec=Ts.reducer,N=I(t=>t.offline_id),jc=N.getInitialState({}),_s=u.createSlice({name:"formSubmissions",initialState:jc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jc)),reducers:{initializeFormSubmissions:N.initialize,setFormSubmission:N.setOne,setFormSubmissions:N.setMany,addFormSubmission:N.addOne,addFormSubmissions:N.addMany,updateFormSubmission:N.updateOne,updateFormSubmissions:N.updateMany,deleteFormSubmission:N.deleteOne,deleteFormSubmissions:N.deleteMany}}),{initializeFormSubmissions:Pc,setFormSubmission:Ye,setFormSubmissions:ah,addFormSubmission:Is,addFormSubmissions:Ke,updateFormSubmission:qc,updateFormSubmissions:ch,deleteFormSubmission:Rs,deleteFormSubmissions:Je}=_s.actions,Fs=t=>t.formSubmissionReducer.instances,Os=u.createSelector([Fs],t=>Object.values(t)),vs=t=>e=>e.formSubmissionReducer.instances[t],kc=g(u.createSelector([Fs,Ne,(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))})),Dc=g(u.createSelector([Os,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),Cc=g(u.createSelector([Os,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),Mc=_s.reducer,H=I(t=>t.offline_id),zc=H.getInitialState({}),ws=u.createSlice({name:"geoImages",initialState:zc,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,zc)})},reducers:{initializeGeoImages:H.initialize,setGeoImage:H.setOne,setGeoImages:H.setMany,addGeoImage:H.addOne,addGeoImages:H.addMany,updateGeoImage:H.updateOne,updateGeoImages:H.updateMany,deleteGeoImage:H.deleteOne,deleteGeoImages:H.deleteMany}}),{initializeGeoImages:Uc,setGeoImage:ve,setGeoImages:Vc,addGeoImage:$c,addGeoImages:Bc,updateGeoImage:Gc,updateGeoImages:oh,deleteGeoImage:Es,deleteGeoImages:Lc}=ws.actions,Nc=t=>t.geoImageReducer.instances,Hc=u.createSelector([Nc],t=>Object.values(t)),js=t=>e=>e.geoImageReducer.instances[t],rh=g(u.createSelector([Hc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.project===e)))),Wc=ws.reducer,W=I(t=>t.offline_id),Yc=W.getInitialState({}),Ps=u.createSlice({name:"issueAssociations",initialState:Yc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yc)),reducers:{initializeIssueAssociations:W.initialize,addIssueAssociation:W.addOne,addIssueAssociations:W.addMany,setIssueAssociation:W.setOne,setIssueAssociations:W.setMany,updateIssueAssociation:W.updateOne,updateIssueAssociations:W.updateMany,deleteIssueAssociation:W.deleteOne,deleteIssueAssociations:W.deleteMany}}),{initializeIssueAssociations:Kc,setIssueAssociations:dh,setIssueAssociation:lh,updateIssueAssociation:Jc,updateIssueAssociations:uh,addIssueAssociation:qs,addIssueAssociations:ks,deleteIssueAssociation:Ds,deleteIssueAssociations:Cs}=Ps.actions,we=t=>t.issueAssociationReducer.instances,hh=u.createSelector([we],t=>Object.values(t)),Xc=t=>e=>e.issueAssociationReducer.instances[t],Zc=g(u.createSelector([we,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.associated_issue===e)))),Qc=g(u.createSelector([we,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),xc=g(u.createSelector([we,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.asset===e)))),eo=Ps.reducer,Y=I(t=>t.offline_id),to=Y.getInitialState({}),Ms=u.createSlice({name:"issueAttachments",initialState:to,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,to)),reducers:{initializeIssueAttachments:Y.initialize,addIssueAttachment:Y.addOne,addIssueAttachments:Y.addMany,setIssueAttachment:Y.setOne,setIssueAttachments:Y.setMany,updateIssueAttachment:Y.updateOne,updateIssueAttachments:Y.updateMany,deleteIssueAttachment:Y.deleteOne,deleteIssueAttachments:Y.deleteMany}}),{initializeIssueAttachments:so,addIssueAttachment:mh,addIssueAttachments:zs,setIssueAttachment:io,setIssueAttachments:fh,updateIssueAttachment:ph,updateIssueAttachments:no,deleteIssueAttachment:ao,deleteIssueAttachments:Us}=Ms.actions,co=t=>t.issueAttachmentReducer.instances,Vs=u.createSelector([co],t=>Object.values(t)),oo=g(u.createSelector([Vs,(t,e)=>e],(t,e)=>S(t.filter(({issue:s})=>e===s)))),ro=t=>e=>e.issueAttachmentReducer.instances[t],yh=g(u.createSelector([Vs,(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}})),lo=Ms.reducer,re=I(t=>t.offline_id),uo=re.getInitialState({}),$s=u.createSlice({name:"issueComments",initialState:uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uo)),reducers:{addIssueComment:re.addOne,addIssueComments:re.addMany,setIssueComment:re.setOne,setIssueComments:re.setMany,deleteIssueComment:re.deleteOne,deleteIssueComments:re.deleteMany}}),{setIssueComments:ho,setIssueComment:Bs,addIssueComment:Gs,addIssueComments:Ah,deleteIssueComment:Ls,deleteIssueComments:gh}=$s.actions,mo=t=>t.issueCommentReducer.instances,fo=t=>e=>e.issueCommentReducer.instances[t],Sh=g(u.createSelector([mo,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),po=$s.reducer,de=I(t=>t.offline_id),yo=de.getInitialState({}),Ns=u.createSlice({name:"issues",initialState:yo,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,yo)}),reducers:{initializeIssues:de.initialize,addIssue:de.addOne,addIssues:de.addMany,updateIssue:de.updateOne,deleteIssue:de.deleteOne,deleteIssues:de.deleteMany}}),{initializeIssues:Ao,addIssue:Hs,addIssues:go,updateIssue:Xe,deleteIssue:Ws,deleteIssues:So}=Ns.actions,To=t=>t.issueReducer.instances,Ys=t=>e=>e.issueReducer.instances[t],Th=g(u.createSelector([To,(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)})),bo=Ns.reducer,K=I(t=>t.offline_id),_o=K.getInitialState({}),Ks=u.createSlice({name:"issueTypeFieldsAttachments",initialState:_o,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,_o)),reducers:{initializeIssueTypeFieldsAttachments:K.initialize,addIssueTypeFieldsAttachment:K.addOne,addIssueTypeFieldsAttachments:K.addMany,setIssueTypeFieldsAttachment:K.setOne,setIssueTypeFieldsAttachments:K.setMany,updateIssueTypeFieldsAttachment:K.updateOne,updateIssueTypeFieldsAttachments:K.updateMany,deleteIssueTypeFieldsAttachment:K.deleteOne,deleteIssueTypeFieldsAttachments:K.deleteMany}}),{initializeIssueTypeFieldsAttachments:Io,addIssueTypeFieldsAttachment:bh,addIssueTypeFieldsAttachments:Ro,setIssueTypeFieldsAttachment:_h,setIssueTypeFieldsAttachments:Ih,updateIssueTypeFieldsAttachment:Rh,updateIssueTypeFieldsAttachments:Fo,deleteIssueTypeFieldsAttachment:Fh,deleteIssueTypeFieldsAttachments:Oo}=Ks.actions,vo=t=>t.issueTypeFieldsAttachmentReducer.instances,wo=u.createSelector([vo],t=>Object.values(t)),Oh=g(u.createSelector([wo,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),vh=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],Eo=Ks.reducer,J=I(t=>t.offline_id),jo=J.getInitialState({}),Js=u.createSlice({name:"issueTypeFieldValues",initialState:jo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jo)),reducers:{initializeIssueTypeFieldValues:J.initialize,addIssueTypeFieldValues:J.addOne,addIssueTypeFieldValuesMany:J.addMany,setIssueTypeFieldValues:J.setOne,setIssueTypeFieldValuesMany:J.setMany,updateIssueTypeFieldValues:J.updateOne,updateIssueTypeFieldValuesMany:J.updateMany,deleteIssueTypeFieldValues:J.deleteOne,deleteIssueTypeFieldValuesMany:J.deleteMany}}),{initializeIssueTypeFieldValues:Po,addIssueTypeFieldValues:Xs,addIssueTypeFieldValuesMany:wh,setIssueTypeFieldValues:Eh,setIssueTypeFieldValuesMany:jh,updateIssueTypeFieldValues:Ee,updateIssueTypeFieldValuesMany:Ph,deleteIssueTypeFieldValues:Zs,deleteIssueTypeFieldValuesMany:qh}=Js.actions,qo=t=>t.issueTypeFieldValuesReducer.instances,Qs=u.createSelector([qo],t=>Object.values(t)),kh=g(u.createSelector([Qs,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue===e)))),xs=t=>e=>e.issueTypeFieldValuesReducer.instances[t],ko=Js.reducer,X=I(t=>t.offline_id),Do=X.getInitialState({}),ei=u.createSlice({name:"issueTypeFields",initialState:Do,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Do)),reducers:{initializeIssueTypeFields:X.initialize,addIssueTypeFields:X.addOne,addIssueTypeFieldsMany:X.addMany,setIssueTypeFields:X.setOne,setIssueTypeFieldsMany:X.setMany,updateIssueTypeFields:X.updateOne,updateIssueTypeFieldsMany:X.updateMany,deleteIssueTypeFields:X.deleteOne,deleteIssueTypeFieldsMany:X.deleteMany}}),{initializeIssueTypeFields:Co,addIssueTypeFields:Mo,addIssueTypeFieldsMany:Dh,setIssueTypeFields:Ch,setIssueTypeFieldsMany:Mh,updateIssueTypeFields:zo,updateIssueTypeFieldsMany:zh,deleteIssueTypeFields:Uo,deleteIssueTypeFieldsMany:Uh}=ei.actions,Vo=t=>t.issueTypeFieldsReducer.instances,Ze=u.createSelector([Vo],t=>Object.values(t)),Vh=g(u.createSelector([Ze,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue_type===e)))),$h=g(u.createSelector([Ze,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Bh=g(u.createSelector([Ze,Qs,(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)))})),Gh=t=>e=>e.issueTypeFieldsReducer.instances[t],$o=ei.reducer,Z=I(t=>t.offline_id),Bo=Z.getInitialState({}),ti=u.createSlice({name:"issueTypeFieldValuesAttachments",initialState:Bo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bo)),reducers:{initializeIssueTypeFieldValuesAttachments:Z.initialize,addIssueTypeFieldValuesAttachment:Z.addOne,addIssueTypeFieldValuesAttachments:Z.addMany,setIssueTypeFieldValuesAttachment:Z.setOne,setIssueTypeFieldValuesAttachments:Z.setMany,updateIssueTypeFieldValuesAttachment:Z.updateOne,updateIssueTypeFieldValuesAttachments:Z.updateMany,deleteIssueTypeFieldValuesAttachment:Z.deleteOne,deleteIssueTypeFieldValuesAttachments:Z.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:Go,addIssueTypeFieldValuesAttachment:Lh,addIssueTypeFieldValuesAttachments:Qe,setIssueTypeFieldValuesAttachment:Nh,setIssueTypeFieldValuesAttachments:Hh,updateIssueTypeFieldValuesAttachment:Wh,updateIssueTypeFieldValuesAttachments:Lo,deleteIssueTypeFieldValuesAttachment:Yh,deleteIssueTypeFieldValuesAttachments:xe}=ti.actions,si=t=>t.issueTypeFieldValuesAttachmentReducer.instances,No=u.createSelector([si],t=>Object.values(t)),Kh=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],Ho=g(u.createSelector([si,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),Wo=g(u.createSelector([No,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),Yo=ti.reducer,ye=I(t=>t.offline_id),Ko=ye.getInitialState({}),ii=u.createSlice({name:"issueTypes",initialState:Ko,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Ko)}),reducers:{initializeIssueTypes:ye.initialize,setIssueType:ye.setOne,addIssueType:ye.addOne,updateIssueType:ye.updateOne,removeIssueType:ye.deleteOne}}),{initializeIssueTypes:Jo,setIssueType:je,addIssueType:Xo,updateIssueType:Zo,removeIssueType:ni}=ii.actions,Qo=t=>t.issueTypeReducer.instances,xo=u.createSelector(Qo,t=>Object.values(t)),ai=t=>e=>e.issueTypeReducer.instances[t],Jh=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},Xh=g(u.createSelector([xo,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),ci=g(u.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue_type===e)))),Zh=t=>e=>ci(t)(e).length,er=ii.reducer,le=I(t=>t.offline_id),tr=le.getInitialState({}),oi=u.createSlice({name:"issueUpdates",initialState:tr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,tr)),reducers:{initializeIssueUpdates:le.setMany,setIssueUpdate:le.setOne,addIssueUpdate:le.addOne,addIssueUpdates:le.addMany,deleteIssueUpdate:le.deleteOne,deleteIssueUpdates:le.deleteMany}}),{initializeIssueUpdates:sr,setIssueUpdate:Qh,addIssueUpdate:ir,addIssueUpdates:nr,deleteIssueUpdate:ar,deleteIssueUpdates:cr}=oi.actions,or=t=>t.issueUpdateReducer.instances,rr=g(u.createSelector([or,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),dr=oi.reducer,et=I(t=>t.offline_id),lr=et.getInitialState({}),ri=u.createSlice({name:"license",initialState:lr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,lr)),reducers:{initializeLicences:et.initialize,addLicenses:et.addMany,updateLicense:et.updateOne}}),{initializeLicences:ur,addLicenses:xh,updateLicense:te}=ri.actions,tt=t=>t.licenseReducer.instances,em=t=>e=>e.licenseReducer.instances[t],hr=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),tm=u.createSelector([tt],t=>S(Object.values(t).filter(e=>e.is_active))),sm=u.createSelector([tt],t=>ae(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),mr=ri.reducer,fr={users:{},currentUser:null},di=u.createSlice({name:"users",initialState:fr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,fr)),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:im,setProfilePicture:nm,setUsers:pr,addUsers:am,removeUser:yr}=di.actions,Ar=di.reducer,st=t=>t.userReducer.currentUser,it=t=>t.userReducer.users,cm=t=>e=>e.userReducer.users[t],om=g(u.createSelector([it,(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)})),nt=I(t=>t.offline_id),gr=nt.getInitialState({}),li=u.createSlice({name:"organizationAccess",initialState:gr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gr)),reducers:{initializeOrganizationAccesses:nt.initialize,updateOrganizationAccess:nt.updateOne,deleteOrganizationAccess:nt.deleteOne}}),{initializeOrganizationAccesses:Sr,updateOrganizationAccess:Tr,deleteOrganizationAccess:br}=li.actions,ui=t=>t.organizationAccessReducer.instances,rm=t=>e=>e.organizationAccessReducer.instances[t],dm=u.createSelector([st,ui],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.id))??null),lm=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),_r=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return ae(e)},Ir=li.reducer,Pe=I(t=>t.offline_id),Rr=Pe.getInitialState({}),hi=u.createSlice({name:"projectAccess",initialState:Rr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Rr)),reducers:{initializeProjectAccesses:Pe.initialize,updateProjectAccess:Pe.updateOne,deleteProjectAccess:Pe.deleteOne,deleteProjectAccesses:Pe.deleteMany}}),{initializeProjectAccesses:mi,updateProjectAccess:Fr,deleteProjectAccess:Or,deleteProjectAccesses:vr}=hi.actions,fi=t=>t.projectAccessReducer.instances,wr=u.createSelector(fi,t=>Object.values(t)),um=t=>e=>e.projectAccessReducer.instances[t],hm=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),Er=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return ae(e)},jr=hi.reducer,Pr={projects:{}},pi=u.createSlice({name:"projects",initialState:Pr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pr)),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:qr,updateProject:kr,deleteProject:Dr,acceptProjectInvite:Cr}=pi.actions,Mr=pi.reducer,at=t=>t.projectReducer.projects,mm=u.createSelector([at],t=>S(Object.values(t))),fm=t=>e=>e.projectReducer.projects[t],zr=u.createSelector([fi],t=>Object.values(t).map(e=>e.user)),Ur=u.createSelector([zr,it],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),pm=u.createSelector([st,Ur,Er],(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],o=s[a.id];return(c==null?void 0:c.access_level)===(o==null?void 0:o.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===rt.ADMIN?-1:1}))),Vr={organizations:{}},yi=u.createSlice({name:"organizations",initialState:Vr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vr)),reducers:{setOrganizations:(t,e)=>{for(const s of e.payload)t.organizations[s.id]=s}}}),{setOrganizations:$r}=yi.actions,Br=t=>t.organizationReducer.organizations,Gr=u.createSelector([Br],t=>Object.values(t)),ym=t=>e=>e.organizationReducer.organizations[t],Am=u.createSelector([Gr],t=>S(Object.values(t).filter(e=>e.has_access))),Lr=u.createSelector([ui],t=>Object.values(t).map(e=>e.user)),gm=g(u.createSelector([at,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),Sm=g(u.createSelector([tt,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),Nr=u.createSelector([Lr,it],(t,e)=>ae(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),Tm=u.createSelector([st,Nr,_r],(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],o=s[a.id];return(c==null?void 0:c.access_level)===(o==null?void 0:o.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===dt.ADMIN?-1:1}))),Hr=yi.reducer,Wr=(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}}}}},Yr={deletedRequests:[],latestRetryTime:0},Ai=u.createSlice({name:"outbox",initialState:Yr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yr)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return Wr(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}}}),bm=t=>t.outboxReducer.deletedRequests,_m=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Kr,markForDeletion:Im,markAsDeleted:Jr,_setLatestRetryTime:Xr}=Ai.actions,Zr=Ai.reducer,Q=I(t=>t.offline_id),Qr=Q.getInitialState({}),gi=u.createSlice({name:"projectAttachments",initialState:Qr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qr)),reducers:{initializeProjectAttachments:Q.initialize,addProjectAttachment:Q.addOne,addProjectAttachments:Q.addMany,setProjectAttachment:Q.setOne,setProjectAttachments:Q.setMany,updateProjectAttachment:Q.updateOne,updateProjectAttachments:Q.updateMany,deleteProjectAttachment:Q.deleteOne,deleteProjectAttachments:Q.deleteMany}}),{initializeProjectAttachments:xr,addProjectAttachment:Rm,addProjectAttachments:ed,setProjectAttachment:td,setProjectAttachments:sd,updateProjectAttachment:Fm,updateProjectAttachments:id,deleteProjectAttachment:nd,deleteProjectAttachments:Si}=gi.actions,ad=t=>t.projectAttachmentReducer.instances,Ti=u.createSelector([ad],t=>Object.values(t)),cd=t=>e=>e.projectAttachmentReducer.instances[t],od=g(u.createSelector([Ti,(t,e)=>e],(t,e)=>S(t.filter(({project:s})=>e===s)))),Om=g(u.createSelector([Ti,(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}})),rd=gi.reducer,x=I(t=>t.offline_id),dd=x.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),bi=u.createSlice({name:"projectFiles",initialState:dd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,dd)),reducers:{initializeProjectFiles:x.initialize,setProjectFile:x.setOne,setProjectFiles:x.setMany,addProjectFile:x.addOne,addProjectFiles:x.addMany,updateProjectFile:x.updateOne,updateProjectFiles:x.updateMany,deleteProjectFile:x.deleteOne,deleteProjectFiles:x.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:
|
|
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,Sl,Tl,Bi,bl,_l,Ae,Il,Rl,Fl,Ol){"use strict";var $p=Object.defineProperty;var Bp=(i,O,u)=>O in i?$p(i,O,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[O]=u;var A=(i,O,u)=>Bp(i,typeof O!="symbol"?O+"":O,u);var Al;const Gi=Object.freeze([]),Li=Object.freeze({});var ut=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(ut||{}),ht=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(ht||{}),l=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(l||{}),Ni=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(Ni||{}),mt=(t=>(t[t.LOWEST=0]="LOWEST",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=6]="HIGH",t[t.HIGHEST=8]="HIGHEST",t))(mt||{}),ft=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(ft||{}),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||{}),Hi=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Hi||{}),Wi=(t=>(t[t.PRO=0]="PRO",t))(Wi||{}),Ki=(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))(Ki||{});const vl=ft.BACKLOG,wl=mt.MEDIUM,Yi=6e4;function I(t){return{addOne:(f,p)=>{const y=t(p.payload);f.instances[y]=p.payload},addMany:(f,p)=>{for(const y of p.payload){const T=t(y);f.instances[T]=y}},setOne:(f,p)=>{const y=t(p.payload);f.instances[y]=p.payload},setMany:(f,p)=>{for(const y of p.payload){const T=t(y);f.instances[T]=y}},updateOne:(f,p)=>{const y=t(p.payload);f.instances[y]=p.payload},updateMany:(f,p)=>{for(const y of p.payload){const T=t(y);f.instances[T]=y}},deleteOne:(f,p)=>{delete f.instances[p.payload]},deleteMany:(f,p)=>{for(const y of p.payload)delete f.instances[y]},initialize:(f,p)=>{f.instances={};for(const y of p.payload){const T=t(y);f.instances[T]=y}},getInitialState:f=>({...f,instances:{}})}}Al=Symbol.toStringTag;class Ji{constructor(){A(this,Al,"Promise");A(this,"_promise");A(this,"_resolve");A(this,"_reject");A(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 El=t=>({type:"Point",coordinates:t}),jl=t=>({type:"MultiPoint",coordinates:t}),Pl=(t,e)=>t[0]===e[0]&&t[1]===e[1];let pt=!1;["true","1"].includes("".toLowerCase())&&(pt=!0);function ql(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 o=s[c];if(!Object.prototype.hasOwnProperty.call(e,o)||t[o]!==e[o])return!1}return!0}function yt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(pt&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(pt&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Cl(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?Gi:t,re=t=>Object.keys(t).length===0?Li:t,Xi=yt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===At.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),kl=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),Dl=1e3*86400,At=new Date,Ml=t=>new Date(t).toDateString()===At.toDateString(),zl=yt((t,e,s)=>{const n=Math.round((new Date(t).getTime()-At.getTime())/Dl);return n<e||n>s?Xi(t):kl.format(n,"days")});function Ul(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const gt=async(t,e)=>{e||(e=await ge(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 ge(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 o=Ul(c);e(o)})},n.readAsArrayBuffer(t)})}function Vl(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 Zi(t,e){return new File([t],e,{type:t.type})}function $l(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 Bl=async t=>{const e={};for(const s of t){const n=await ge(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},Qi=async t=>(await fetch(t)).blob(),Gl=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 Ll(t){const e=new Blob([t]);Sl.saveAs(e,t.name)}const xi={};function Nl(t,e,s,...n){const a=xi[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(xi[t]={[e]:!0},c=!0),c&&console[s](...n)}const en=["created_at","updated_at","index","revision"];function R(t){return{...t,offline_id:O.v4()}}function tn(t){const e={};for(const s of t)e[s.offline_id]=s;return e}function Hl(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 Wl(t){return t.toLowerCase().replace(" ","-")}function Kl(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Yl(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 sn(t,e,s){return s.findIndex(n=>n.offline_id===t.offline_id)===e}function Jl(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const Xl=/^.+@.+\..+$/;function v(t){const e={...t};for(const s of en)s in e&&delete e[s];return e}const Oe=I(t=>t.offline_id),nn=Oe.getInitialState({}),St=u.createSlice({name:"agents",initialState:nn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,nn)),reducers:{initializeConversations:Oe.initialize,addConversation:Oe.addOne,setConversation:Oe.setOne,updateConversation:Oe.updateOne}}),{initializeConversations:an,addConversation:cn,setConversation:on,updateConversation:rn}=St.actions,Tt=t=>t.agentsReducer.instances,Zl=u.createSelector([Tt],t=>Object.values(t)),Ql=S(u.createSelector([Tt,(t,e)=>e],(t,e)=>t[e])),dn=St.reducer,C=I(t=>t.offline_id),ln=C.getInitialState({}),bt=u.createSlice({name:"assetAttachments",initialState:ln,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ln)),reducers:{initializeAssetAttachments:C.initialize,addAssetAttachment:C.addOne,addAssetAttachments:C.addMany,setAssetAttachment:C.setOne,setAssetAttachments:C.setMany,updateAssetAttachment:C.updateOne,updateAssetAttachments:C.updateMany,deleteAssetAttachment:C.deleteOne,deleteAssetAttachments:C.deleteMany}}),{initializeAssetAttachments:_t,addAssetAttachment:xl,addAssetAttachments:It,setAssetAttachment:un,setAssetAttachments:eu,updateAssetAttachment:tu,updateAssetAttachments:hn,deleteAssetAttachment:mn,deleteAssetAttachments:Rt}=bt.actions,fn=t=>t.assetAttachmentReducer.instances,pn=u.createSelector([fn],t=>Object.values(t)),yn=t=>e=>e.assetAttachmentReducer.instances[t],An=S(u.createSelector([pn,(t,e)=>e],(t,e)=>g(t.filter(({asset:s})=>e===s)))),gn=bt.reducer,k=I(t=>t.offline_id),Sn=k.getInitialState({}),Ft=u.createSlice({name:"assets",initialState:Sn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sn)),reducers:{initializeAssets:k.initialize,addAsset:k.addOne,addAssets:k.addMany,setAsset:k.setOne,setAssets:k.setMany,updateAsset:k.updateOne,updateAssets:k.updateMany,deleteAsset:k.deleteOne,deleteAssets:k.deleteMany}}),{initializeAssets:Tn,addAsset:Ot,addAssets:vt,updateAsset:ve,updateAssets:su,deleteAsset:wt,deleteAssets:bn,setAsset:iu,setAssets:nu}=Ft.actions,Et=t=>t.assetReducer.instances,_n=u.createSelector([Et],t=>g(Object.values(t))),jt=S(u.createSelector([_n,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),Pt=t=>e=>e.assetReducer.instances[t],au=S(u.createSelector([Et,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),cu=t=>e=>jt(t)(e).length,In=Ft.reducer,ce=I(t=>t.offline_id),Rn=ce.getInitialState({}),qt=u.createSlice({name:"assetStageCompletions",initialState:Rn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Rn)),reducers:{initializeAssetStageCompletions:ce.initialize,addAssetStageCompletion:ce.addOne,addAssetStageCompletions:ce.addMany,updateAssetStageCompletion:ce.updateOne,updateAssetStageCompletions:ce.updateMany,deleteAssetStageCompletion:ce.deleteOne,deleteAssetStageCompletions:ce.deleteMany}}),{initializeAssetStageCompletions:Fn,addAssetStageCompletion:Ct,addAssetStageCompletions:kt,updateAssetStageCompletion:On,updateAssetStageCompletions:vn,deleteAssetStageCompletion:Dt,deleteAssetStageCompletions:Mt}=qt.actions,zt=t=>t.assetStageCompletionReducer.instances,ou=u.createSelector([zt],t=>{const e={};for(const s of Object.values(t)){const{asset:n,stage:a,submitted_at:c}=s;e[n]||(e[n]={}),e[n][a]=c}return re(e)}),wn=t=>e=>e.assetStageCompletionReducer.instances[t],En=S(u.createSelector([zt,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),jn=qt.reducer,D=I(t=>t.offline_id),Pn=D.getInitialState({}),Ut=u.createSlice({name:"assetStages",initialState:Pn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pn)),reducers:{initializeAssetStages:D.initialize,setAssetStage:D.setOne,setAssetStages:D.setMany,addAssetStage:D.addOne,addAssetStages:D.addMany,updateAssetStage:D.updateOne,updateAssetStages:D.updateMany,deleteAssetStage:D.deleteOne,deleteAssetStages:D.deleteMany}}),{initializeAssetStages:qn,setAssetStage:Cn,setAssetStages:ru,addAssetStage:du,addAssetStages:Ue,updateAssetStage:Vt,updateAssetStages:Ve,deleteAssetStage:lu,deleteAssetStages:$e}=Ut.actions,kn=Ut.reducer,Be=t=>t.assetStageReducer.instances,Dn=t=>e=>e.assetStageReducer.instances[t],Mn=u.createSelector([Be],t=>Object.values(t)),uu=S(u.createSelector([Be,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_type===e&&(s[n]=a);return re(s)})),zn=S(u.createSelector([Mn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e).sort((s,n)=>s.priority-n.priority)))),$t=S(u.createSelector([Be,(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)})),M=I(t=>t.offline_id),Un=M.getInitialState({}),Bt=u.createSlice({name:"assetTypeAttachments",initialState:Un,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Un)),reducers:{initializeAssetTypeAttachments:M.initialize,addAssetTypeAttachment:M.addOne,addAssetTypeAttachments:M.addMany,setAssetTypeAttachment:M.setOne,setAssetTypeAttachments:M.setMany,updateAssetTypeAttachment:M.updateOne,updateAssetTypeAttachments:M.updateMany,deleteAssetTypeAttachment:M.deleteOne,deleteAssetTypeAttachments:M.deleteMany}}),{initializeAssetTypeAttachments:Vn,addAssetTypeAttachment:hu,addAssetTypeAttachments:Gt,setAssetTypeAttachment:$n,setAssetTypeAttachments:mu,updateAssetTypeAttachment:fu,updateAssetTypeAttachments:Bn,deleteAssetTypeAttachment:Gn,deleteAssetTypeAttachments:Lt}=Bt.actions,Ln=t=>t.assetTypeAttachmentReducer.instances,Nn=u.createSelector([Ln],t=>Object.values(t)),Hn=t=>e=>e.assetTypeAttachmentReducer.instances[t],Wn=S(u.createSelector([Nn,(t,e)=>e],(t,e)=>g(t.filter(({asset_type:s})=>e===s)))),Kn=Bt.reducer,z=I(t=>t.offline_id),Yn=z.getInitialState({}),Nt=u.createSlice({name:"assetTypeFieldsAttachments",initialState:Yn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yn)),reducers:{initializeAssetTypeFieldsAttachments:z.initialize,addAssetTypeFieldsAttachment:z.addOne,addAssetTypeFieldsAttachments:z.addMany,setAssetTypeFieldsAttachment:z.setOne,setAssetTypeFieldsAttachments:z.setMany,updateAssetTypeFieldsAttachment:z.updateOne,updateAssetTypeFieldsAttachments:z.updateMany,deleteAssetTypeFieldsAttachment:z.deleteOne,deleteAssetTypeFieldsAttachments:z.deleteMany}}),{initializeAssetTypeFieldsAttachments:Jn,addAssetTypeFieldsAttachment:pu,addAssetTypeFieldsAttachments:Xn,setAssetTypeFieldsAttachment:yu,setAssetTypeFieldsAttachments:Au,updateAssetTypeFieldsAttachment:gu,updateAssetTypeFieldsAttachments:Zn,deleteAssetTypeFieldsAttachment:Su,deleteAssetTypeFieldsAttachments:Qn}=Nt.actions,xn=t=>t.assetTypeFieldsAttachmentReducer.instances,ea=u.createSelector([xn],t=>Object.values(t)),Tu=S(u.createSelector([ea,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),bu=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],ta=Nt.reducer,U=I(t=>t.offline_id),sa=U.getInitialState({}),Ht=u.createSlice({name:"assetTypeFields",initialState:sa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sa)),reducers:{initializeAssetTypeFields:U.initialize,addAssetTypeFields:U.addOne,addAssetTypeFieldsMany:U.addMany,setAssetTypeFields:U.setOne,setAssetTypeFieldsMany:U.setMany,updateAssetTypeFields:U.updateOne,updateAssetTypeFieldsMany:U.updateMany,deleteAssetTypeFields:U.deleteOne,deleteAssetTypeFieldsMany:U.deleteMany}}),{initializeAssetTypeFields:ia,addAssetTypeFields:na,addAssetTypeFieldsMany:_u,setAssetTypeFields:Iu,setAssetTypeFieldsMany:Ru,updateAssetTypeFields:aa,updateAssetTypeFieldsMany:Fu,deleteAssetTypeFields:ca,deleteAssetTypeFieldsMany:Ou}=Ht.actions,oa=t=>t.assetTypeFieldsReducer.instances,Ge=u.createSelector([oa],t=>Object.values(t)),vu=S(u.createSelector([Ge,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),wu=S(u.createSelector([Ge,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Eu=t=>e=>e.assetTypeFieldsReducer.instances[t],ra=Ht.reducer,V=I(t=>t.offline_id),da=V.getInitialState({}),Wt=u.createSlice({name:"assetTypeFieldValuesAttachments",initialState:da,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,da)),reducers:{initializeAssetTypeFieldValuesAttachments:V.initialize,addAssetTypeFieldValuesAttachment:V.addOne,addAssetTypeFieldValuesAttachments:V.addMany,setAssetTypeFieldValuesAttachment:V.setOne,setAssetTypeFieldValuesAttachments:V.setMany,updateAssetTypeFieldValuesAttachment:V.updateOne,updateAssetTypeFieldValuesAttachments:V.updateMany,deleteAssetTypeFieldValuesAttachment:V.deleteOne,deleteAssetTypeFieldValuesAttachments:V.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:la,addAssetTypeFieldValuesAttachment:ju,addAssetTypeFieldValuesAttachments:Le,setAssetTypeFieldValuesAttachment:Pu,setAssetTypeFieldValuesAttachments:qu,updateAssetTypeFieldValuesAttachment:Cu,updateAssetTypeFieldValuesAttachments:ua,deleteAssetTypeFieldValuesAttachment:ku,deleteAssetTypeFieldValuesAttachments:Ne}=Wt.actions,Kt=t=>t.assetTypeFieldValuesAttachmentReducer.instances,ha=u.createSelector([Kt],t=>Object.values(t)),Du=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],ma=S(u.createSelector([Kt,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),fa=S(u.createSelector([ha,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),pa=Wt.reducer,$=I(t=>t.offline_id),ya=$.getInitialState({}),Yt=u.createSlice({name:"assetTypeFieldValues",initialState:ya,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ya)),reducers:{initializeAssetTypeFieldValues:$.initialize,addAssetTypeFieldValues:$.addOne,addAssetTypeFieldValuesMany:$.addMany,setAssetTypeFieldValues:$.setOne,setAssetTypeFieldValuesMany:$.setMany,updateAssetTypeFieldValues:$.updateOne,updateAssetTypeFieldValuesMany:$.updateMany,deleteAssetTypeFieldValues:$.deleteOne,deleteAssetTypeFieldValuesMany:$.deleteMany}}),{initializeAssetTypeFieldValues:Aa,addAssetTypeFieldValues:Jt,addAssetTypeFieldValuesMany:ga,setAssetTypeFieldValues:Mu,setAssetTypeFieldValuesMany:zu,updateAssetTypeFieldValues:we,updateAssetTypeFieldValuesMany:Sa,deleteAssetTypeFieldValues:Xt,deleteAssetTypeFieldValuesMany:Ta}=Yt.actions,ba=t=>t.assetTypeFieldValuesReducer.instances,Zt=u.createSelector([ba],t=>Object.values(t)),Uu=S(u.createSelector([Zt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Vu=S(u.createSelector([Ge,Zt,(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)))})),Qt=t=>e=>e.assetTypeFieldValuesReducer.instances[t],_a=Yt.reducer,B=I(t=>t.offline_id),Ia=B.getInitialState({}),xt=u.createSlice({name:"assetTypes",initialState:Ia,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ia)),reducers:{initializeAssetTypes:B.initialize,setAssetType:B.setOne,setAssetTypes:B.setMany,addAssetType:B.addOne,addAssetTypes:B.addMany,updateAssetType:B.updateOne,updateAssetTypes:B.updateMany,deleteAssetType:B.deleteOne,deleteAssetTypes:B.deleteMany}}),{initializeAssetTypes:Ra,setAssetType:$u,setAssetTypes:Bu,addAssetType:es,addAssetTypes:Gu,updateAssetType:Ee,updateAssetTypes:Lu,deleteAssetType:ts,deleteAssetTypes:Nu}=xt.actions,ss=t=>t.assetTypeReducer.instances,Hu=u.createSelector([ss],t=>Object.values(t)),is=t=>e=>e.assetTypeReducer.instances[t],Wu=S(u.createSelector([ss,(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)})),Fa=xt.reducer,Oa={accessToken:"",refreshToken:"",isLoggedIn:!1},He=u.createSlice({name:"auth",initialState:Oa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Oa)),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||He.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Ku,clearTokens:Yu,setLoggedIn:va}=He.actions,Ju=t=>t.authReducer.accessToken,Xu=t=>t.authReducer.isLoggedIn,wa=He.reducer,je=I(t=>t.offline_id),Ea=je.getInitialState({}),ns=u.createSlice({name:"categories",initialState:Ea,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ea)),reducers:{initializeCategories:je.initialize,addCategory:je.addOne,updateCategory:je.updateOne,deleteCategory:je.deleteOne}}),{initializeCategories:ja,addCategory:as,updateCategory:Pa,deleteCategory:qa}=ns.actions,cs=t=>t.categoryReducer.instances,Zu=u.createSelector([cs],t=>Object.values(t)),os=t=>e=>e.categoryReducer.instances[t],Qu=S(u.createSelector([cs,(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)})),xu=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,Ca=ns.reducer,G=I(t=>t.offline_id),ka=G.getInitialState({}),rs=u.createSlice({name:"documentAttachments",initialState:ka,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ka)),reducers:{initializeDocumentAttachments:G.initialize,addDocumentAttachment:G.addOne,addDocumentAttachments:G.addMany,setDocumentAttachment:G.setOne,setDocumentAttachments:G.setMany,updateDocumentAttachment:G.updateOne,updateDocumentAttachments:G.updateMany,deleteDocumentAttachment:G.deleteOne,deleteDocumentAttachments:G.deleteMany}}),{initializeDocumentAttachments:Da,addDocumentAttachment:eh,addDocumentAttachments:Ma,setDocumentAttachment:za,setDocumentAttachments:th,updateDocumentAttachment:sh,updateDocumentAttachments:Ua,deleteDocumentAttachment:Va,deleteDocumentAttachments:$a}=rs.actions,Ba=t=>t.documentAttachmentReducer.instances,Ga=u.createSelector([Ba],t=>Object.values(t)),La=t=>e=>e.documentAttachmentReducer.instances[t],ih=S(u.createSelector([Ga,(t,e)=>e],(t,e)=>g(t.filter(({document:s})=>e===s)))),Na=rs.reducer,Ha={documents:{}},ds=u.createSlice({name:"documents",initialState:Ha,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Ha)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(sn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=tn(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:o}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(o.indexOf(c.offline_id),1)}if(n){const o=t.documents[n],d=o!=null&&o.parent_document?t.documents[o.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[o.parent_document].children_documents.splice(d.children_documents.indexOf(o.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[o.parent_document].children_documents.splice(d.children_documents.indexOf(o.offline_id)+1,0,c.offline_id),t.documents[s].parent_document=d.offline_id;break;case"left-child":if(!o)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=o.offline_id;break;case"right-child":if(!o)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=o.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:Wa,addDocuments:Ka,updateDocuments:oe,moveDocument:Ya,removeDocuments:ls}=ds.actions,Se=t=>t.documentsReducer.documents,Ja=u.createSelector([Se],t=>Object.values(t)),Xa=t=>e=>e.documentsReducer.documents[t],nh=S(u.createSelector([Se,(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)})),ah=S(u.createSelector([Se,(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)})),ch=u.createSelector([Ja],t=>g(t.filter(e=>!e.parent_document))),Za=ds.reducer,We=I(t=>t.offline_id),oh=We.getInitialState({}),us=u.createSlice({name:"emailDomains",initialState:oh,reducers:{initializeEmailDomains:We.initialize,addEmailDomain:We.addOne,deleteEmailDomain:We.deleteOne}}),{initializeEmailDomains:Qa,addEmailDomain:xa,deleteEmailDomain:ec}=us.actions,tc=t=>t.emailDomainsReducer.instances,sc=u.createSelector([tc],t=>Object.values(t)),rh=S(u.createSelector([sc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),ic=us.reducer,nc={s3Urls:{}},ac=1e3*60*60,dh=ac*24*7,hs=u.createSlice({name:"file",initialState:nc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,nc)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:n,sha1:a}=e.payload,c=new Date,o=new Date(c.getTime()+dh);t.s3Urls[a]={url:s,fields:n,exp:o.getTime()}}}}),{setUploadUrl:cc}=hs.actions,oc=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<ac))return s},rc=hs.reducer,L=I(t=>t.offline_id),dc=L.getInitialState({}),ms=u.createSlice({name:"formRevisionAttachments",initialState:dc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,dc)),reducers:{initializeFormRevisionAttachments:L.initialize,addFormRevisionAttachment:L.addOne,addFormRevisionAttachments:L.addMany,setFormRevisionAttachment:L.setOne,setFormRevisionAttachments:L.setMany,updateFormRevisionAttachment:L.updateOne,updateFormRevisionAttachments:L.updateMany,deleteFormRevisionAttachment:L.deleteOne,deleteFormRevisionAttachments:L.deleteMany}}),{initializeFormRevisionAttachments:lc,addFormRevisionAttachment:lh,addFormRevisionAttachments:uc,setFormRevisionAttachment:uh,setFormRevisionAttachments:hh,updateFormRevisionAttachment:mh,updateFormRevisionAttachments:hc,deleteFormRevisionAttachment:fh,deleteFormRevisionAttachments:mc}=ms.actions,fc=t=>t.formRevisionAttachmentReducer.instances,ph=S(u.createSelector([fc,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_revision===e)))),pc=ms.reducer,yh=(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},de=I(t=>t.offline_id),yc=de.getInitialState({}),fs=u.createSlice({name:"formRevisions",initialState:yc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,yc)),reducers:{initializeFormRevisions:de.initialize,setFormRevision:de.setOne,addFormRevision:de.addOne,addFormRevisions:de.addMany,deleteFormRevision:de.deleteOne,deleteFormRevisions:de.deleteMany}}),{setFormRevision:Ac,initializeFormRevisions:gc,addFormRevision:ps,addFormRevisions:Sc,deleteFormRevision:ys,deleteFormRevisions:Tc}=fs.actions,Ke=t=>t.formRevisionReducer.instances,bc=u.createSelector([Ke],t=>Object.values(t)),Ah=t=>e=>e.formRevisionReducer.instances[t],gh=S(u.createSelector([Ke,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(yh)[s.length-1];return t[a.offline_id]})),_c=S(u.createSelector([bc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.form===e)))),Ic=fs.reducer,le=I(t=>t.offline_id),Rc=le.getInitialState({}),As=u.createSlice({name:"forms",initialState:Rc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Rc)),reducers:{initializeForms:le.initialize,setForm:le.setOne,addForm:le.addOne,addForms:le.addMany,updateForm:le.updateOne,deleteForm:le.deleteOne}}),{initializeForms:Fc,setForm:Sh,addForm:gs,addForms:Th,updateForm:bh,deleteForm:Ss}=As.actions,Oc=As.reducer,vc=t=>t.formReducer.instances,_h=u.createSelector([vc],t=>Object.values(t)),wc=t=>e=>e.formReducer.instances[t],N=I(t=>t.offline_id),Ec=N.getInitialState({}),Ts=u.createSlice({name:"formSubmissionAttachments",initialState:Ec,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ec)),reducers:{initializeFormSubmissionAttachments:N.initialize,addFormSubmissionAttachment:N.addOne,addFormSubmissionAttachments:N.addMany,setFormSubmissionAttachment:N.setOne,setFormSubmissionAttachments:N.setMany,updateFormSubmissionAttachment:N.updateOne,updateFormSubmissionAttachments:N.updateMany,deleteFormSubmissionAttachment:N.deleteOne,deleteFormSubmissionAttachments:N.deleteMany}}),{initializeFormSubmissionAttachments:jc,addFormSubmissionAttachment:Ih,addFormSubmissionAttachments:Ye,setFormSubmissionAttachment:Rh,setFormSubmissionAttachments:Fh,updateFormSubmissionAttachment:Oh,updateFormSubmissionAttachments:Pc,deleteFormSubmissionAttachment:vh,deleteFormSubmissionAttachments:Je}=Ts.actions,bs=t=>t.formSubmissionAttachmentReducer.instances,qc=S(u.createSelector([bs,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),Cc=S(u.createSelector([bs,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_submission===e)))),kc=Ts.reducer,H=I(t=>t.offline_id),Dc=H.getInitialState({}),_s=u.createSlice({name:"formSubmissions",initialState:Dc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dc)),reducers:{initializeFormSubmissions:H.initialize,setFormSubmission:H.setOne,setFormSubmissions:H.setMany,addFormSubmission:H.addOne,addFormSubmissions:H.addMany,updateFormSubmission:H.updateOne,updateFormSubmissions:H.updateMany,deleteFormSubmission:H.deleteOne,deleteFormSubmissions:H.deleteMany}}),{initializeFormSubmissions:Mc,setFormSubmission:Xe,setFormSubmissions:wh,addFormSubmission:Is,addFormSubmissions:Ze,updateFormSubmission:zc,updateFormSubmissions:Eh,deleteFormSubmission:Rs,deleteFormSubmissions:Qe}=_s.actions,Fs=t=>t.formSubmissionReducer.instances,Os=u.createSelector([Fs],t=>Object.values(t)),vs=t=>e=>e.formSubmissionReducer.instances[t],Uc=S(u.createSelector([Fs,Ke,(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))})),Vc=S(u.createSelector([Os,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),$c=S(u.createSelector([Os,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),Bc=_s.reducer,W=I(t=>t.offline_id),Gc=W.getInitialState({}),ws=u.createSlice({name:"geoImages",initialState:Gc,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,Gc)})},reducers:{initializeGeoImages:W.initialize,setGeoImage:W.setOne,setGeoImages:W.setMany,addGeoImage:W.addOne,addGeoImages:W.addMany,updateGeoImage:W.updateOne,updateGeoImages:W.updateMany,deleteGeoImage:W.deleteOne,deleteGeoImages:W.deleteMany}}),{initializeGeoImages:Lc,setGeoImage:Pe,setGeoImages:Nc,addGeoImage:Hc,addGeoImages:Wc,updateGeoImage:Kc,updateGeoImages:jh,deleteGeoImage:Es,deleteGeoImages:Yc}=ws.actions,Jc=t=>t.geoImageReducer.instances,Xc=u.createSelector([Jc],t=>Object.values(t)),js=t=>e=>e.geoImageReducer.instances[t],Ph=S(u.createSelector([Xc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),Zc=ws.reducer,K=I(t=>t.offline_id),Qc=K.getInitialState({}),Ps=u.createSlice({name:"issueAssociations",initialState:Qc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qc)),reducers:{initializeIssueAssociations:K.initialize,addIssueAssociation:K.addOne,addIssueAssociations:K.addMany,setIssueAssociation:K.setOne,setIssueAssociations:K.setMany,updateIssueAssociation:K.updateOne,updateIssueAssociations:K.updateMany,deleteIssueAssociation:K.deleteOne,deleteIssueAssociations:K.deleteMany}}),{initializeIssueAssociations:xc,setIssueAssociations:qh,setIssueAssociation:Ch,updateIssueAssociation:eo,updateIssueAssociations:kh,addIssueAssociation:qs,addIssueAssociations:Cs,deleteIssueAssociation:ks,deleteIssueAssociations:Ds}=Ps.actions,qe=t=>t.issueAssociationReducer.instances,Dh=u.createSelector([qe],t=>Object.values(t)),to=t=>e=>e.issueAssociationReducer.instances[t],so=S(u.createSelector([qe,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.associated_issue===e)))),io=S(u.createSelector([qe,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),no=S(u.createSelector([qe,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.asset===e)))),ao=Ps.reducer,Y=I(t=>t.offline_id),co=Y.getInitialState({}),Ms=u.createSlice({name:"issueAttachments",initialState:co,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,co)),reducers:{initializeIssueAttachments:Y.initialize,addIssueAttachment:Y.addOne,addIssueAttachments:Y.addMany,setIssueAttachment:Y.setOne,setIssueAttachments:Y.setMany,updateIssueAttachment:Y.updateOne,updateIssueAttachments:Y.updateMany,deleteIssueAttachment:Y.deleteOne,deleteIssueAttachments:Y.deleteMany}}),{initializeIssueAttachments:zs,addIssueAttachment:Mh,addIssueAttachments:Us,setIssueAttachment:oo,setIssueAttachments:zh,updateIssueAttachment:Uh,updateIssueAttachments:ro,deleteIssueAttachment:lo,deleteIssueAttachments:Vs}=Ms.actions,uo=t=>t.issueAttachmentReducer.instances,ho=u.createSelector([uo],t=>Object.values(t)),mo=S(u.createSelector([ho,(t,e)=>e],(t,e)=>g(t.filter(({issue:s})=>e===s)))),fo=t=>e=>e.issueAttachmentReducer.instances[t],po=Ms.reducer,J=I(t=>t.offline_id),yo=J.getInitialState({}),$s=u.createSlice({name:"issueCommentAttachments",initialState:yo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,yo)),reducers:{initializeIssueCommentAttachments:J.initialize,addIssueCommentAttachment:J.addOne,addIssueCommentAttachments:J.addMany,setIssueCommentAttachment:J.setOne,setIssueCommentAttachments:J.setMany,updateIssueCommentAttachment:J.updateOne,updateIssueCommentAttachments:J.updateMany,deleteIssueCommentAttachment:J.deleteOne,deleteIssueCommentAttachments:J.deleteMany}}),{initializeIssueCommentAttachments:Bs,addIssueCommentAttachment:Vh,addIssueCommentAttachments:Ao,setIssueCommentAttachment:go,setIssueCommentAttachments:$h,updateIssueCommentAttachment:Bh,updateIssueCommentAttachments:So,deleteIssueCommentAttachment:To,deleteIssueCommentAttachments:bo}=$s.actions,_o=t=>t.issueCommentAttachmentReducer.instances,Io=u.createSelector([_o],t=>Object.values(t)),Ro=t=>e=>e.issueCommentAttachmentReducer.instances[t],Gh=S(u.createSelector([Io,(t,e)=>e],(t,e)=>g(t.filter(({issue_comment:s})=>e===s)))),Fo=$s.reducer,ue=I(t=>t.offline_id),Oo=ue.getInitialState({}),Gs=u.createSlice({name:"issueComments",initialState:Oo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Oo)),reducers:{addIssueComment:ue.addOne,addIssueComments:ue.addMany,setIssueComment:ue.setOne,setIssueComments:ue.setMany,deleteIssueComment:ue.deleteOne,deleteIssueComments:ue.deleteMany}}),{setIssueComments:vo,setIssueComment:Ls,addIssueComment:Ns,addIssueComments:Lh,deleteIssueComment:Hs,deleteIssueComments:Nh}=Gs.actions,wo=t=>t.issueCommentReducer.instances,Eo=t=>e=>e.issueCommentReducer.instances[t],Hh=S(u.createSelector([wo,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),jo=Gs.reducer,he=I(t=>t.offline_id),Po=he.getInitialState({}),Ws=u.createSlice({name:"issues",initialState:Po,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Po)}),reducers:{initializeIssues:he.initialize,addIssue:he.addOne,addIssues:he.addMany,updateIssue:he.updateOne,deleteIssue:he.deleteOne,deleteIssues:he.deleteMany}}),{initializeIssues:qo,addIssue:Ks,addIssues:Co,updateIssue:xe,deleteIssue:Ys,deleteIssues:ko}=Ws.actions,Do=t=>t.issueReducer.instances,Js=t=>e=>e.issueReducer.instances[t],Wh=S(u.createSelector([Do,(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)})),Mo=Ws.reducer,X=I(t=>t.offline_id),zo=X.getInitialState({}),Xs=u.createSlice({name:"issueTypeAttachments",initialState:zo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zo)),reducers:{initializeIssueTypeAttachments:X.initialize,addIssueTypeAttachment:X.addOne,addIssueTypeAttachments:X.addMany,setIssueTypeAttachment:X.setOne,setIssueTypeAttachments:X.setMany,updateIssueTypeAttachment:X.updateOne,updateIssueTypeAttachments:X.updateMany,deleteIssueTypeAttachment:X.deleteOne,deleteIssueTypeAttachments:X.deleteMany}}),{initializeIssueTypeAttachments:Zs,addIssueTypeAttachment:Kh,addIssueTypeAttachments:Uo,setIssueTypeAttachment:Vo,setIssueTypeAttachments:Yh,updateIssueTypeAttachment:Jh,updateIssueTypeAttachments:$o,deleteIssueTypeAttachment:Bo,deleteIssueTypeAttachments:Go}=Xs.actions,Lo=t=>t.issueTypeAttachmentReducer.instances,No=u.createSelector([Lo],t=>Object.values(t)),Ho=t=>e=>e.issueTypeAttachmentReducer.instances[t],Xh=S(u.createSelector([No,(t,e)=>e],(t,e)=>g(t.filter(({issue_type:s})=>e===s)))),Wo=Xs.reducer,Z=I(t=>t.offline_id),Ko=Z.getInitialState({}),Qs=u.createSlice({name:"issueTypeFieldsAttachments",initialState:Ko,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ko)),reducers:{initializeIssueTypeFieldsAttachments:Z.initialize,addIssueTypeFieldsAttachment:Z.addOne,addIssueTypeFieldsAttachments:Z.addMany,setIssueTypeFieldsAttachment:Z.setOne,setIssueTypeFieldsAttachments:Z.setMany,updateIssueTypeFieldsAttachment:Z.updateOne,updateIssueTypeFieldsAttachments:Z.updateMany,deleteIssueTypeFieldsAttachment:Z.deleteOne,deleteIssueTypeFieldsAttachments:Z.deleteMany}}),{initializeIssueTypeFieldsAttachments:Yo,addIssueTypeFieldsAttachment:Zh,addIssueTypeFieldsAttachments:Jo,setIssueTypeFieldsAttachment:Qh,setIssueTypeFieldsAttachments:xh,updateIssueTypeFieldsAttachment:em,updateIssueTypeFieldsAttachments:Xo,deleteIssueTypeFieldsAttachment:tm,deleteIssueTypeFieldsAttachments:Zo}=Qs.actions,Qo=t=>t.issueTypeFieldsAttachmentReducer.instances,xo=u.createSelector([Qo],t=>Object.values(t)),sm=S(u.createSelector([xo,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),im=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],er=Qs.reducer,Q=I(t=>t.offline_id),tr=Q.getInitialState({}),xs=u.createSlice({name:"issueTypeFieldValues",initialState:tr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,tr)),reducers:{initializeIssueTypeFieldValues:Q.initialize,addIssueTypeFieldValues:Q.addOne,addIssueTypeFieldValuesMany:Q.addMany,setIssueTypeFieldValues:Q.setOne,setIssueTypeFieldValuesMany:Q.setMany,updateIssueTypeFieldValues:Q.updateOne,updateIssueTypeFieldValuesMany:Q.updateMany,deleteIssueTypeFieldValues:Q.deleteOne,deleteIssueTypeFieldValuesMany:Q.deleteMany}}),{initializeIssueTypeFieldValues:sr,addIssueTypeFieldValues:ei,addIssueTypeFieldValuesMany:nm,setIssueTypeFieldValues:am,setIssueTypeFieldValuesMany:cm,updateIssueTypeFieldValues:Ce,updateIssueTypeFieldValuesMany:om,deleteIssueTypeFieldValues:ti,deleteIssueTypeFieldValuesMany:rm}=xs.actions,ir=t=>t.issueTypeFieldValuesReducer.instances,si=u.createSelector([ir],t=>Object.values(t)),dm=S(u.createSelector([si,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue===e)))),ii=t=>e=>e.issueTypeFieldValuesReducer.instances[t],nr=xs.reducer,x=I(t=>t.offline_id),ar=x.getInitialState({}),ni=u.createSlice({name:"issueTypeFields",initialState:ar,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ar)),reducers:{initializeIssueTypeFields:x.initialize,addIssueTypeFields:x.addOne,addIssueTypeFieldsMany:x.addMany,setIssueTypeFields:x.setOne,setIssueTypeFieldsMany:x.setMany,updateIssueTypeFields:x.updateOne,updateIssueTypeFieldsMany:x.updateMany,deleteIssueTypeFields:x.deleteOne,deleteIssueTypeFieldsMany:x.deleteMany}}),{initializeIssueTypeFields:cr,addIssueTypeFields:or,addIssueTypeFieldsMany:lm,setIssueTypeFields:um,setIssueTypeFieldsMany:hm,updateIssueTypeFields:rr,updateIssueTypeFieldsMany:mm,deleteIssueTypeFields:dr,deleteIssueTypeFieldsMany:fm}=ni.actions,lr=t=>t.issueTypeFieldsReducer.instances,et=u.createSelector([lr],t=>Object.values(t)),pm=S(u.createSelector([et,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue_type===e)))),ym=S(u.createSelector([et,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Am=S(u.createSelector([et,si,(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)))})),gm=t=>e=>e.issueTypeFieldsReducer.instances[t],ur=ni.reducer,ee=I(t=>t.offline_id),hr=ee.getInitialState({}),ai=u.createSlice({name:"issueTypeFieldValuesAttachments",initialState:hr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,hr)),reducers:{initializeIssueTypeFieldValuesAttachments:ee.initialize,addIssueTypeFieldValuesAttachment:ee.addOne,addIssueTypeFieldValuesAttachments:ee.addMany,setIssueTypeFieldValuesAttachment:ee.setOne,setIssueTypeFieldValuesAttachments:ee.setMany,updateIssueTypeFieldValuesAttachment:ee.updateOne,updateIssueTypeFieldValuesAttachments:ee.updateMany,deleteIssueTypeFieldValuesAttachment:ee.deleteOne,deleteIssueTypeFieldValuesAttachments:ee.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:mr,addIssueTypeFieldValuesAttachment:Sm,addIssueTypeFieldValuesAttachments:tt,setIssueTypeFieldValuesAttachment:Tm,setIssueTypeFieldValuesAttachments:bm,updateIssueTypeFieldValuesAttachment:_m,updateIssueTypeFieldValuesAttachments:fr,deleteIssueTypeFieldValuesAttachment:Im,deleteIssueTypeFieldValuesAttachments:st}=ai.actions,ci=t=>t.issueTypeFieldValuesAttachmentReducer.instances,pr=u.createSelector([ci],t=>Object.values(t)),Rm=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],yr=S(u.createSelector([ci,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),Ar=S(u.createSelector([pr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),gr=ai.reducer,Te=I(t=>t.offline_id),Sr=Te.getInitialState({}),oi=u.createSlice({name:"issueTypes",initialState:Sr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Sr)}),reducers:{initializeIssueTypes:Te.initialize,setIssueType:Te.setOne,addIssueType:Te.addOne,updateIssueType:Te.updateOne,removeIssueType:Te.deleteOne}}),{initializeIssueTypes:Tr,setIssueType:ke,addIssueType:br,updateIssueType:_r,removeIssueType:ri}=oi.actions,Ir=t=>t.issueTypeReducer.instances,Rr=u.createSelector(Ir,t=>Object.values(t)),di=t=>e=>e.issueTypeReducer.instances[t],Fm=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},Om=S(u.createSelector([Rr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),li=S(u.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue_type===e)))),vm=t=>e=>li(t)(e).length,Fr=oi.reducer,me=I(t=>t.offline_id),Or=me.getInitialState({}),ui=u.createSlice({name:"issueUpdates",initialState:Or,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Or)),reducers:{initializeIssueUpdates:me.setMany,setIssueUpdate:me.setOne,addIssueUpdate:me.addOne,addIssueUpdates:me.addMany,deleteIssueUpdate:me.deleteOne,deleteIssueUpdates:me.deleteMany}}),{initializeIssueUpdates:vr,setIssueUpdate:wm,addIssueUpdate:wr,addIssueUpdates:Er,deleteIssueUpdate:jr,deleteIssueUpdates:Pr}=ui.actions,qr=t=>t.issueUpdateReducer.instances,Cr=S(u.createSelector([qr,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),kr=ui.reducer,it=I(t=>t.offline_id),Dr=it.getInitialState({}),hi=u.createSlice({name:"license",initialState:Dr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dr)),reducers:{initializeLicences:it.initialize,addLicenses:it.addMany,updateLicense:it.updateOne}}),{initializeLicences:Mr,addLicenses:Em,updateLicense:ne}=hi.actions,nt=t=>t.licenseReducer.instances,jm=t=>e=>e.licenseReducer.instances[t],zr=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),Pm=u.createSelector([nt],t=>g(Object.values(t).filter(e=>e.is_active))),qm=u.createSelector([nt],t=>re(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),Ur=hi.reducer,Vr={users:{},currentUser:null},mi=u.createSlice({name:"users",initialState:Vr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vr)),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:Cm,setProfilePicture:km,setUsers:$r,addUsers:Dm,removeUser:Br}=mi.actions,Gr=mi.reducer,at=t=>t.userReducer.currentUser,ct=t=>t.userReducer.users,Mm=t=>e=>e.userReducer.users[t],zm=S(u.createSelector([ct,(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)})),ot=I(t=>t.offline_id),Lr=ot.getInitialState({}),fi=u.createSlice({name:"organizationAccess",initialState:Lr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lr)),reducers:{initializeOrganizationAccesses:ot.initialize,updateOrganizationAccess:ot.updateOne,deleteOrganizationAccess:ot.deleteOne}}),{initializeOrganizationAccesses:Nr,updateOrganizationAccess:Hr,deleteOrganizationAccess:Wr}=fi.actions,pi=t=>t.organizationAccessReducer.instances,Um=t=>e=>e.organizationAccessReducer.instances[t],Vm=u.createSelector([at,pi],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.id))??null),$m=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),Kr=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return re(e)},Yr=fi.reducer,De=I(t=>t.offline_id),Jr=De.getInitialState({}),yi=u.createSlice({name:"projectAccess",initialState:Jr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Jr)),reducers:{initializeProjectAccesses:De.initialize,updateProjectAccess:De.updateOne,deleteProjectAccess:De.deleteOne,deleteProjectAccesses:De.deleteMany}}),{initializeProjectAccesses:Ai,updateProjectAccess:Xr,deleteProjectAccess:Zr,deleteProjectAccesses:Qr}=yi.actions,gi=t=>t.projectAccessReducer.instances,xr=u.createSelector(gi,t=>Object.values(t)),Bm=t=>e=>e.projectAccessReducer.instances[t],Gm=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),ed=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return re(e)},td=yi.reducer,sd={projects:{}},Si=u.createSlice({name:"projects",initialState:sd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sd)),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:id,updateProject:nd,deleteProject:ad,acceptProjectInvite:cd}=Si.actions,od=Si.reducer,rt=t=>t.projectReducer.projects,Lm=u.createSelector([rt],t=>g(Object.values(t))),Nm=t=>e=>e.projectReducer.projects[t],rd=u.createSelector([gi],t=>Object.values(t).map(e=>e.user)),dd=u.createSelector([rd,ct],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),Hm=u.createSelector([at,dd,ed],(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],o=s[a.id];return(c==null?void 0:c.access_level)===(o==null?void 0:o.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===ut.ADMIN?-1:1}))),ld={organizations:{}},Ti=u.createSlice({name:"organizations",initialState:ld,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ld)),reducers:{setOrganizations:(t,e)=>{for(const s of e.payload)t.organizations[s.id]=s}}}),{setOrganizations:ud}=Ti.actions,hd=t=>t.organizationReducer.organizations,md=u.createSelector([hd],t=>Object.values(t)),Wm=t=>e=>e.organizationReducer.organizations[t],Km=u.createSelector([md],t=>g(Object.values(t).filter(e=>e.has_access))),fd=u.createSelector([pi],t=>Object.values(t).map(e=>e.user)),Ym=S(u.createSelector([rt,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),Jm=S(u.createSelector([nt,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),pd=u.createSelector([fd,ct],(t,e)=>re(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),Xm=u.createSelector([at,pd,Kr],(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],o=s[a.id];return(c==null?void 0:c.access_level)===(o==null?void 0:o.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===ht.ADMIN?-1:1}))),yd=Ti.reducer,Ad=(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}}}}},gd={deletedRequests:[],latestRetryTime:0},bi=u.createSlice({name:"outbox",initialState:gd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gd)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return Ad(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}}}),Zm=t=>t.outboxReducer.deletedRequests,Qm=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Sd,markForDeletion:xm,markAsDeleted:Td,_setLatestRetryTime:bd}=bi.actions,_d=bi.reducer,te=I(t=>t.offline_id),Id=te.getInitialState({}),_i=u.createSlice({name:"projectAttachments",initialState:Id,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Id)),reducers:{initializeProjectAttachments:te.initialize,addProjectAttachment:te.addOne,addProjectAttachments:te.addMany,setProjectAttachment:te.setOne,setProjectAttachments:te.setMany,updateProjectAttachment:te.updateOne,updateProjectAttachments:te.updateMany,deleteProjectAttachment:te.deleteOne,deleteProjectAttachments:te.deleteMany}}),{initializeProjectAttachments:Rd,addProjectAttachment:ef,addProjectAttachments:Fd,setProjectAttachment:Od,setProjectAttachments:vd,updateProjectAttachment:tf,updateProjectAttachments:wd,deleteProjectAttachment:Ed,deleteProjectAttachments:Ii}=_i.actions,jd=t=>t.projectAttachmentReducer.instances,Pd=u.createSelector([jd],t=>Object.values(t)),qd=t=>e=>e.projectAttachmentReducer.instances[t],Cd=S(u.createSelector([Pd,(t,e)=>e],(t,e)=>g(t.filter(({project:s})=>e===s)))),kd=_i.reducer,se=I(t=>t.offline_id),Dd=se.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),Ri=u.createSlice({name:"projectFiles",initialState:Dd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dd)),reducers:{initializeProjectFiles:se.initialize,setProjectFile:se.setOne,setProjectFiles:se.setMany,addProjectFile:se.addOne,addProjectFiles:se.addMany,updateProjectFile:se.updateOne,updateProjectFiles:se.updateMany,deleteProjectFile:se.deleteOne,deleteProjectFiles:se.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:Md,setProjectFile:sf,setProjectFiles:nf,addProjectFile:af,addProjectFiles:zd,updateProjectFile:Fi,updateProjectFiles:cf,deleteProjectFile:Ud,deleteProjectFiles:Vd,setIsImportingProjectFile:$d,setActiveProjectFileId:Bd,saveActiveProjectFileBounds:Gd,resetProjectFileObjectUrls:of}=Ri.actions,Ld=t=>t.projectFileReducer.instances,Nd=u.createSelector([Ld],t=>g(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),rf=t=>e=>e.projectFileReducer.instances[t],df=t=>t.projectFileReducer.activeProjectFileId,lf=t=>t.projectFileReducer.isImportingProjectFile,Hd=Ri.reducer,uf={isRehydrated:!1},Oi=u.createSlice({name:"rehydrated",initialState:uf,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:hf}=Oi.actions,mf=t=>t.rehydratedReducer.isRehydrated,Wd=Oi.reducer,be=I(t=>t.offline_id),Kd=be.getInitialState({}),vi=u.createSlice({name:"teams",initialState:Kd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kd)),reducers:{setTeam:be.setOne,initializeTeams:be.initialize,addTeam:be.addOne,updateTeam:be.updateOne,deleteTeam:be.deleteOne}}),{setTeam:_e,initializeTeams:Yd,addTeam:Jd,updateTeam:wi,deleteTeam:Ei}=vi.actions,ji=t=>t.teamReducer.instances,Pi=u.createSelector([ji],t=>Object.values(t)),Ie=t=>e=>e.teamReducer.instances[t],ff=S(u.createSelector([ji,(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)})),pf=S(u.createSelector([Pi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),yf=S(u.createSelector([Pi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.members.includes(e))))),Xd=vi.reducer,Af={version:0},Zd=u.createSlice({name:"versioning",initialState:Af,reducers:{}}),Qd=Zd.reducer;let xd;function gf(t){xd=t}function Me(){return xd}let el;function Sf(t){el=t}function Tf(){return el}const tl={};class sl{constructor(e){A(this,"client");tl[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 il="versioning",nl=()=>ol.length-1,al=t=>(t[il]={version:nl()},t),cl=()=>al({}),bf=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),_f=t=>e=>{var s;return e===void 0&&(e={}),((s=e[il])==null?void 0:s.version)===nl()?e:t(e)},ol=[al,cl,cl,bf],If=Object.fromEntries(ol.map((t,e)=>[e,_f(t)])),qi="versioning",rl={[qi]:Qd,fileReducer:rc,authReducer:wa,categoryReducer:Ca,assetReducer:In,assetAttachmentReducer:gn,assetStageCompletionReducer:jn,assetStageReducer:kn,assetTypeReducer:Fa,assetTypeAttachmentReducer:Kn,issueReducer:Mo,issueAttachmentReducer:po,issueTypeReducer:Fr,issueTypeAttachmentReducer:Wo,organizationReducer:yd,outboxReducer:_d,projectReducer:od,projectAttachmentReducer:kd,projectAccessReducer:td,organizationAccessReducer:Yr,projectFileReducer:Hd,rehydratedReducer:Wd,formReducer:Oc,formRevisionReducer:Ic,formRevisionAttachmentReducer:pc,formSubmissionAttachmentReducer:kc,formSubmissionReducer:Bc,userReducer:Gr,emailDomainsReducer:ic,licenseReducer:Ur,documentsReducer:Za,documentAttachmentReducer:Na,teamReducer:Xd,agentsReducer:dn,issueCommentReducer:jo,issueCommentAttachmentReducer:Fo,issueUpdateReducer:kr,geoImageReducer:Zc,issueAssociationReducer:ao,issueTypeFieldsReducer:ur,issueTypeFieldValuesReducer:nr,issueTypeFieldsAttachmentReducer:er,issueTypeFieldValuesAttachmentReducer:gr,assetTypeFieldsReducer:ra,assetTypeFieldValuesReducer:_a,assetTypeFieldsAttachmentReducer:ta,assetTypeFieldValuesAttachmentReducer:pa},dl=u.combineReducers(rl),ll="RESET",Rf=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?dl(void 0,e):dl(t,e);let Ci=null;function fe(){const t=Me();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(Ci)return Ci;const e=t.getState().offline.outbox,s=Fe._fromOutbox(e);return Ci=s,s}const Ff=t=>{if(t)throw t;const e=Me();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},ul=(t,e,s)=>{const n=fe();return n?(n.addRequest(e),n.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},hl=(t,e,s)=>{const n=fe();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 Of(t,e){if(!e.payload)throw new Error("Received empty payload");return Df(e)}const vf={...Bi,effect:Of,discard:Di,returnPromises:!0,persistCallback:Ff,retry:zf,persistOptions:{storage:bl},queue:{...Bi.queue,enqueue:ul,dequeue:hl,peek:(...t)=>Mf(...t)}},wf=_l(If,qi),Ef=u.compose(Tl.offline(vf),wf);function jf(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 ki(t,e){const s=tl[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const n=s instanceof F;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},o=t.meta.offline.effect,{payload:d,headers:m,method:r,queryParams:h,attachmentHash:f,isExternalUrl:p,isAuthNeeded:y,isResponseBlob:T}={...c,...o.request},_=o.request;let b=_.url;const j=f?await e.files.fetchCache(f):void 0;if(f&&!j)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 ae=E=>{if(f){const ie=_.s3url;if(!ie)throw new Error(`No S3 URL for file ${f}`);if("warning"in ie)throw new Error(`S3 URL warning for file ${f}`);if(!j)throw new Error(`No file for file ${f}`);const ze=ie.fields["x-amz-checksum-sha1"];if(!ze)throw new Error(`No checksum for file ${f}`);return E.set("x-amz-checksum-sha1",ze).field({...d,...ie.fields}).attach("file",j)}return E.send(d)},Vp={[l.GET]:()=>T?Ae.get(b.toString()).responseType("blob"):Ae.get(b.toString()),[l.POST]:()=>{const E=Ae.post(b.toString());return ae(E)},[l.PATCH]:()=>{const E=Ae.patch(b.toString());return ae(E)},[l.PUT]:()=>{const E=Ae.put(b.toString());return ae(E)},[l.DELETE]:()=>{const E=Ae.delete(b.toString());return ae(E)}}[r];let ye=Vp();if(y&&n){const E=s.auth.getAuthHeader();ye=ye.set("Authorization",E)}m&&(ye=ye.set(m));try{return await ye.query(h)}catch(E){const ie=jf(E),ze=ie==null?void 0:ie.status;if(n&&ze===401)return await s.auth.handleUnauthorized(ye,ie),ye.query(h);throw new P({response:ie,innerError:E,discard:fl.includes(ze)})}}class Pf{constructor(e){A(this,"_all");A(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 ml{constructor(){A(this,"next");this.next=null}then(e){return new Pf(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!Me())throw new Error("Client store not set");const n=Tf();if(!n)throw new Error("Client SDK not set");return ki(e,n)}}}class qf extends ml{async run(e){return super.run(e)}}class Cf extends ml{async run(e){return super.run(e)}}const kf=new qf().then(new Cf).compile();function Df(t){var e;return(e=kf[0])==null?void 0:e.run(t)}const fl=[400,409,403,404,405,500];function Di(t,e,s=0){var r;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=
|
|
5
|
-
Action:`,e);const f=
|
|
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=Me(),c=n.getState().outboxReducer.deletedRequests,o=e.payload.uuid;function d(){n.dispatch(Td(o));const h=fe();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 P&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),d();if(c.includes(o))return console.debug("Discarding request due to deletion:",e),d();if(t instanceof P){const h=t.status||((r=t.response)==null?void 0:r.status);if(h||console.warn("Error has no status code:",t),h!==void 0&&fl.includes(h)){console.warn("Discarding request due to error:",t,`
|
|
5
|
+
Action:`,e);const f=fe();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=fe();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function Mf(t,e,s){var n;return(n=fe())==null?void 0:n.peek()}function zf(t,e){return Me().dispatch(bd(new Date().getTime())),Yi}const Re="An unknown error occurred",Uf=500,pl=["non_field_errors","detail"];function Vf(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"?pl.includes(a)?c:`${a}: ${c}`:Array.isArray(c)?pl.includes(a)?c.join(`
|
|
6
6
|
`):c.map(o=>`${a}: ${o}`).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>
|
|
9
|
-
Converting error to APIError and discarding.`),r=new j({message:"An error occurred while processing the request.",innerError:r,discard:!0})),a.reject(r)};o.then(d,m)}return a}}class be{constructor(){A(this,"graph");A(this,"requestAttemptCounter");this.graph=new Zd.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new be;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 o=e[c];if(!o){console.error("Previous outbox item was undefined");continue}o.payload.uuid!==a.payload.uuid&&o.payload.blocks.some(d=>a.payload.blockers.includes(d))&&be._addDependency(a.payload.uuid,o.payload.uuid,s.graph)}}return s}_addDependency(e,s){be._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 hf=(t,e)=>{const s=new e(t);return Lm(s),Gm(t),s};class F extends jd{constructor(s,n){super(s);A(this,"auth");this.auth=n}}class mf extends F{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(sn(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(an(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(nn(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(tn(s))}}class P extends F{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:o,formRevisionAttachmentReducer:d,formSubmissionAttachmentReducer:m,geoImageReducer:r,assetTypeFieldsAttachmentReducer:h,assetTypeFieldValuesAttachmentReducer:f,issueTypeFieldsAttachmentReducer:p,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(n.instances),Object.values(a.instances),Object.values(c.instances),Object.values(o.instances),Object.values(d.instances),Object.values(m.instances),Object.values(r.instances),Object.values(h.instances),Object.values(f.instances),Object.values(p.instances),Object.values(y.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 fe(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 ke extends P{async _bulkAdd(e){var r;const{store:s}=this.client,n=(r=s.getState().userReducer.currentUser)==null?void 0:r.id,a=new Date().toISOString(),c=[],o=[],d={};for(const h of e){const{modelId:f,file:p}=h,y=await this.getFilePayload(p);y.sha1 in d||(d[y.sha1]=y);const T=this.buildOfflineAttachment({file:p,file_sha1:y.sha1,submitted_at:a,created_by:n,description:"",modelId:f});c.push(T),o.push(this.buildAttachmentPayload({offline_id:T.offline_id,file_name:T.file_name,file_sha1:T.file_sha1,file_extension:y.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:o,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: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 ff extends ke{constructor(){super(...arguments);A(this,"name","Asset Attachment");A(this,"url","/asset-attachments");A(this,"initializeAttachments",St);A(this,"addAttachments",Tt);A(this,"updateAttachments",dn);A(this,"removeAttachments",bt);A(this,"removeAttachment",ln);A(this,"setAttachment",rn);A(this,"selectAttachment",hn)}buildOfflineAttachment(s){return R({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(St(n))}}function ki(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class pf extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(Rt(c));const o=this.enqueueRequest({description:"Create asset",method:l.POST,url:"/assets/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return o.then(d=>{this.dispatch(Ie(d))}).catch(()=>{this.dispatch(Ot(c.offline_id))}),[c,o]}update(e){const{store:s}=this.client,n=Et(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(Ie(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(o=>{this.dispatch(Ie(o))}).catch(()=>{this.dispatch(Ie(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Et(e)(n);if(!a)throw new Error(`No asset with id ${e} found in the store`);const c=mn(e)(n),o=Cc(e)(n),d=xc(e)(n);if(this.dispatch(Ot(e)),c.length>0){const m=c.map(({offline_id:r})=>r);this.dispatch(bt(m))}if(o.length>0){const m=o.map(({offline_id:r})=>r);this.dispatch(Je(m))}if(d.length>0){const m=d.map(({offline_id:r})=>r);this.dispatch(Cs(m))}return this.enqueueRequest({description:"Delete asset",method:l.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(Rt(a)),this.dispatch(Tt(c)),this.dispatch(Ke(o)),this.dispatch(ks(d)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),o=O.v4(),d=ki(e,a).map(h=>{const f=h.map(p=>R(p));return{batchId:O.v4(),payload:{transaction_id:o,submitted_at:c,asset_type:s,project:n,assets:f}}}),m=[];let r=null;for(const h of d){const{batchId:f,payload:p}=h,y=p.assets.map(E=>E.offline_id),T=[s];r&&T.push(r);const _=y;_.push(f);const b=this.enqueueRequest({description:"Batch create assets",method:l.POST,url:"/assets/bulk/",payload:p,blockers:T,blocks:_});r=h.batchId,m.push(b)}return Promise.all(m).then(h=>{const f=h.flat();this.dispatch(Ft(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(yn(s))}}class yf extends F{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Pt(c));const o=this.enqueueRequest({description:"Add asset stage completion",method:l.POST,url:"/asset-stage-completions/",payload:{offline_id:c.offline_id,submitted_at:a,asset:e.asset,stage:e.stage},blockers:[e.asset,e.stage],blocks:[c.offline_id]});return o.then(d=>{this.dispatch(_n(d))}).catch(()=>{this.dispatch(kt(c.offline_id))}),[c,o]}delete(e){const{store:s}=this.client,n=Rn(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with id ${e} to exist`);this.dispatch(kt(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(Pt(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.id,c=e.map(r=>R(r)),o=c.map(r=>({...r,created_by:a,submitted_at:n})),d=o.map(({offline_id:r})=>r);this.dispatch(qt(o));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(r=>r.asset),...e.map(r=>r.stage)],blocks:d});return m.then(r=>{this.dispatch(In(r))}).catch(()=>{this.dispatch(Dt(d))}),[o,m]}bulkDelete(e){const{store:s}=this.client,n=Fn(e)(s.getState());this.dispatch(Dt(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(qt(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(bn(s))}}class Af extends F{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.id,c=e.map(m=>R(m)),o=c.map(m=>({...m,asset_type:s,created_by:a,submitted_at:n}));this.dispatch(Ce(o));const d=this.enqueueRequest({description:"Add asset stages",method:l.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_type:s,stages:c},blockers:[s],blocks:c.map(({offline_id:m})=>m)});return d.then(m=>{this.dispatch(Me(m))}).catch(()=>{this.dispatch(ze(o.map(({offline_id:m})=>m)))}),[o,d]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Ut(e.map(({offline_id:o})=>o))(a);return this.dispatch(Me(e)),this.enqueueRequest({description:"Edit asset stages",method:l.PATCH,url:`/asset-types/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({offline_id:o})=>o)}).catch(o=>{throw this.dispatch(Me(c)),o})}async bulkDelete(e){const{store:s}=this.client,n=Ut(e)(s.getState());this.dispatch(ze(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(Ce(n))}),a}update(e){const{store:s}=this.client,n=Pn(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(zt(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(o=>{this.dispatch(zt(o))}).catch(()=>{this.dispatch(En(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(wn(s))}}class gf extends ke{constructor(){super(...arguments);A(this,"name","Asset Type Attachment");A(this,"url","/asset-type-attachments");A(this,"addAttachments",$t);A(this,"updateAttachments",zn);A(this,"removeAttachments",Bt);A(this,"removeAttachment",Un);A(this,"setAttachment",Mn);A(this,"selectAttachment",$n)}buildOfflineAttachment(s){return R({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(Cn(n))}}class Sf extends P{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=[],o=[];for(const r of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.extension,file_sha1:y.sha1,fields_revision:h};o.push(_)}this.dispatch(Hn(c));const d=this.enqueueRequest({description:"Add asset type fields attachments",method:l.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.fields_revision),blocks:c.map(r=>r.offline_id)});return d.then(r=>{this.processPresignedUrls(r.presigned_urls),this.dispatch(Wn(r.attachments))}).catch(()=>{this.dispatch(Yn(c.map(r=>r.offline_id)))}),[c,d.then(({attachments:r})=>r)]}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(Nn(s))}}class Tf extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(xn(c));const o=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 o.then(m=>{this.dispatch(ea(m))}).catch(m=>{throw this.dispatch(ta(c.offline_id)),m}),[c,o]}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(Qn(s))}}class bf extends P{async bulkAdd(e,s){var r;const n=new Date().toISOString(),a=(r=this.client.store.getState().userReducer.currentUser)==null?void 0:r.id,c=ki(e,s??e.length),o=[],d=[];for(const h of c){const f={},p=[];for(const y of h){const{fieldValuesId:T,fieldIdentifier:_,file:b}=y,E=await this.getFilePayload(b);E.sha1 in f||(f[E.sha1]=E);const se=R({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:E.sha1,created_by:a,field_values:T,submitted_at:n,field_identifier:_});o.push(se);const Wd={offline_id:se.offline_id,file_name:b.name,file_sha1:E.sha1,file_extension:E.extension,field_identifier:_,field_values:T};p.push(Wd)}d.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch($e(o));const m=d.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(ca(f))}).catch(h=>{throw this.dispatch(Be(o.map(f=>f.offline_id))),h}),[o,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ra(e)(n);this.dispatch(Be(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($e(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(aa(s))}}const _f=t=>Array.isArray(t)&&t[0]instanceof File,Di=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:_f(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class If extends P{add(e){var o;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(o=n.userReducer.currentUser)==null?void 0:o.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:l.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(Is(a)),c.then(d=>(this.dispatch(Ye(d)),d)).catch(()=>{this.dispatch(Rs(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=vs(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(qc(c));const o=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 o.then(d=>{this.dispatch(Ye(d))}).catch(()=>{this.dispatch(Ye(a))}),[c,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=vs(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=wc(e)(n);this.dispatch(Rs(e)),this.dispatch(We(c.map(o=>o.offline_id)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:l.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(Is(a)),this.dispatch(He(c)),o}}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(Pc(s))}}class Rf extends F{add(e){var o;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(o=n.userReducer.currentUser)==null?void 0:o.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:l.POST,url:"/asset-type-field-values/",payload:a,blockers:[e.asset,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(Kt(a)),c.then(d=>(this.dispatch(Re(d)),d)).catch(()=>{this.dispatch(Jt(a.offline_id))}),[a,c]}bulkAdd(e,s){var r;const n=new Date().toISOString(),{values:a}=Di(e.values),c=[],o=ki(e.payloads,s??e.payloads.length),d=[];for(const h of o){const f=[];for(const p of h){const y=R({...p,values:Di(p.values).values,created_by:(r=this.client.store.getState().userReducer.currentUser)==null?void 0:r.id,submitted_at:n});c.push(y),f.push({offline_id:y.offline_id,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:y.values})}d.push({submitted_at:n,values:a,field_values:f})}this.dispatch(ma(c));const m=[];for(const h of d){const f=h.field_values.map(_=>_.asset),p=h.field_values.map(_=>_.fields_revision),y=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:y});m.push(T)}return Promise.all(m).then(h=>{this.dispatch(fa(h.flat()))}).catch(()=>{this.dispatch(pa(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Zt(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(Re(c));const o=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 o.then(d=>{this.dispatch(Re(d))}).catch(()=>{this.dispatch(Re(a))}),[c,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Zt(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=da(e)(n);this.dispatch(Jt(e)),this.dispatch(Be(c.map(o=>o.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(o){throw this.dispatch(Kt(a)),this.dispatch($e(c)),o}}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(ha(s))}}class Ff extends F{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(xt(c));const o=this.enqueueRequest({description:"Create asset type",method:l.POST,url:"/asset-types/",payload:c,blockers:[],blocks:[c.offline_id]});return o.then(d=>{this.dispatch(Fe(d))}).catch(()=>{this.dispatch(es(c.offline_id))}),[c,o]}update(e){const{store:s}=this.client,n=ss(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(Fe(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(o=>{this.dispatch(Fe(o))}).catch(()=>{this.dispatch(Fe(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ss(e)(n);if(!a)throw new Error(`Expected asset type with offline_id ${e} to exist`);const c=wt(e)(n),o=kn(e)(n),d=Bn(e)(n);return this.dispatch(es(e)),this.dispatch(An(c.map(m=>m.offline_id))),this.dispatch(ze(o.map(m=>m.offline_id))),this.dispatch(Bt(d.map(({offline_id:m})=>m))),this.enqueueRequest({description:"Delete asset type",method:l.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(xt(a)),this.dispatch(Ft(c)),this.dispatch(Ce(o)),this.dispatch($t(d)),m})}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(Sa(s))}}class Of extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(ns(c));const o=this.enqueueRequest({description:"Create Category",method:l.POST,url:"/categories/",payload:c,blockers:[e.project.toString()],blocks:[c.offline_id]});return[c,o]}update(e){const s=this.client.store.getState(),n=cs(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(Oa(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=cs(e)(s.getState());if(!n)throw new Error(`No category with id ${e} found in the store`);this.dispatch(va(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(ns(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(Fa(s))}}class vf extends ke{constructor(){super(...arguments);A(this,"name","Document Attachment");A(this,"url","/document-attachments");A(this,"addAttachments",Pa);A(this,"updateAttachments",ka);A(this,"removeAttachments",Ca);A(this,"removeAttachment",Da);A(this,"setAttachment",qa);A(this,"selectAttachment",za)}buildOfflineAttachment(s){return R({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(),o=[],d=[],m={},r={};for(const p of s){const{documentId:y,file:T}=p,_=await this.getFilePayload(T);_.sha1 in m||(m[_.sha1]=_,r[_.sha1]=[]);const b=this.buildOfflineAttachment({file:T,file_sha1:_.sha1,submitted_at:c,created_by:a,description:"",modelId:y});o.push(b),d.push({offline_id:b.offline_id,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:_.extension,description:b.description,document:y}),r[_.sha1].push(b.offline_id)}this.dispatch(this.addAttachments(o));const h=this.enqueueRequest({description:"Attach files to document",method:l.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:d,files:Object.values(m)},blocks:o.map(p=>p.offline_id),blockers:o.map(p=>p.file_sha1)});return h.then(({attachments:p,presigned_urls:y})=>{this.dispatch(this.updateAttachments(p));const T=this.processPresignedUrls(y);for(const[_,b]of Object.entries(T))b.then(()=>{const E=r[_];for(const se of E)this.makeReadable(se)})}).catch(()=>{this.dispatch(this.removeAttachments(o.map(p=>p.offline_id)))}),[o,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(ja(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 wf extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(Ba([c]));const o=this.enqueueRequest({description:"Create Document",method:l.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 o.catch(()=>{this.dispatch(ls([c.offline_id]))}),[c,o]}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(ne([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(()=>{ne([n])}),[a,c]}move(e,s,n){const{store:a}=this.client,c=pe(a.getState()),o=[],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(o.push(d),d.parent_document&&o.push(c[d.parent_document]),s){const r=c[s];if(!r)throw new Error(`attempting to move a document to target with offline_id ${s} that does not exist in store.documents`);o.push(r),r.parent_document&&o.push(c[r.parent_document])}this.dispatch(Ga({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(r=>{this.dispatch(ne(r))}).catch(()=>{this.dispatch(ne(o))}),m}delete(e){const{store:s}=this.client,n=pe(s.getState()),a=Na(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(ls([e]));const o=this.enqueueRequest({description:"Delete Document",method:l.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return o.then(d=>{this.dispatch(ne(d))}).catch(()=>{this.dispatch(ne([a])),c&&this.dispatch(ne([c]))}),o}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($a([...await n,...await a]))}}class Ef extends F{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(Ka(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(Ya(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(Wa(s))}}class jf extends F{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 ct={},Ci=new Set;let ot=0,Mi=0,zi=0;const Pf=20;class qf extends F{constructor(){super(...arguments);A(this,"host");A(this,"_dbPromise",Qd.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:l.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await fe(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(ec({sha1:s,...c})),c}async addCache(s,n){if(Ci.has(n))return;if(!s.type){const o=s.name.split("."),d=o[o.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),ot++):(await a.put("files",s,n),Mi++),Ci.add(n),zi++,zi%Pf===0&&console.debug(`File cache summary: ${ot} hits and ${Mi} misses, ${ot/(ot+Mi)*100}% hit rate over ${zi} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),Ci.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return tc(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},o=await this.getOrRenewUploadUrl(s);if("warning"in o){if(o.warning==="already_uploaded")return[c,Promise.resolve(void 0).then()];throw new Error(o.warning)}const d=o.url,m=this.enqueueRequest({url:d,description:"Upload file",method:l.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${a}`],blocks:[s],s3url:o});return[c,m]}async fetchFileFromUrl(s,n,a){const c=s.split("?")[0]??s,o=await this.fetchCache(n);if(o){if(!o.name)throw new Error("Cached file unexpectedly has no name.");return o}if(s.startsWith("blob:")){const h=await Xi(s),f=new File([h],a??n,{type:h.type});return await this.addCache(f,n),f}let d=ct[c],m=!0;d?m=!1:(d=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)})}),ct[c]=d);let r;try{r=await d}catch(h){throw m&&h instanceof j&&delete ct[c],h}if(m){const h=await fe(r);if(h!==n){const y=`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>Uf?Re:s}class P extends Error{constructor(s){super(Re);A(this,"status");A(this,"response");A(this,"message");A(this,"options");const{response:n,innerError:a}=s;this.message=s.message??Vf(n,a)??Re,this.status=(n==null?void 0:n.status)??0,this.response=n,s.discard=s.discard??!1,this.options=s}}class $f{constructor(e){A(this,"store");this.store=e}async enqueueRequest(e,s,n){return this._enqueueRequest(e,s,n).then(a=>{if(a instanceof P)throw a;return a})}_enqueueRequest(e,s,n){const a=new Ji,c={...e,BASE_URL:s,serviceName:n};if(e.immediate){const o={...c,uuid:e.uuid??O.v4()},d={payload:o,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:o,BASE_URL:s,serviceName:n}}}};ki(d,this).then(m=>{a.resolve(m.body)}).catch(m=>{Di(m,d),m instanceof Error?a.reject(m):a.reject(new Error((m??Re).toString()))})}else{const o=this.store.dispatch(Sd(c)),d=r=>{if(r)a.resolve(r.body);else{const h=new P({message:"Could not get a response from the server.",response:r,discard:!0});a.reject(h)}},m=r=>{r instanceof P?r.options.discard=!0:(console.error("Received an unexpected error while processing a request:",r,`
|
|
9
|
+
Converting error to APIError and discarding.`),r=new P({message:"An error occurred while processing the request.",innerError:r,discard:!0})),a.reject(r)};o.then(d,m)}return a}}class Fe{constructor(){A(this,"graph");A(this,"requestAttemptCounter");this.graph=new Il.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Fe;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 o=e[c];if(!o){console.error("Previous outbox item was undefined");continue}o.payload.uuid!==a.payload.uuid&&o.payload.blocks.some(d=>a.payload.blockers.includes(d))&&Fe._addDependency(a.payload.uuid,o.payload.uuid,s.graph)}}return s}_addDependency(e,s){Fe._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 Bf=(t,e)=>{const s=new e(t);return Sf(s),gf(t),s};class F extends sl{constructor(s,n){super(s);A(this,"auth");this.auth=n}}class Gf extends F{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(cn(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(rn(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(on(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(an(s))}}class q extends F{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:o,formRevisionAttachmentReducer:d,formSubmissionAttachmentReducer:m,geoImageReducer:r,assetTypeFieldsAttachmentReducer:h,assetTypeFieldValuesAttachmentReducer:f,issueTypeFieldsAttachmentReducer:p,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(n.instances),Object.values(a.instances),Object.values(c.instances),Object.values(o.instances),Object.values(d.instances),Object.values(m.instances),Object.values(r.instances),Object.values(h.instances),Object.values(f.instances),Object.values(p.instances),Object.values(y.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 ge(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 pe extends q{async _bulkAdd(e){var r;const{store:s}=this.client,n=(r=s.getState().userReducer.currentUser)==null?void 0:r.id,a=new Date().toISOString(),c=[],o=[],d={};for(const h of e){const{modelId:f,file:p}=h,y=await this.getFilePayload(p);y.sha1 in d||(d[y.sha1]=y);const T=this.buildOfflineAttachment({file:p,file_sha1:y.sha1,submitted_at:a,created_by:n,description:"",modelId:f});c.push(T),o.push(this.buildAttachmentPayload({offline_id:T.offline_id,file_name:T.file_name,file_sha1:T.file_sha1,file_extension:y.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:o,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: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 Lf extends pe{constructor(){super(...arguments);A(this,"name","Asset Attachment");A(this,"url","/asset-attachments");A(this,"initializeAttachments",_t);A(this,"addAttachments",It);A(this,"updateAttachments",hn);A(this,"removeAttachments",Rt);A(this,"removeAttachment",mn);A(this,"setAttachment",un);A(this,"selectAttachment",yn)}buildOfflineAttachment(s){return R({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(_t(n))}}function Mi(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class Nf extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(Ot(c));const o=this.enqueueRequest({description:"Create asset",method:l.POST,url:"/assets/",payload:v(c),blockers:[c.asset_type],blocks:[c.offline_id]});return o.then(d=>{this.dispatch(ve(d))}).catch(()=>{this.dispatch(wt(c.offline_id))}),[c,o]}update(e){const{store:s}=this.client,n=Pt(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(ve(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(o=>{this.dispatch(ve(o))}).catch(()=>{this.dispatch(ve(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Pt(e)(n);if(!a)throw new Error(`No asset with id ${e} found in the store`);const c=An(e)(n),o=$c(e)(n),d=no(e)(n);if(this.dispatch(wt(e)),c.length>0){const m=c.map(({offline_id:r})=>r);this.dispatch(Rt(m))}if(o.length>0){const m=o.map(({offline_id:r})=>r);this.dispatch(Qe(m))}if(d.length>0){const m=d.map(({offline_id:r})=>r);this.dispatch(Ds(m))}return this.enqueueRequest({description:"Delete asset",method:l.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(Ot(a)),this.dispatch(It(c)),this.dispatch(Ze(o)),this.dispatch(Cs(d)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),o=O.v4(),d=Mi(e,a).map(h=>{const f=h.map(p=>R(p));return{batchId:O.v4(),payload:{transaction_id:o,submitted_at:c,asset_type:s,project:n,assets:f}}}),m=[];let r=null;for(const h of d){const{batchId:f,payload:p}=h,y=p.assets.map(j=>j.offline_id),T=[s];r&&T.push(r);const _=y;_.push(f);const b=this.enqueueRequest({description:"Batch create assets",method:l.POST,url:"/assets/bulk/",payload:p,blockers:T,blocks:_});r=h.batchId,m.push(b)}return Promise.all(m).then(h=>{const f=h.flat();this.dispatch(vt(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(Tn(s))}}class Hf extends F{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Ct(c));const o=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 o.then(d=>{this.dispatch(On(d))}).catch(()=>{this.dispatch(Dt(c.offline_id))}),[c,o]}delete(e){const{store:s}=this.client,n=wn(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with id ${e} to exist`);this.dispatch(Dt(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(Ct(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.id,c=e.map(r=>R(r)),o=c.map(r=>({...r,created_by:a,submitted_at:n})),d=o.map(({offline_id:r})=>r);this.dispatch(kt(o));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(r=>r.asset),...e.map(r=>r.stage)],blocks:d});return m.then(r=>{this.dispatch(vn(r))}).catch(()=>{this.dispatch(Mt(d))}),[o,m]}bulkDelete(e){const{store:s}=this.client,n=En(e)(s.getState());this.dispatch(Mt(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(kt(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(Fn(s))}}class Wf extends F{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.id,c=e.map(m=>R(m)),o=c.map(m=>({...m,asset_type:s,created_by:a,submitted_at:n}));this.dispatch(Ue(o));const d=this.enqueueRequest({description:"Add asset stages",method:l.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_type:s,stages:c},blockers:[s],blocks:c.map(({offline_id:m})=>m)});return d.then(m=>{this.dispatch(Ve(m))}).catch(()=>{this.dispatch($e(o.map(({offline_id:m})=>m)))}),[o,d]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=$t(e.map(({offline_id:o})=>o))(a);return this.dispatch(Ve(e)),this.enqueueRequest({description:"Edit asset stages",method:l.PATCH,url:`/asset-types/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({offline_id:o})=>o)}).catch(o=>{throw this.dispatch(Ve(c)),o})}async bulkDelete(e){const{store:s}=this.client,n=$t(e)(s.getState());this.dispatch($e(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(Ue(n))}),a}update(e){const{store:s}=this.client,n=Dn(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(Vt(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(o=>{this.dispatch(Vt(o))}).catch(()=>{this.dispatch(Cn(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(qn(s))}}class Kf extends pe{constructor(){super(...arguments);A(this,"name","Asset Type Attachment");A(this,"url","/asset-type-attachments");A(this,"addAttachments",Gt);A(this,"updateAttachments",Bn);A(this,"removeAttachments",Lt);A(this,"removeAttachment",Gn);A(this,"setAttachment",$n);A(this,"selectAttachment",Hn)}buildOfflineAttachment(s){return R({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(Vn(n))}}class Yf extends q{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=[],o=[];for(const r of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.extension,file_sha1:y.sha1,fields_revision:h};o.push(_)}this.dispatch(Xn(c));const d=this.enqueueRequest({description:"Add asset type fields attachments",method:l.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.fields_revision),blocks:c.map(r=>r.offline_id)});return d.then(r=>{this.processPresignedUrls(r.presigned_urls),this.dispatch(Zn(r.attachments))}).catch(()=>{this.dispatch(Qn(c.map(r=>r.offline_id)))}),[c,d.then(({attachments:r})=>r)]}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(Jn(s))}}class Jf extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(na(c));const o=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 o.then(m=>{this.dispatch(aa(m))}).catch(m=>{throw this.dispatch(ca(c.offline_id)),m}),[c,o]}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(ia(s))}}class Xf extends q{async bulkAdd(e,s){var r;const n=new Date().toISOString(),a=(r=this.client.store.getState().userReducer.currentUser)==null?void 0:r.id,c=Mi(e,s??e.length),o=[],d=[];for(const h of c){const f={},p=[];for(const y of h){const{fieldValuesId:T,fieldIdentifier:_,file:b}=y,j=await this.getFilePayload(b);j.sha1 in f||(f[j.sha1]=j);const ae=R({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:j.sha1,created_by:a,field_values:T,submitted_at:n,field_identifier:_});o.push(ae);const gl={offline_id:ae.offline_id,file_name:b.name,file_sha1:j.sha1,file_extension:j.extension,field_identifier:_,field_values:T};p.push(gl)}d.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(Le(o));const m=d.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(ua(f))}).catch(h=>{throw this.dispatch(Ne(o.map(f=>f.offline_id))),h}),[o,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ma(e)(n);this.dispatch(Ne(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(Le(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(la(s))}}const Zf=t=>Array.isArray(t)&&t[0]instanceof File,zi=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:Zf(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class Qf extends q{add(e){var o;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(o=n.userReducer.currentUser)==null?void 0:o.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(Is(a)),c.then(d=>(this.dispatch(Xe(d)),d)).catch(()=>{this.dispatch(Rs(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=vs(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(zc(c));const o=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 o.then(d=>{this.dispatch(Xe(d))}).catch(()=>{this.dispatch(Xe(a))}),[c,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=vs(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Cc(e)(n);this.dispatch(Rs(e)),this.dispatch(Je(c.map(o=>o.offline_id)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:l.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(Is(a)),this.dispatch(Ye(c)),o}}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(Mc(s))}}class xf extends F{add(e){var o;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(o=n.userReducer.currentUser)==null?void 0:o.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(Jt(a)),c.then(d=>(this.dispatch(we(d)),d)).catch(()=>{this.dispatch(Xt(a.offline_id))}),[a,c]}bulkAdd(e,s){var r;const n=new Date().toISOString(),{values:a}=zi(e.values),c=[],o=Mi(e.payloads,s??e.payloads.length),d=[];for(const h of o){const f=[];for(const p of h){const y=R({...p,values:zi(p.values).values,created_by:(r=this.client.store.getState().userReducer.currentUser)==null?void 0:r.id,submitted_at:n});c.push(y),f.push({offline_id:y.offline_id,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:y.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(_=>_.asset),p=h.field_values.map(_=>_.fields_revision),y=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:y});m.push(T)}return Promise.all(m).then(h=>{this.dispatch(Sa(h.flat()))}).catch(()=>{this.dispatch(Ta(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Qt(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(we(c));const o=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 o.then(d=>{this.dispatch(we(d))}).catch(()=>{this.dispatch(we(a))}),[c,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Qt(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=fa(e)(n);this.dispatch(Xt(e)),this.dispatch(Ne(c.map(o=>o.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(o){throw this.dispatch(Jt(a)),this.dispatch(Le(c)),o}}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(Aa(s))}}class ep extends F{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(es(c));const o=this.enqueueRequest({description:"Create asset type",method:l.POST,url:"/asset-types/",payload:v(c),blockers:[],blocks:[c.offline_id]});return o.then(d=>{this.dispatch(Ee(d))}).catch(()=>{this.dispatch(ts(c.offline_id))}),[c,o]}update(e){const{store:s}=this.client,n=is(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(Ee(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(o=>{this.dispatch(Ee(o))}).catch(()=>{this.dispatch(Ee(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=is(e)(n);if(!a)throw new Error(`Expected asset type with offline_id ${e} to exist`);const c=jt(e)(n),o=zn(e)(n),d=Wn(e)(n);return this.dispatch(ts(e)),this.dispatch(bn(c.map(m=>m.offline_id))),this.dispatch($e(o.map(m=>m.offline_id))),this.dispatch(Lt(d.map(({offline_id:m})=>m))),this.enqueueRequest({description:"Delete asset type",method:l.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(es(a)),this.dispatch(vt(c)),this.dispatch(Ue(o)),this.dispatch(Gt(d)),m})}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(Ra(s))}}class tp extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(as(c));const o=this.enqueueRequest({description:"Create Category",method:l.POST,url:"/categories/",payload:v(c),blockers:[e.project.toString()],blocks:[c.offline_id]});return[c,o]}update(e){const s=this.client.store.getState(),n=os(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(Pa(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=os(e)(s.getState());if(!n)throw new Error(`No category with id ${e} found in the store`);this.dispatch(qa(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(as(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(ja(s))}}class sp extends pe{constructor(){super(...arguments);A(this,"name","Document Attachment");A(this,"url","/document-attachments");A(this,"addAttachments",Ma);A(this,"updateAttachments",Ua);A(this,"removeAttachments",$a);A(this,"removeAttachment",Va);A(this,"setAttachment",za);A(this,"selectAttachment",La)}buildOfflineAttachment(s){return R({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(),o=[],d=[],m={},r={};for(const p of s){const{documentId:y,file:T}=p,_=await this.getFilePayload(T);_.sha1 in m||(m[_.sha1]=_,r[_.sha1]=[]);const b=this.buildOfflineAttachment({file:T,file_sha1:_.sha1,submitted_at:c,created_by:a,description:"",modelId:y});o.push(b),d.push({offline_id:b.offline_id,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:_.extension,description:b.description,document:y}),r[_.sha1].push(b.offline_id)}this.dispatch(this.addAttachments(o));const h=this.enqueueRequest({description:"Attach files to document",method:l.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:d,files:Object.values(m)},blocks:o.map(p=>p.offline_id),blockers:o.map(p=>p.file_sha1)});return h.then(({attachments:p,presigned_urls:y})=>{this.dispatch(this.updateAttachments(p));const T=this.processPresignedUrls(y);for(const[_,b]of Object.entries(T))b.then(()=>{const j=r[_];for(const ae of j)this.makeReadable(ae)})}).catch(()=>{this.dispatch(this.removeAttachments(o.map(p=>p.offline_id)))}),[o,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(Da(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 ip extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(Ka([c]));const o=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 o.catch(()=>{this.dispatch(ls([c.offline_id]))}),[c,o]}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(oe([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(()=>{oe([n])}),[a,c]}move(e,s,n){const{store:a}=this.client,c=Se(a.getState()),o=[],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(o.push(d),d.parent_document&&o.push(c[d.parent_document]),s){const r=c[s];if(!r)throw new Error(`attempting to move a document to target with offline_id ${s} that does not exist in store.documents`);o.push(r),r.parent_document&&o.push(c[r.parent_document])}this.dispatch(Ya({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(r=>{this.dispatch(oe(r))}).catch(()=>{this.dispatch(oe(o))}),m}delete(e){const{store:s}=this.client,n=Se(s.getState()),a=Xa(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(ls([e]));const o=this.enqueueRequest({description:"Delete Document",method:l.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return o.then(d=>{this.dispatch(oe(d))}).catch(()=>{this.dispatch(oe([a])),c&&this.dispatch(oe([c]))}),o}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(Wa([...await n,...await a]))}}class np extends F{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(ec(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(xa(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(Qa(s))}}class ap extends F{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 dt={},Ui=new Set;let lt=0,Vi=0,$i=0;const cp=20;class op extends F{constructor(){super(...arguments);A(this,"host");A(this,"_dbPromise",Rl.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 gt(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:l.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await ge(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(cc({sha1:s,...c})),c}async addCache(s,n){if(Ui.has(n))return;if(!s.type){const o=s.name.split("."),d=o[o.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),lt++):(await a.put("files",s,n),Vi++),Ui.add(n),$i++,$i%cp===0&&console.debug(`File cache summary: ${lt} hits and ${Vi} misses, ${lt/(lt+Vi)*100}% hit rate over ${$i} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),Ui.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return oc(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 gt(n,s),c={file_name:n.name,file_sha1:s,file:a},o=await this.getOrRenewUploadUrl(s);if("warning"in o){if(o.warning==="already_uploaded")return[c,Promise.resolve(void 0).then()];throw new Error(o.warning)}const d=o.url,m=this.enqueueRequest({url:d,description:"Upload file",method:l.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${a}`],blocks:[s],s3url:o});return[c,m]}async fetchFileFromUrl(s,n,a){const c=s.split("?")[0]??s,o=await this.fetchCache(n);if(o){if(!o.name)throw new Error("Cached file unexpectedly has no name.");return o}if(s.startsWith("blob:")){const h=await Qi(s),f=new File([h],a??n,{type:h.type});return await this.addCache(f,n),f}let d=dt[c],m=!0;d?m=!1:(d=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)})}),dt[c]=d);let r;try{r=await d}catch(h){throw m&&h instanceof P&&delete dt[c],h}if(m){const h=await ge(r);if(h!==n){const y=`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(y)}const f=r.type.split("/")[1];if(!f)throw new Error("File has no extension");const p=a??h+"."+f;if(r=Ji(r,p),!r.name)throw new Error("Failed to set file's name");await this.addCache(r,h),ct[c]=new Promise(y=>{y(r)})}return r}}class kf extends P{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=[],o=[];for(const r of e){const{revisionId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.extension,file_sha1:y.sha1,form_revision:h};o.push(_)}this.dispatch(ac(c));const d=this.enqueueRequest({description:"Attach files to form revision",method:l.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.form_revision),blocks:c.map(r=>r.offline_id)});return d.then(r=>{this.processPresignedUrls(r.presigned_urls),this.dispatch(cc(r.attachments))}).catch(()=>{this.dispatch(oc(c.map(r=>r.offline_id)))}),[c,d.then(({attachments:r})=>r)]}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(nc(s))}}class Df extends P{add(e){var d;const{store:s}=this.client,a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=R({...e,created_by:a,revision:"Pending",submitted_at:new Date().toISOString()});this.dispatch(ps(c));const o=this.enqueueRequest({description:"Create form revision",method:l.POST,url:"/form-revisions/",payload:c,blockers:[e.form],blocks:[c.offline_id]});return o.then(m=>{this.dispatch(uc(m))}).catch(()=>{this.dispatch(ys(c.offline_id))}),[c,o]}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(hc(s))}}const Cf=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 o of a){if(o.image){if(o.image instanceof Promise)try{e[o.identifier]=await o.image}catch(d){console.error("Failed to get image from promise",d)}else e[o.identifier]=o.image;delete o.image}c.push(o)}s.push({...n,fields:c})}return{fields:s,images:e}};class Mf extends P{add(e,s){var r;const{store:n}=this.client,a=new Date().toISOString(),c=(r=n.getState().userReducer.currentUser)==null?void 0:r.id,o=R({...e,submitted_at:a,created_by:c}),d=R({...s,form:o.offline_id,revision:"Pending",submitted_at:a,created_by:c});this.dispatch(gs(o)),this.dispatch(ps(d));const m=this.enqueueRequest({description:"Create form",method:l.POST,url:"/forms/",payload:{...o,initial_revision:{offline_id:d.offline_id,submitted_at:d.submitted_at,title:d.title,description:d.description,fields:d.fields}},blockers:[],blocks:[o.offline_id,d.offline_id]});return m.catch(h=>{throw this.dispatch(Ss(o.offline_id)),this.dispatch(ys(d.offline_id)),h}),[o,d,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Ic(e)(n);if(!a)throw new Error("Expected form to exist");const c=kc(e)(n);c.length>0&&this.dispatch(Je(c.map(({offline_id:d})=>d)));const o=Ac(e)(n);o.length>0&&this.dispatch(fc(o.map(({offline_id:d})=>d))),this.dispatch(Ss(e));try{return await this.enqueueRequest({description:"Delete form",method:l.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(d){throw this.dispatch(gs(a)),o.length>0&&this.dispatch(mc(o)),c.length>0&&this.dispatch(Ke(c)),d}}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(Tc(s))}}class zf extends P{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=[],o=[];for(const r of e){const{submissionId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.sha1,file_extension:y.extension,field_identifier:f,form_submission:h};o.push(_)}this.dispatch(He(c));const d=this.enqueueRequest({description:"Attach files to form submission",method:l.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.form_submission),blocks:c.map(r=>r.offline_id)});return d.then(r=>{this.processPresignedUrls(r.presigned_urls),this.dispatch(Oc(r.attachments))}).catch(r=>{throw this.dispatch(We(c.map(h=>h.offline_id))),r}),[c,d.then(({attachments:r})=>r)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=vc(e)(n);this.dispatch(We(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(He(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(Fc(s))}}class Uf extends P{async add(e){var f;const{store:s}=this.client,{file:n,...a}=e,c=new Date().toISOString(),o=(f=s.getState().userReducer.currentUser)==null?void 0:f.id,d=a.project,m=await this.getFilePayload(n),r=R({...a,file_name:n.name,file_sha1:m.sha1,file:URL.createObjectURL(n),submitted_at:c,created_by:o});this.dispatch($c(r));const h=this.enqueueRequest({description:"Add geo image",method:l.POST,url:"/geo-images/",payload:{offline_id:r.offline_id,submitted_at:c,title:r.title,description:r.description,geo_marker:r.geo_marker,canvas_marker:r.canvas_marker,sha1:r.file_sha1,project:r.project,file_name:r.file_name,direction:r.direction,original_date:r.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(Es(r.offline_id))}),[r,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,o=[],d=[],m=[],r={};for(const p of e){const{file:y,...T}=p,_=await this.getFilePayload(y);_.sha1 in r||(r[_.sha1]=_);const b=R({...T,file_name:y.name,file_sha1:_.sha1,file:URL.createObjectURL(y),submitted_at:a,created_by:c,project:s});o.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(Bc(o));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(r)},blocks:[s.toString()],blockers:d});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(Vc(p.geo_images))}).catch(()=>{this.dispatch(Lc(d))}),[o,h.then(p=>p.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=js(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(Gc(c));const o=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 o.then(d=>{this.dispatch(ve(d))}).catch(()=>{this.dispatch(ve(a))}),[c,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=js(e)(n);if(!a)throw new Error(`Map image with offline_id ${e} does not exist in the store`);this.dispatch(Es(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(ve(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(Uc(s))}}class Vf extends F{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=R({...e,submitted_at:n,created_by:a});this.dispatch(qs(c));const o=this.enqueueRequest({description:"Add issue association",method:l.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 o.then(m=>{this.dispatch(Jc(m))}).catch(()=>{this.dispatch(Ds(c.offline_id))}),[c,o]}async delete(e){const{store:s}=this.client,n=Xc(e)(s.getState());if(!n)throw new Error(`Issue association with id ${e} not found in store.`);this.dispatch(Ds(e));const a=this.enqueueRequest({description:"Delete issue association",method:l.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(qs(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(Kc(s))}}class $f extends ke{constructor(){super(...arguments);A(this,"name","Issue Attachment");A(this,"url","/issue-attachments");A(this,"addAttachments",zs);A(this,"updateAttachments",no);A(this,"removeAttachments",Us);A(this,"removeAttachment",ao);A(this,"setAttachment",io);A(this,"selectAttachment",ro)}buildOfflineAttachment(s){return R({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(so(n))}}class Bf extends F{add(e){var c;const{store:s}=this.client,n=R({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Gs(n));const a=this.enqueueRequest({description:"Add issue comment",method:l.POST,url:"/issue-comments/",payload:n,blockers:[e.issue],blocks:[n.offline_id]});return a.catch(()=>{this.dispatch(Ls(n.offline_id))}),[n,a]}update(e){const{store:s}=this.client,n=fo(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(Bs(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(Bs(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(Ls(e));const n=this.enqueueRequest({description:"Delete comment",method:l.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Gs(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(ho(s))}}class Gf extends F{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,o=R({...e,submitted_at:a,created_by:c});this.dispatch(Hs(o));const d=this.enqueueRequest({description:"Create issue",method:l.POST,url:"/issues/",payload:o,blockers:["add-issue",o.project.toString()],blocks:[o.offline_id]});return d.then(r=>{this.dispatch(Xe(r))}).catch(r=>{throw this.dispatch(Ws(o.offline_id)),r}),[o,d]}update(e){var m;const s=this.client.store.getState(),n=Ys(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(Xe(a));const c={};for(const r of[v.TITLE,v.DESCRIPTION,v.STATUS,v.CATEGORY,v.PRIORITY,v.ASSIGNED_TO,v.DUE_DATE])if(r in e&&e[r]!==n[r])switch(r){case v.PRIORITY:case v.STATUS:{const h=e[r];c[r]=h!==void 0?Number(h):null;break}case v.DUE_DATE:case v.DESCRIPTION:case v.TITLE:c[r]=e[r]??null;break;case v.CATEGORY:{let h=null;const f=e[r];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[r]=h?{name:h.name,color:h.color,offline_id:h.offline_id}:null;break}case v.ASSIGNED_TO:{let h=null;const f=e[r];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[r]=h?{full_name:h.username,id:h.id}:null;break}}const o=R({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:n.offline_id,changes:c});this.dispatch(ir(o));const d=this.enqueueRequest({description:"Edit issue",method:l.PATCH,url:`/issues/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return d.catch(()=>{this.dispatch(Xe(n)),this.dispatch(ar(o.offline_id))}),[a,d]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Ys(e)(n);if(!a)throw new Error(`No issue with id ${e} found in the store`);const c=oo(e)(n),o=rr(e)(n),d=Dc(e)(n),m={};for(const h of Zc(e)(n))m[h.offline_id]=h;for(const h of Qc(e)(n))m[h.offline_id]=h;const r=Object.values(m);this.dispatch(Ws(e)),c.length>0&&this.dispatch(Us(c.map(({offline_id:h})=>h))),o.length>0&&this.dispatch(cr(o.map(({offline_id:h})=>h))),d.length>0&&this.dispatch(Je(d.map(({offline_id:h})=>h))),r.length>0&&this.dispatch(Cs(r.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(Hs(a)),this.dispatch(zs(c)),this.dispatch(nr(o)),this.dispatch(Ke(d)),this.dispatch(ks(r)),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(Ao(s))}}class Lf extends P{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=[],o=[];for(const r of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.extension,field_identifier:f,file_sha1:y.sha1,fields_revision:h};o.push(_)}this.dispatch(Ro(c));const d=this.enqueueRequest({description:"Add issue type fields attachments",method:l.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.fields_revision),blocks:c.map(r=>r.offline_id)});return d.then(r=>{this.processPresignedUrls(r.presigned_urls),this.dispatch(Fo(r.attachments))}).catch(()=>{this.dispatch(Oo(c.map(r=>r.offline_id)))}),[c,d.then(({attachments:r})=>r)]}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(Io(s))}}class Nf extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(Mo(c));const o=this.enqueueRequest({description:"Add Issue Type Fields",method:l.POST,url:"/issue-type-fields/",payload:c,blockers:[c.issue_type],blocks:[c.offline_id]});return o.then(m=>{this.dispatch(zo(m))}).catch(m=>{throw this.dispatch(Uo(c.offline_id)),m}),[c,o]}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(Co(s))}}class Hf extends P{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=[],o=[];for(const r of e){const{fieldValuesId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.sha1,file_extension:y.extension,field_identifier:f,field_values:h};o.push(_)}this.dispatch(Qe(c));const d=this.enqueueRequest({description:"Add issue type field values attachments",method:l.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.field_values),blocks:c.map(r=>r.offline_id)});return d.then(({presigned_urls:r,attachments:h})=>{this.processPresignedUrls(r),this.dispatch(Lo(h))}).catch(r=>{throw this.dispatch(xe(c.map(h=>h.offline_id))),r}),[c,d.then(({attachments:r})=>r)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Ho(e)(n);this.dispatch(xe(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(Qe(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(Go(s))}}class Wf extends F{add(e){var o;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(o=n.userReducer.currentUser)==null?void 0:o.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:l.POST,url:"/issue-type-field-values/",payload:a,blockers:[e.issue,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(Xs(a)),c.then(d=>(this.dispatch(Ee(d)),d)).catch(()=>{this.dispatch(Zs(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=xs(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(Ee(c));const o=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 o.then(d=>{this.dispatch(Ee(d))}).catch(()=>{this.dispatch(Ee(a))}),[c,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=xs(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Wo(e)(n);this.dispatch(Zs(e)),this.dispatch(xe(c.map(o=>o.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(o){throw this.dispatch(Xs(a)),this.dispatch(Qe(c)),o}}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(Po(s))}}class Yf extends F{add(e){var o;const{store:s}=this.client,n=s.getState(),a=R({...e,submitted_at:new Date().toISOString(),created_by:(o=n.userReducer.currentUser)==null?void 0:o.id});this.dispatch(Xo(a));const c=this.enqueueRequest({method:l.POST,url:"/issue-types/",payload:a,blockers:[],blocks:[a.offline_id]});return c.then(d=>{this.dispatch(je(d))}).catch(()=>{this.dispatch(ni(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=ai(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(Zo(c));const o=this.enqueueRequest({method:l.PATCH,url:`/issue-types/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return o.then(d=>{this.dispatch(je(d))}).catch(()=>{this.dispatch(je(a))}),[c,o]}delete(e){const{store:s}=this.client,n=s.getState(),a=ai(e)(n);if(!a)throw new Error(`IssueType with offline_id ${e} does not exist in the store.`);const c=ci(e)(n);this.dispatch(ni(e)),this.dispatch(So(c.map(d=>d.offline_id)));const o=this.enqueueRequest({method:l.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return o.catch(()=>{this.dispatch(je(a)),this.dispatch(go(c))}),o}async refreshStore(e){const s=await this.enqueueRequest({method:l.GET,url:"/issue-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Jo(s))}}class Kf extends F{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(sr(s))}}class Jf extends jd{constructor(e){super(e)}}const Xf=1800;function Zf(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 Qf extends Jf{constructor(){super(...arguments);A(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(_a(!1)),this.clearTokens(),this.dispatch({type:xd.RESET_STATE}),this.dispatch({type:Ud})}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=el(s).exp??n}catch{a=n}return a-n<Xf}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??Te).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:l.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(a=>{this.setTokens(Zf(a))})}}class xf extends F{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(te(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(te(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(te(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(te(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(te(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(te(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 o of a)n[o.offline_id]=o;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 o of c)n[o.offline_id]=o;this.dispatch(ur(Object.values(n)))}}class ep extends F{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(Tr(e))}),s}async remove(e){return this.dispatch(br(e.offline_id)),this.dispatch(yr(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(Sr(s))}}class tp extends F{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 o of a)n[o.id]=o;const c=await this.enqueueRequest({description:"Get organization",method:l.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.id]=c,this.dispatch($r(Object.values(n)))}}class sp extends F{async update(e){return this.dispatch(Fr(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(Or(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(mi(s))}}class ip extends ke{constructor(){super(...arguments);A(this,"name","Project Attachment");A(this,"url","/project-attachments");A(this,"addAttachments",ed);A(this,"updateAttachments",id);A(this,"removeAttachments",Si);A(this,"removeAttachment",nd);A(this,"setAttachment",td);A(this,"selectAttachment",cd)}buildOfflineAttachment(s){return R({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(xr(n))}}class np extends F{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(_i(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,r)=>{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(r)});const d=Promise.resolve(c).then(m=>this.enqueueRequest(m));return d.then(m=>{this.dispatch(_i(m))}),this.dispatch(yd),this.dispatch(pd(null)),this.dispatch(fd(!1)),[a,d]}delete(e){return this.dispatch(hd(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(ld(s))}}class ap extends F{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(kr(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=at(n),c=a[e];if(!c)throw new Error("Expected project to exist");const o=gd(n).filter(h=>h.project===e);this.dispatch(md(o.map(({offline_id:h})=>h)));const d=od(c.id)(n);this.dispatch(Si(d.map(({offline_id:h})=>h)));const m=wr(n);this.dispatch(vr(m.map(({offline_id:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(Dr(c));const r=hr(c.id)(n);r&&this.dispatch(te({...r,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(qr(Object.values(a))),this.dispatch(mi(Object.values(m))),this.dispatch(ud(o)),this.dispatch(sd(d)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),r&&this.dispatch(te({...r,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(Cr(e))})}}class cp extends F{add(e){const s=R({...e,submitted_at:new Date().toISOString()});this.dispatch(Id(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(ge(a))}).catch(()=>{this.dispatch(Oi(s.offline_id))}),[s,n]}update(e){const{store:s}=this.client,n=Se(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(Fi(a));const c=this.enqueueRequest({description:"Update team",method:l.PATCH,url:`/organizations/teams/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(o=>{this.dispatch(ge(o))}).catch(()=>{this.dispatch(ge(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Se(e)(n);if(!a)throw new Error(`Expected team with id ${e} to exist`);this.dispatch(Oi(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(ge(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=Se(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(Fi({...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(ge(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=Se(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=Se(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=a.members.filter(o=>!s.includes(o));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(_d(s))}}class op extends F{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 o of a)n[o.id]=o;const c=await this.enqueueRequest({description:"Fetch project users",method:l.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const o of c)n[o.id]=o;this.dispatch(pr(Object.values(n)))}}var Nd=(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))(Nd||{});i.APIError=j,i.AgentService=mf,i.AssetAttachmentService=ff,i.AssetService=pf,i.AssetStageCompletionService=yf,i.AssetStageService=Af,i.AssetTypeAttachmentService=gf,i.AssetTypeFieldValuesAttachmentService=bf,i.AssetTypeFieldValuesService=Rf,i.AssetTypeFieldsAttachmentService=Sf,i.AssetTypeFieldsService=Tf,i.AssetTypeService=Ff,i.AttachmentModel=Bi,i.BaseApiService=F,i.BaseSDK=uf,i.CategoryService=Of,i.DEFAULT_ISSUE_PRIORITY=sl,i.DEFAULT_ISSUE_STATUS=tl,i.DeferredPromise=Wi,i.DocumentAttachmentService=vf,i.DocumentService=wf,i.EMPTY_ARRAY=Vi,i.EMPTY_OBJECT=$i,i.EmailDomainsService=Ef,i.EmailVerificationService=jf,i.FileService=qf,i.FormRevisionAttachmentService=kf,i.FormRevisionService=Df,i.FormService=Mf,i.FormSubmissionAttachmentService=zf,i.FormSubmissionService=If,i.GeoImageService=Uf,i.HttpMethod=l,i.IssueAssociationService=Vf,i.IssueAttachmentService=$f,i.IssueCommentService=Bf,i.IssuePriority=lt,i.IssueService=Gf,i.IssueStatus=ut,i.IssueTypeFieldValuesAttachmentService=Hf,i.IssueTypeFieldValuesService=Wf,i.IssueTypeFieldsAttachmentService=Lf,i.IssueTypeFieldsService=Nf,i.IssueTypeService=Yf,i.IssueUpdateChange=v,i.IssueUpdateService=Kf,i.JWTService=Qf,i.LicenseLevel=Li,i.LicenseService=xf,i.LicenseStatus=Ni,i.OUTBOX_RETRY_DELAY=Hi,i.OrganizationAccessLevel=dt,i.OrganizationAccessService=ep,i.OrganizationService=tp,i.OutboxCoordinator=be,i.PaddleCheckoutEvent=Gi,i.ProjectAccessLevel=rt,i.ProjectAccessService=sp,i.ProjectAttachmentService=ip,i.ProjectFileService=np,i.ProjectService=ap,i.TeamService=cp,i.UNKNOWN_ERROR_MESSAGE=Te,i.UserService=op,i.VERSION_REDUCER_KEY=Ei,i.VerificationCodeType=Nd,i._selectLatestFormRevision=yc,i._setLatestRetryTime=Xr,i.acceptProjectInvite=Cr,i.addAsset=Rt,i.addAssetAttachment=Ol,i.addAssetAttachments=Tt,i.addAssetStage=zl,i.addAssetStageCompletion=Pt,i.addAssetStageCompletions=qt,i.addAssetStages=Ce,i.addAssetType=xt,i.addAssetTypeAttachment=$l,i.addAssetTypeAttachments=$t,i.addAssetTypeFieldValues=Kt,i.addAssetTypeFieldValuesAttachment=au,i.addAssetTypeFieldValuesAttachments=$e,i.addAssetTypeFieldValuesMany=ma,i.addAssetTypeFields=xn,i.addAssetTypeFieldsAttachment=Nl,i.addAssetTypeFieldsAttachments=Hn,i.addAssetTypeFieldsMany=Zl,i.addAssetTypes=Au,i.addAssets=Ft,i.addCategory=ns,i.addConversation=sn,i.addDocumentAttachment=Eu,i.addDocumentAttachments=Pa,i.addDocuments=Ba,i.addEmailDomain=Ya,i.addForm=gs,i.addFormRevision=ps,i.addFormRevisionAttachment=$u,i.addFormRevisionAttachments=ac,i.addFormRevisions=mc,i.addFormSubmission=Is,i.addFormSubmissionAttachment=eh,i.addFormSubmissionAttachments=He,i.addFormSubmissions=Ke,i.addForms=Xu,i.addGeoImage=$c,i.addGeoImages=Bc,i.addIssue=Hs,i.addIssueAssociation=qs,i.addIssueAssociations=ks,i.addIssueAttachment=mh,i.addIssueAttachments=zs,i.addIssueComment=Gs,i.addIssueComments=Ah,i.addIssueType=Xo,i.addIssueTypeFieldValues=Xs,i.addIssueTypeFieldValuesAttachment=Lh,i.addIssueTypeFieldValuesAttachments=Qe,i.addIssueTypeFieldValuesMany=wh,i.addIssueTypeFields=Mo,i.addIssueTypeFieldsAttachment=bh,i.addIssueTypeFieldsAttachments=Ro,i.addIssueTypeFieldsMany=Dh,i.addIssueUpdate=ir,i.addIssueUpdates=nr,i.addIssues=go,i.addLicenses=xh,i.addProjectAttachment=Rm,i.addProjectAttachments=ed,i.addProjectFile=Em,i.addProjectFiles=ud,i.addTeam=Id,i.addUsers=am,i.agentsReducer=cn,i.agentsSlice=yt,i.areArraysEqual=cl,i.assetAttachmentReducer=fn,i.assetAttachmentSlice=gt,i.assetReducer=Sn,i.assetSlice=It,i.assetStageCompletionReducer=On,i.assetStageCompletionSlice=jt,i.assetStageReducer=jn,i.assetStageSlice=Mt,i.assetTypeAttachmentReducer=Gn,i.assetTypeAttachmentSlice=Vt,i.assetTypeFieldValuesAttachmentReducer=la,i.assetTypeFieldValuesAttachmentSlice=Ht,i.assetTypeFieldValuesReducer=Aa,i.assetTypeFieldValuesSlice=Yt,i.assetTypeFieldsAttachmentReducer=Xn,i.assetTypeFieldsAttachmentSlice=Lt,i.assetTypeFieldsReducer=ia,i.assetTypeFieldsSlice=Nt,i.assetTypeReducer=Ta,i.assetTypeSlice=Qt,i.authReducer=Ia,i.authSlice=Ge,i.blobToBase64=pl,i.categoryReducer=wa,i.categorySlice=is,i.clearTokens=Iu,i.constructUploadedFilePayloads=fl,i.coordinatesAreEqual=al,i.createModelAdapter=I,i.createMultiPointGeometry=nl,i.createOfflineAction=Wr,i.createPointGeometry=il,i.deleteAsset=Ot,i.deleteAssetAttachment=ln,i.deleteAssetAttachments=bt,i.deleteAssetStage=Ul,i.deleteAssetStageCompletion=kt,i.deleteAssetStageCompletions=Dt,i.deleteAssetStages=ze,i.deleteAssetType=es,i.deleteAssetTypeAttachment=Un,i.deleteAssetTypeAttachments=Bt,i.deleteAssetTypeFieldValues=Jt,i.deleteAssetTypeFieldValuesAttachment=du,i.deleteAssetTypeFieldValuesAttachments=Be,i.deleteAssetTypeFieldValuesMany=pa,i.deleteAssetTypeFields=ta,i.deleteAssetTypeFieldsAttachment=Kl,i.deleteAssetTypeFieldsAttachments=Yn,i.deleteAssetTypeFieldsMany=tu,i.deleteAssetTypes=Su,i.deleteAssets=An,i.deleteCategory=va,i.deleteDocumentAttachment=Da,i.deleteDocumentAttachments=Ca,i.deleteEmailDomain=Ka,i.deleteForm=Ss,i.deleteFormRevision=ys,i.deleteFormRevisionAttachment=Nu,i.deleteFormRevisionAttachments=oc,i.deleteFormRevisions=fc,i.deleteFormSubmission=Rs,i.deleteFormSubmissionAttachment=nh,i.deleteFormSubmissionAttachments=We,i.deleteFormSubmissions=Je,i.deleteGeoImage=Es,i.deleteGeoImages=Lc,i.deleteIssue=Ws,i.deleteIssueAssociation=Ds,i.deleteIssueAssociations=Cs,i.deleteIssueAttachment=ao,i.deleteIssueAttachments=Us,i.deleteIssueComment=Ls,i.deleteIssueComments=gh,i.deleteIssueTypeFieldValues=Zs,i.deleteIssueTypeFieldValuesAttachment=Yh,i.deleteIssueTypeFieldValuesAttachments=xe,i.deleteIssueTypeFieldValuesMany=qh,i.deleteIssueTypeFields=Uo,i.deleteIssueTypeFieldsAttachment=Fh,i.deleteIssueTypeFieldsAttachments=Oo,i.deleteIssueTypeFieldsMany=Uh,i.deleteIssueUpdate=ar,i.deleteIssueUpdates=cr,i.deleteIssues=So,i.deleteOrganizationAccess=br,i.deleteProject=Dr,i.deleteProjectAccess=Or,i.deleteProjectAccesses=vr,i.deleteProjectAttachment=nd,i.deleteProjectAttachments=Si,i.deleteProjectFile=hd,i.deleteProjectFiles=md,i.deleteTeam=Oi,i.dequeue=$d,i.discard=qi,i.documentAttachmentReducer=Ua,i.documentAttachmentSlice=os,i.documentSlice=ds,i.documentsReducer=Ha,i.downloadFile=yl,i.downloadInMemoryFile=ml,i.emailDomainsReducer=Za,i.emailDomainsSlice=us,i.emailRegex=Il,i.enqueue=Vd,i.enqueueRequest=Kr,i.fallbackToEmptyArray=S,i.fallbackToEmptyObject=ae,i.fileReducer=sc,i.fileSlice=hs,i.fileToBlob=Xi,i.formReducer=bc,i.formRevisionAttachmentReducer=dc,i.formRevisionAttachmentSlice=ms,i.formRevisionReducer=gc,i.formRevisionsSlice=fs,i.formSlice=As,i.formSubmissionAttachmentReducer=Ec,i.formSubmissionAttachmentSlice=Ts,i.formSubmissionReducer=Mc,i.formSubmissionSlice=_s,i.geoImageReducer=Wc,i.geoImageSlice=ws,i.getFileIdentifier=hl,i.getFileS3Key=pt,i.getLocalDateString=Ki,i.getLocalRelativeDateString=ll,i.getOutboxCoordinator=ue,i.getRenamedFile=Ji,i.hashFile=fe,i.initSDK=hf,i.initializeAssetAttachments=St,i.initializeAssetStageCompletions=bn,i.initializeAssetStages=wn,i.initializeAssetTypeAttachments=Cn,i.initializeAssetTypeFieldValues=ha,i.initializeAssetTypeFieldValuesAttachments=aa,i.initializeAssetTypeFields=Qn,i.initializeAssetTypeFieldsAttachments=Nn,i.initializeAssetTypes=Sa,i.initializeAssets=yn,i.initializeCategories=Fa,i.initializeConversations=tn,i.initializeDocumentAttachments=ja,i.initializeEmailDomains=Wa,i.initializeFormRevisionAttachments=nc,i.initializeFormRevisions=hc,i.initializeFormSubmissionAttachments=Fc,i.initializeFormSubmissions=Pc,i.initializeForms=Tc,i.initializeGeoImages=Uc,i.initializeIssueAssociations=Kc,i.initializeIssueAttachments=so,i.initializeIssueTypeFieldValues=Po,i.initializeIssueTypeFieldValuesAttachments=Go,i.initializeIssueTypeFields=Co,i.initializeIssueTypeFieldsAttachments=Io,i.initializeIssueTypes=Jo,i.initializeIssueUpdates=sr,i.initializeIssues=Ao,i.initializeLicences=ur,i.initializeOrganizationAccesses=Sr,i.initializeProjectAccesses=mi,i.initializeProjectAttachments=xr,i.initializeProjectFiles=ld,i.initializeTeams=_d,i.isToday=dl,i.issueAssociationReducer=eo,i.issueAssociationSlice=Ps,i.issueAttachmentReducer=lo,i.issueAttachmentSlice=Ms,i.issueCommentReducer=po,i.issueCommentSlice=$s,i.issueReducer=bo,i.issueSlice=Ns,i.issueTypeFieldValuesAttachmentReducer=Yo,i.issueTypeFieldValuesAttachmentSlice=ti,i.issueTypeFieldValuesReducer=ko,i.issueTypeFieldValuesSlice=Js,i.issueTypeFieldsAttachmentReducer=Eo,i.issueTypeFieldsAttachmentSlice=Ks,i.issueTypeFieldsReducer=$o,i.issueTypeFieldsSlice=ei,i.issueTypeReducer=er,i.issueTypeSlice=ii,i.issueUpdateReducer=dr,i.issueUpdateSlice=oi,i.licenseReducer=mr,i.licenseSlice=ri,i.logOnlyOnce=Al,i.markAsDeleted=Jr,i.markForDeletion=Im,i.memoize=mt,i.moveDocument=Ga,i.offline=R,i.onlyUniqueHashes=_l,i.onlyUniqueOfflineIds=xi,i.organizationAccessReducer=Ir,i.organizationAccessSlice=li,i.organizationReducer=Hr,i.organizationSlice=yi,i.outboxReducer=Zr,i.outboxSlice=Ai,i.overmapEnhancer=xm,i.overmapReducers=Md,i.overmapRootReducer=Km,i.performRequest=Pi,i.projectAccessReducer=jr,i.projectAccessSlice=hi,i.projectAttachmentReducer=rd,i.projectAttachmentSlice=gi,i.projectFileReducer=Sd,i.projectFileSlice=bi,i.projectReducer=Mr,i.projectSlice=pi,i.rehydratedReducer=Td,i.rehydratedSlice=Ii,i.removeDocuments=ls,i.removeIssueType=ni,i.removeUser=yr,i.resetProjectFileObjectUrls=Pm,i.resetStore=Ud,i.restructureCreateSelectorWithArgs=g,i.saveActiveProjectFileBounds=yd,i.selectAccessToken=Ru,i.selectActiveOrganizationAccess=dm,i.selectActiveProjectFileId=km,i.selectActiveStatusLicenses=tm,i.selectAllDocumentAttachments=rs,i.selectAllProjectAttachments=Ti,i.selectAncestorIdsOfDocument=Cu,i.selectAssetAttachmentById=hn,i.selectAssetAttachmentMapping=un,i.selectAssetAttachments=_t,i.selectAssetById=Et,i.selectAssetStageById=Pn,i.selectAssetStageCompletionById=Rn,i.selectAssetStageCompletionMapping=Ct,i.selectAssetStageCompletionsByIds=Fn,i.selectAssetStages=qn,i.selectAssetStagesByIds=Ut,i.selectAssetTypeAttachmentById=$n,i.selectAssetTypeAttachmentMapping=Vn,i.selectAssetTypeAttachments=Gt,i.selectAssetTypeById=ss,i.selectAssetTypeFieldValues=Xt,i.selectAssetTypeFieldValuesAttachmentById=lu,i.selectAssetTypeFieldValuesAttachments=oa,i.selectAssetTypeFieldValuesAttachmentsByIds=ra,i.selectAssetTypeFieldValuesAttachmentsMapping=Wt,i.selectAssetTypeFieldValuesById=Zt,i.selectAssetTypeFieldValuesMapping=ya,i.selectAssetTypeFieldValuesOfAsset=mu,i.selectAssetTypeFields=Ve,i.selectAssetTypeFieldsAttachmentById=Xl,i.selectAssetTypeFieldsAttachments=Jn,i.selectAssetTypeFieldsAttachmentsMapping=Kn,i.selectAssetTypeFieldsById=nu,i.selectAssetTypeFieldsMapping=sa,i.selectAssetTypeFieldsOfAssetType=su,i.selectAssetTypeStagesMapping=Vl,i.selectAssetTypeValuesOfAssetType=fu,i.selectAssetTypes=Tu,i.selectAssetTypesByIds=bu,i.selectAssetTypesMapping=ts,i.selectAssets=gn,i.selectAssetsByIds=kl,i.selectAssetsMapping=vt,i.selectAssetsOfAssetType=wt,i.selectAttachmentsOfAsset=mn,i.selectAttachmentsOfAssetByType=El,i.selectAttachmentsOfAssetType=Bn,i.selectAttachmentsOfAssetTypeByType=Ll,i.selectAttachmentsOfAssetTypeFieldValues=da,i.selectAttachmentsOfAssetTypeFields=Jl,i.selectAttachmentsOfDocument=qu,i.selectAttachmentsOfDocumentByType=ku,i.selectAttachmentsOfFormRevision=Hu,i.selectAttachmentsOfFormSubmission=wc,i.selectAttachmentsOfIssue=oo,i.selectAttachmentsOfIssueByType=yh,i.selectAttachmentsOfIssueTypeFieldValues=Wo,i.selectAttachmentsOfIssueTypeFields=Oh,i.selectAttachmentsOfProject=od,i.selectAttachmentsOfProjectByType=Om,i.selectCategories=Ou,i.selectCategoriesByIds=vu,i.selectCategoryById=cs,i.selectCategoryMapping=as,i.selectCommentsOfIssue=Sh,i.selectCompletedStagesByAsset=Cl,i.selectConversation=Fl,i.selectConversationMapping=At,i.selectConversations=Rl,i.selectCurrentUser=st,i.selectDeletedRequests=bm,i.selectDocumentAttachmentById=za,i.selectDocumentAttachmentMapping=Ma,i.selectDocumentById=Na,i.selectDocuments=La,i.selectDocumentsByIds=Du,i.selectDocumentsMapping=pe,i.selectEmailDomains=Xa,i.selectEmailDomainsAsMapping=Ja,i.selectEmailDomainsOfOrganization=Uu,i.selectFilteredForms=xu,i.selectFormById=Ic,i.selectFormMapping=_c,i.selectFormRevisionAttachmentsMapping=rc,i.selectFormRevisionById=Yu,i.selectFormRevisionMapping=Ne,i.selectFormRevisions=pc,i.selectFormRevisionsOfForm=Ac,i.selectFormSubmissionAttachemntsByIds=vc,i.selectFormSubmissionAttachmentsMapping=bs,i.selectFormSubmissionById=vs,i.selectFormSubmissions=Os,i.selectFormSubmissionsMapping=Fs,i.selectFormSubmissionsOfAsset=Cc,i.selectFormSubmissionsOfForm=kc,i.selectFormSubmissionsOfIssue=Dc,i.selectForms=Qu,i.selectGeoImageById=js,i.selectGeoImageMapping=Nc,i.selectGeoImages=Hc,i.selectGeoImagesOfProject=rh,i.selectIsImportingProjectFile=Dm,i.selectIsLoggedIn=Fu,i.selectIssueAssociationById=Xc,i.selectIssueAssociationMapping=we,i.selectIssueAssociations=hh,i.selectIssueAssociationsOfAsset=xc,i.selectIssueAssociationsOfIssue=Qc,i.selectIssueAssociationsToIssue=Zc,i.selectIssueAttachmentById=ro,i.selectIssueAttachmentMapping=co,i.selectIssueAttachments=Vs,i.selectIssueById=Ys,i.selectIssueCommentById=fo,i.selectIssueCommentMapping=mo,i.selectIssueCountOfCategory=wu,i.selectIssueMapping=To,i.selectIssueTypeById=ai,i.selectIssueTypeFieldValues=Qs,i.selectIssueTypeFieldValuesAttachmentById=Kh,i.selectIssueTypeFieldValuesAttachments=No,i.selectIssueTypeFieldValuesAttachmentsByIds=Ho,i.selectIssueTypeFieldValuesAttachmentsMapping=si,i.selectIssueTypeFieldValuesById=xs,i.selectIssueTypeFieldValuesMapping=qo,i.selectIssueTypeFieldValuesOfIssue=kh,i.selectIssueTypeFields=Ze,i.selectIssueTypeFieldsAttachmentById=vh,i.selectIssueTypeFieldsAttachments=wo,i.selectIssueTypeFieldsAttachmentsMapping=vo,i.selectIssueTypeFieldsById=Gh,i.selectIssueTypeFieldsMapping=Vo,i.selectIssueTypeFieldsOfIssueType=Vh,i.selectIssueTypeMapping=Qo,i.selectIssueTypeValuesOfIssueType=Bh,i.selectIssueTypes=xo,i.selectIssueTypesByIds=Jh,i.selectIssueTypesOfOrganization=Xh,i.selectIssueUpdateMapping=or,i.selectIssueUpdatesOfIssue=rr,i.selectIssuesByIds=Th,i.selectIssuesOfIssueType=ci,i.selectIssuesOfIssueTypeCount=Zh,i.selectLatestAssetTypeFieldsOfAssetType=iu,i.selectLatestFormRevisionOfForm=Ku,i.selectLatestIssueTypeFieldsOfIssueType=$h,i.selectLatestRetryTime=_m,i.selectLicense=em,i.selectLicenseForProject=hr,i.selectLicenses=tt,i.selectLicensesForProjectsMapping=sm,i.selectLicensesOfOrganization=Sm,i.selectNumberOfAssetsOfAssetType=Dl,i.selectOrganizationAccessById=rm,i.selectOrganizationAccessForUser=lm,i.selectOrganizationAccessUserMapping=_r,i.selectOrganizationAccesses=ui,i.selectOrganizationById=ym,i.selectOrganizationUsersAsMapping=Nr,i.selectOrganizationUsersIds=Lr,i.selectOrganizations=Gr,i.selectOrganizationsMapping=Br,i.selectOrganizationsWithAccess=Am,i.selectProjectAccessById=um,i.selectProjectAccessForUser=hm,i.selectProjectAccessMapping=fi,i.selectProjectAccessUserMapping=Er,i.selectProjectAccesses=wr,i.selectProjectAttachmentById=cd,i.selectProjectAttachmentMapping=ad,i.selectProjectById=fm,i.selectProjectFileById=qm,i.selectProjectFileMapping=Ad,i.selectProjectFiles=gd,i.selectProjectMapping=at,i.selectProjectUsersAsMapping=Ur,i.selectProjectUsersIds=zr,i.selectProjects=mm,i.selectProjectsOfOrganization=gm,i.selectRehydrated=zm,i.selectRootDocuments=Mu,i.selectSortedOrganizationUsers=Tm,i.selectSortedProjectUsers=pm,i.selectStageMapping=Ue,i.selectStagesOfAssetType=kn,i.selectTeamById=Se,i.selectTeams=wi,i.selectTeamsByIds=Um,i.selectTeamsMapping=vi,i.selectTeamsOfOrganization=Vm,i.selectTeamsOfUser=$m,i.selectUploadUrl=tc,i.selectUserById=cm,i.selectUsersByIds=om,i.selectUsersMapping=it,i.separateFilesFromValues=Di,i.separateImageFromFields=Cf,i.setActiveProjectFileId=pd,i.setAsset=Pl,i.setAssetAttachment=rn,i.setAssetAttachments=vl,i.setAssetStage=En,i.setAssetStages=Ml,i.setAssetType=pu,i.setAssetTypeAttachment=Mn,i.setAssetTypeAttachments=Bl,i.setAssetTypeFieldValues=uu,i.setAssetTypeFieldValuesAttachment=cu,i.setAssetTypeFieldValuesAttachments=ou,i.setAssetTypeFieldValuesMany=hu,i.setAssetTypeFields=Ql,i.setAssetTypeFieldsAttachment=Hl,i.setAssetTypeFieldsAttachments=Wl,i.setAssetTypeFieldsMany=xl,i.setAssetTypes=yu,i.setAssets=ql,i.setConversation=nn,i.setCurrentUser=im,i.setDocumentAttachment=qa,i.setDocumentAttachments=ju,i.setDocuments=$a,i.setForm=Ju,i.setFormRevision=uc,i.setFormRevisionAttachment=Bu,i.setFormRevisionAttachments=Gu,i.setFormSubmission=Ye,i.setFormSubmissionAttachment=th,i.setFormSubmissionAttachments=sh,i.setFormSubmissions=ah,i.setGeoImage=ve,i.setGeoImages=Vc,i.setIsImportingProjectFile=fd,i.setIssueAssociation=lh,i.setIssueAssociations=dh,i.setIssueAttachment=io,i.setIssueAttachments=fh,i.setIssueComment=Bs,i.setIssueComments=ho,i.setIssueType=je,i.setIssueTypeFieldValues=Eh,i.setIssueTypeFieldValuesAttachment=Nh,i.setIssueTypeFieldValuesAttachments=Hh,i.setIssueTypeFieldValuesMany=jh,i.setIssueTypeFields=Ch,i.setIssueTypeFieldsAttachment=_h,i.setIssueTypeFieldsAttachments=Ih,i.setIssueTypeFieldsMany=Mh,i.setIssueUpdate=Qh,i.setLoggedIn=_a,i.setOrganizations=$r,i.setProfilePicture=nm,i.setProjectAttachment=td,i.setProjectAttachments=sd,i.setProjectFile=vm,i.setProjectFiles=wm,i.setProjects=qr,i.setRehydrated=Mm,i.setTeam=ge,i.setTokens=_u,i.setUploadUrl=ec,i.setUsers=pr,i.shallowEqual=Yi,i.slugify=Tl,i.spacesToDashesLower=Sl,i.teamReducer=Rd,i.teamSlice=Ri,i.toFileNameSafeString=gl,i.toOfflineIdRecord=Qi,i.truncate=bl,i.updateAsset=Ie,i.updateAssetAttachment=wl,i.updateAssetAttachments=dn,i.updateAssetStage=zt,i.updateAssetStageCompletion=_n,i.updateAssetStageCompletions=In,i.updateAssetStages=Me,i.updateAssetType=Fe,i.updateAssetTypeAttachment=Gl,i.updateAssetTypeAttachments=zn,i.updateAssetTypeFieldValues=Re,i.updateAssetTypeFieldValuesAttachment=ru,i.updateAssetTypeFieldValuesAttachments=ca,i.updateAssetTypeFieldValuesMany=fa,i.updateAssetTypeFields=ea,i.updateAssetTypeFieldsAttachment=Yl,i.updateAssetTypeFieldsAttachments=Wn,i.updateAssetTypeFieldsMany=eu,i.updateAssetTypes=gu,i.updateAssets=jl,i.updateCategory=Oa,i.updateConversation=an,i.updateDocumentAttachment=Pu,i.updateDocumentAttachments=ka,i.updateDocuments=ne,i.updateForm=Zu,i.updateFormRevisionAttachment=Lu,i.updateFormRevisionAttachments=cc,i.updateFormSubmission=qc,i.updateFormSubmissionAttachment=ih,i.updateFormSubmissionAttachments=Oc,i.updateFormSubmissions=ch,i.updateGeoImage=Gc,i.updateGeoImages=oh,i.updateIssue=Xe,i.updateIssueAssociation=Jc,i.updateIssueAssociations=uh,i.updateIssueAttachment=ph,i.updateIssueAttachments=no,i.updateIssueType=Zo,i.updateIssueTypeFieldValues=Ee,i.updateIssueTypeFieldValuesAttachment=Wh,i.updateIssueTypeFieldValuesAttachments=Lo,i.updateIssueTypeFieldValuesMany=Ph,i.updateIssueTypeFields=zo,i.updateIssueTypeFieldsAttachment=Rh,i.updateIssueTypeFieldsAttachments=Fo,i.updateIssueTypeFieldsMany=zh,i.updateLicense=te,i.updateOrganizationAccess=Tr,i.updateProject=kr,i.updateProjectAccess=Fr,i.updateProjectAttachment=Fm,i.updateProjectAttachments=id,i.updateProjectFile=_i,i.updateProjectFiles=jm,i.updateTeam=Fi,i.userReducer=Ar,i.userSlice=di,i.versioningReducer=Od,i.versioningSlice=Fd,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
15
|
+
external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(y)}const f=r.type.split("/")[1];if(!f)throw new Error("File has no extension");const p=a??h+"."+f;if(r=Zi(r,p),!r.name)throw new Error("Failed to set file's name");await this.addCache(r,h),dt[c]=new Promise(y=>{y(r)})}return r}}class rp extends q{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=[],o=[];for(const r of e){const{revisionId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.extension,file_sha1:y.sha1,form_revision:h};o.push(_)}this.dispatch(uc(c));const d=this.enqueueRequest({description:"Attach files to form revision",method:l.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.form_revision),blocks:c.map(r=>r.offline_id)});return d.then(r=>{this.processPresignedUrls(r.presigned_urls),this.dispatch(hc(r.attachments))}).catch(()=>{this.dispatch(mc(c.map(r=>r.offline_id)))}),[c,d.then(({attachments:r})=>r)]}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(lc(s))}}class dp extends q{add(e){var d;const{store:s}=this.client,a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=R({...e,created_by:a,submitted_at:new Date().toISOString()});this.dispatch(ps(c));const o=this.enqueueRequest({description:"Create form revision",method:l.POST,url:"/form-revisions/",payload:v(c),blockers:[e.form],blocks:[c.offline_id]});return o.then(m=>{this.dispatch(Ac(m))}).catch(()=>{this.dispatch(ys(c.offline_id))}),[c,o]}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(gc(s))}}const lp=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 o of a){if(o.image){if(o.image instanceof Promise)try{e[o.identifier]=await o.image}catch(d){console.error("Failed to get image from promise",d)}else e[o.identifier]=o.image;delete o.image}c.push(o)}s.push({...n,fields:c})}return{fields:s,images:e}};class up extends q{add(e,s){var r;const{store:n}=this.client,a=new Date().toISOString(),c=(r=n.getState().userReducer.currentUser)==null?void 0:r.id,o=R({...e,submitted_at:a,created_by:c}),d=R({...s,form:o.offline_id,submitted_at:a,created_by:c});this.dispatch(gs(o)),this.dispatch(ps(d));const m=this.enqueueRequest({description:"Create form",method:l.POST,url:"/forms/",payload:{...v(o),initial_revision:{offline_id:d.offline_id,submitted_at:d.submitted_at,title:d.title,description:d.description,fields:d.fields}},blockers:[],blocks:[o.offline_id,d.offline_id]});return m.catch(h=>{throw this.dispatch(Ss(o.offline_id)),this.dispatch(ys(d.offline_id)),h}),[o,d,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=wc(e)(n);if(!a)throw new Error("Expected form to exist");const c=Uc(e)(n);c.length>0&&this.dispatch(Qe(c.map(({offline_id:d})=>d)));const o=_c(e)(n);o.length>0&&this.dispatch(Tc(o.map(({offline_id:d})=>d))),this.dispatch(Ss(e));try{return await this.enqueueRequest({description:"Delete form",method:l.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(d){throw this.dispatch(gs(a)),o.length>0&&this.dispatch(Sc(o)),c.length>0&&this.dispatch(Ze(c)),d}}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(Fc(s))}}class hp extends q{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=[],o=[];for(const r of e){const{submissionId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.sha1,file_extension:y.extension,field_identifier:f,form_submission:h};o.push(_)}this.dispatch(Ye(c));const d=this.enqueueRequest({description:"Attach files to form submission",method:l.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.form_submission),blocks:c.map(r=>r.offline_id)});return d.then(r=>{this.processPresignedUrls(r.presigned_urls),this.dispatch(Pc(r.attachments))}).catch(r=>{throw this.dispatch(Je(c.map(h=>h.offline_id))),r}),[c,d.then(({attachments:r})=>r)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=qc(e)(n);this.dispatch(Je(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(Ye(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(jc(s))}}class mp extends q{async add(e){var f;const{store:s}=this.client,{file:n,...a}=e,c=new Date().toISOString(),o=(f=s.getState().userReducer.currentUser)==null?void 0:f.id,d=a.project,m=await this.getFilePayload(n),r=R({...a,file_name:n.name,file_sha1:m.sha1,file:URL.createObjectURL(n),submitted_at:c,created_by:o});this.dispatch(Hc(r));const h=this.enqueueRequest({description:"Add geo image",method:l.POST,url:"/geo-images/",payload:{offline_id:r.offline_id,submitted_at:c,title:r.title,description:r.description,geo_marker:r.geo_marker,canvas_marker:r.canvas_marker,sha1:r.file_sha1,project:r.project,file_name:r.file_name,direction:r.direction,original_date:r.original_date,file:m},blocks:[d.toString()],blockers:[d.toString()]});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(Pe(p.geo_image))}).catch(()=>{this.dispatch(Es(r.offline_id))}),[r,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,o=[],d=[],m=[],r={};for(const p of e){const{file:y,...T}=p,_=await this.getFilePayload(y);_.sha1 in r||(r[_.sha1]=_);const b=R({...T,file_name:y.name,file_sha1:_.sha1,file:URL.createObjectURL(y),submitted_at:a,created_by:c,project:s});o.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(Wc(o));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(r)},blocks:[s.toString()],blockers:d});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(Nc(p.geo_images))}).catch(()=>{this.dispatch(Yc(d))}),[o,h.then(p=>p.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=js(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(Kc(c));const o=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 o.then(d=>{this.dispatch(Pe(d))}).catch(()=>{this.dispatch(Pe(a))}),[c,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=js(e)(n);if(!a)throw new Error(`Map image with offline_id ${e} does not exist in the store`);this.dispatch(Es(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(Pe(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(Lc(s))}}class fp extends F{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=R({...e,submitted_at:n,created_by:a});this.dispatch(qs(c));const o=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 o.then(m=>{this.dispatch(eo(m))}).catch(()=>{this.dispatch(ks(c.offline_id))}),[c,o]}async delete(e){const{store:s}=this.client,n=to(e)(s.getState());if(!n)throw new Error(`Issue association with id ${e} not found in store.`);this.dispatch(ks(e));const a=this.enqueueRequest({description:"Delete issue association",method:l.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(qs(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(xc(s))}}class pp extends pe{constructor(){super(...arguments);A(this,"name","Issue Attachment");A(this,"url","/issue-attachments");A(this,"initializeAttachments",zs);A(this,"addAttachments",Us);A(this,"updateAttachments",ro);A(this,"removeAttachments",Vs);A(this,"removeAttachment",lo);A(this,"setAttachment",oo);A(this,"selectAttachment",fo)}buildOfflineAttachment(s){return R({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(zs(n))}}class yp extends pe{constructor(){super(...arguments);A(this,"name","Issue Comment Attachment");A(this,"url","/issue-comment-attachments");A(this,"initializeAttachments",Bs);A(this,"addAttachments",Ao);A(this,"updateAttachments",So);A(this,"removeAttachments",bo);A(this,"removeAttachment",To);A(this,"setAttachment",go);A(this,"selectAttachment",Ro)}buildOfflineAttachment(s){return R({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(Bs(n))}}class Ap extends F{add(e){var c;const{store:s}=this.client,n=R({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Ns(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(Hs(n.offline_id))}),[n,a]}update(e){const{store:s}=this.client,n=Eo(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(Ls(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(Ls(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(Hs(e));const n=this.enqueueRequest({description:"Delete comment",method:l.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Ns(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(vo(s))}}class gp extends F{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,o=R({...e,submitted_at:a,created_by:c});this.dispatch(Ks(o));const d=this.enqueueRequest({description:"Create issue",method:l.POST,url:"/issues/",payload:v(o),blockers:["add-issue",o.project.toString(),o.issue_type,...o.category?[o.category]:[]],blocks:[o.offline_id]});return d.then(r=>{this.dispatch(xe(r))}).catch(r=>{throw this.dispatch(Ys(o.offline_id)),r}),[o,d]}update(e){var m;const s=this.client.store.getState(),n=Js(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(xe(a));const c={};for(const r of[w.TITLE,w.DESCRIPTION,w.STATUS,w.CATEGORY,w.PRIORITY,w.ASSIGNED_TO,w.DUE_DATE])if(r in e&&e[r]!==n[r])switch(r){case w.PRIORITY:case w.STATUS:{const h=e[r];c[r]=h!==void 0?Number(h):null;break}case w.DUE_DATE:case w.DESCRIPTION:case w.TITLE:c[r]=e[r]??null;break;case w.CATEGORY:{let h=null;const f=e[r];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[r]=h?{name:h.name,color:h.color,offline_id:h.offline_id}:null;break}case w.ASSIGNED_TO:{let h=null;const f=e[r];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[r]=h?{full_name:h.username,id:h.id}:null;break}}const o=R({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:n.offline_id,changes:c});this.dispatch(wr(o));const d=this.enqueueRequest({description:"Edit issue",method:l.PATCH,url:`/issues/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return d.catch(()=>{this.dispatch(xe(n)),this.dispatch(jr(o.offline_id))}),[a,d]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Js(e)(n);if(!a)throw new Error(`No issue with id ${e} found in the store`);const c=mo(e)(n),o=Cr(e)(n),d=Vc(e)(n),m={};for(const h of so(e)(n))m[h.offline_id]=h;for(const h of io(e)(n))m[h.offline_id]=h;const r=Object.values(m);this.dispatch(Ys(e)),c.length>0&&this.dispatch(Vs(c.map(({offline_id:h})=>h))),o.length>0&&this.dispatch(Pr(o.map(({offline_id:h})=>h))),d.length>0&&this.dispatch(Qe(d.map(({offline_id:h})=>h))),r.length>0&&this.dispatch(Ds(r.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(Ks(a)),this.dispatch(Us(c)),this.dispatch(Er(o)),this.dispatch(Ze(d)),this.dispatch(Cs(r)),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(qo(s))}}class Sp extends pe{constructor(){super(...arguments);A(this,"name","Issue Type Attachment");A(this,"url","/issue-type-attachments");A(this,"initializeAttachments",Zs);A(this,"addAttachments",Uo);A(this,"updateAttachments",$o);A(this,"removeAttachments",Go);A(this,"removeAttachment",Bo);A(this,"setAttachment",Vo);A(this,"selectAttachment",Ho)}buildOfflineAttachment(s){return R({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(Zs(n))}}class Tp extends q{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=[],o=[];for(const r of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.extension,field_identifier:f,file_sha1:y.sha1,fields_revision:h};o.push(_)}this.dispatch(Jo(c));const d=this.enqueueRequest({description:"Add issue type fields attachments",method:l.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.fields_revision),blocks:c.map(r=>r.offline_id)});return d.then(r=>{this.processPresignedUrls(r.presigned_urls),this.dispatch(Xo(r.attachments))}).catch(()=>{this.dispatch(Zo(c.map(r=>r.offline_id)))}),[c,d.then(({attachments:r})=>r)]}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(Yo(s))}}class bp extends F{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=R({...e,created_by:n,submitted_at:a});this.dispatch(or(c));const o=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 o.then(m=>{this.dispatch(rr(m))}).catch(m=>{throw this.dispatch(dr(c.offline_id)),m}),[c,o]}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(cr(s))}}class _p extends q{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=[],o=[];for(const r of e){const{fieldValuesId:h,fieldIdentifier:f,file:p}=r,y=await this.getFilePayload(p);y.sha1 in a||(a[y.sha1]=y);const T=R({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:y.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:y.sha1,file_extension:y.extension,field_identifier:f,field_values:h};o.push(_)}this.dispatch(tt(c));const d=this.enqueueRequest({description:"Add issue type field values attachments",method:l.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:o,files:Object.values(a)},blockers:c.map(r=>r.field_values),blocks:c.map(r=>r.offline_id)});return d.then(({presigned_urls:r,attachments:h})=>{this.processPresignedUrls(r),this.dispatch(fr(h))}).catch(r=>{throw this.dispatch(st(c.map(h=>h.offline_id))),r}),[c,d.then(({attachments:r})=>r)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=yr(e)(n);this.dispatch(st(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(tt(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(mr(s))}}class Ip extends F{add(e){var o;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(o=n.userReducer.currentUser)==null?void 0:o.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(ei(a)),c.then(d=>(this.dispatch(Ce(d)),d)).catch(()=>{this.dispatch(ti(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=ii(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(Ce(c));const o=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 o.then(d=>{this.dispatch(Ce(d))}).catch(()=>{this.dispatch(Ce(a))}),[c,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ii(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Ar(e)(n);this.dispatch(ti(e)),this.dispatch(st(c.map(o=>o.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(o){throw this.dispatch(ei(a)),this.dispatch(tt(c)),o}}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(sr(s))}}class Rp extends F{add(e){var o;const{store:s}=this.client,n=s.getState(),a=R({...e,submitted_at:new Date().toISOString(),created_by:(o=n.userReducer.currentUser)==null?void 0:o.id});this.dispatch(br(a));const c=this.enqueueRequest({method:l.POST,url:"/issue-types/",payload:v(a),blockers:[],blocks:[a.offline_id]});return c.then(d=>{this.dispatch(ke(d))}).catch(()=>{this.dispatch(ri(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(`IssueType with offline_id ${e.offline_id} does not exist in the store.`);const c={...a,...e};this.dispatch(_r(c));const o=this.enqueueRequest({method:l.PATCH,url:`/issue-types/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return o.then(d=>{this.dispatch(ke(d))}).catch(()=>{this.dispatch(ke(a))}),[c,o]}delete(e){const{store:s}=this.client,n=s.getState(),a=di(e)(n);if(!a)throw new Error(`IssueType with offline_id ${e} does not exist in the store.`);const c=li(e)(n);this.dispatch(ri(e)),this.dispatch(ko(c.map(d=>d.offline_id)));const o=this.enqueueRequest({method:l.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return o.catch(()=>{this.dispatch(ke(a)),this.dispatch(Co(c))}),o}async refreshStore(e){const s=await this.enqueueRequest({method:l.GET,url:"/issue-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Tr(s))}}class Fp extends F{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(vr(s))}}class Op extends sl{constructor(e){super(e)}}const vp=1800;function wp(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 Ep extends Op{constructor(){super(...arguments);A(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(va(!1)),this.clearTokens(),this.dispatch({type:Fl.RESET_STATE}),this.dispatch({type:ll})}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=Ol(s).exp??n}catch{a=n}return a-n<vp}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 P&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??Re).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 P({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 P({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(wp(a))})}}class jp extends F{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(ne(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(ne(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(ne(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(ne(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(ne(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(ne(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 o of a)n[o.offline_id]=o;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 o of c)n[o.offline_id]=o;this.dispatch(Mr(Object.values(n)))}}class Pp extends F{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(Hr(e))}),s}async remove(e){return this.dispatch(Wr(e.offline_id)),this.dispatch(Br(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(Nr(s))}}class qp extends F{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 o of a)n[o.id]=o;const c=await this.enqueueRequest({description:"Get organization",method:l.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.id]=c,this.dispatch(ud(Object.values(n)))}}class Cp extends F{async update(e){return this.dispatch(Xr(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(Zr(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(Ai(s))}}class kp extends pe{constructor(){super(...arguments);A(this,"name","Project Attachment");A(this,"url","/project-attachments");A(this,"addAttachments",Fd);A(this,"updateAttachments",wd);A(this,"removeAttachments",Ii);A(this,"removeAttachment",Ed);A(this,"setAttachment",Od);A(this,"selectAttachment",qd)}buildOfflineAttachment(s){return R({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(Rd(n))}}class Dp extends F{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(Fi(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,r)=>{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(r)});const d=Promise.resolve(c).then(m=>this.enqueueRequest(m));return d.then(m=>{this.dispatch(Fi(m))}),this.dispatch(Gd),this.dispatch(Bd(null)),this.dispatch($d(!1)),[a,d]}delete(e){return this.dispatch(Ud(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(Md(s))}}class Mp extends F{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(nd(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=rt(n),c=a[e];if(!c)throw new Error("Expected project to exist");const o=Nd(n).filter(h=>h.project===e);this.dispatch(Vd(o.map(({offline_id:h})=>h)));const d=Cd(c.id)(n);this.dispatch(Ii(d.map(({offline_id:h})=>h)));const m=xr(n);this.dispatch(Qr(m.map(({offline_id:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(ad(c));const r=zr(c.id)(n);r&&this.dispatch(ne({...r,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(id(Object.values(a))),this.dispatch(Ai(Object.values(m))),this.dispatch(zd(o)),this.dispatch(vd(d)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),r&&this.dispatch(ne({...r,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(cd(e))})}}class zp extends F{add(e){const s=R({...e,submitted_at:new Date().toISOString()});this.dispatch(Jd(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(_e(a))}).catch(()=>{this.dispatch(Ei(s.offline_id))}),[s,n]}update(e){const{store:s}=this.client,n=Ie(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(wi(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(o=>{this.dispatch(_e(o))}).catch(()=>{this.dispatch(_e(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Ie(e)(n);if(!a)throw new Error(`Expected team with id ${e} to exist`);this.dispatch(Ei(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(_e(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=Ie(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(wi({...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(_e(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=Ie(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=Ie(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=a.members.filter(o=>!s.includes(o));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(Yd(s))}}class Up extends F{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 o of a)n[o.id]=o;const c=await this.enqueueRequest({description:"Fetch project users",method:l.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const o of c)n[o.id]=o;this.dispatch($r(Object.values(n)))}}var yl=(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))(yl||{});i.APIError=P,i.AgentService=Gf,i.AssetAttachmentService=Lf,i.AssetService=Nf,i.AssetStageCompletionService=Hf,i.AssetStageService=Wf,i.AssetTypeAttachmentService=Kf,i.AssetTypeFieldValuesAttachmentService=Xf,i.AssetTypeFieldValuesService=xf,i.AssetTypeFieldsAttachmentService=Yf,i.AssetTypeFieldsService=Jf,i.AssetTypeService=ep,i.AttachmentModel=Ni,i.BaseApiService=F,i.BaseSDK=$f,i.COMMON_AUTO_FIELDS=en,i.CategoryService=tp,i.DEFAULT_ISSUE_PRIORITY=wl,i.DEFAULT_ISSUE_STATUS=vl,i.DeferredPromise=Ji,i.DocumentAttachmentService=sp,i.DocumentService=ip,i.EMPTY_ARRAY=Gi,i.EMPTY_OBJECT=Li,i.EmailDomainsService=np,i.EmailVerificationService=ap,i.FileService=op,i.FormRevisionAttachmentService=rp,i.FormRevisionService=dp,i.FormService=up,i.FormSubmissionAttachmentService=hp,i.FormSubmissionService=Qf,i.GeoImageService=mp,i.HttpMethod=l,i.IssueAssociationService=fp,i.IssueAttachmentService=pp,i.IssueCommentAttachmentService=yp,i.IssueCommentService=Ap,i.IssuePriority=mt,i.IssueService=gp,i.IssueStatus=ft,i.IssueTypeAttachmentService=Sp,i.IssueTypeFieldValuesAttachmentService=_p,i.IssueTypeFieldValuesService=Ip,i.IssueTypeFieldsAttachmentService=Tp,i.IssueTypeFieldsService=bp,i.IssueTypeService=Rp,i.IssueUpdateChange=w,i.IssueUpdateService=Fp,i.JWTService=Ep,i.LicenseLevel=Wi,i.LicenseService=jp,i.LicenseStatus=Ki,i.OUTBOX_RETRY_DELAY=Yi,i.OrganizationAccessLevel=ht,i.OrganizationAccessService=Pp,i.OrganizationService=qp,i.OutboxCoordinator=Fe,i.PaddleCheckoutEvent=Hi,i.ProjectAccessLevel=ut,i.ProjectAccessService=Cp,i.ProjectAttachmentService=kp,i.ProjectFileService=Dp,i.ProjectService=Mp,i.TeamService=zp,i.UNKNOWN_ERROR_MESSAGE=Re,i.UserService=Up,i.VERSION_REDUCER_KEY=qi,i.VerificationCodeType=yl,i._setLatestRetryTime=bd,i.acceptProjectInvite=cd,i.addAsset=Ot,i.addAssetAttachment=xl,i.addAssetAttachments=It,i.addAssetStage=du,i.addAssetStageCompletion=Ct,i.addAssetStageCompletions=kt,i.addAssetStages=Ue,i.addAssetType=es,i.addAssetTypeAttachment=hu,i.addAssetTypeAttachments=Gt,i.addAssetTypeFieldValues=Jt,i.addAssetTypeFieldValuesAttachment=ju,i.addAssetTypeFieldValuesAttachments=Le,i.addAssetTypeFieldValuesMany=ga,i.addAssetTypeFields=na,i.addAssetTypeFieldsAttachment=pu,i.addAssetTypeFieldsAttachments=Xn,i.addAssetTypeFieldsMany=_u,i.addAssetTypes=Gu,i.addAssets=vt,i.addCategory=as,i.addConversation=cn,i.addDocumentAttachment=eh,i.addDocumentAttachments=Ma,i.addDocuments=Ka,i.addEmailDomain=xa,i.addForm=gs,i.addFormRevision=ps,i.addFormRevisionAttachment=lh,i.addFormRevisionAttachments=uc,i.addFormRevisions=Sc,i.addFormSubmission=Is,i.addFormSubmissionAttachment=Ih,i.addFormSubmissionAttachments=Ye,i.addFormSubmissions=Ze,i.addForms=Th,i.addGeoImage=Hc,i.addGeoImages=Wc,i.addIssue=Ks,i.addIssueAssociation=qs,i.addIssueAssociations=Cs,i.addIssueAttachment=Mh,i.addIssueAttachments=Us,i.addIssueComment=Ns,i.addIssueCommentAttachment=Vh,i.addIssueCommentAttachments=Ao,i.addIssueComments=Lh,i.addIssueType=br,i.addIssueTypeAttachment=Kh,i.addIssueTypeAttachments=Uo,i.addIssueTypeFieldValues=ei,i.addIssueTypeFieldValuesAttachment=Sm,i.addIssueTypeFieldValuesAttachments=tt,i.addIssueTypeFieldValuesMany=nm,i.addIssueTypeFields=or,i.addIssueTypeFieldsAttachment=Zh,i.addIssueTypeFieldsAttachments=Jo,i.addIssueTypeFieldsMany=lm,i.addIssueUpdate=wr,i.addIssueUpdates=Er,i.addIssues=Co,i.addLicenses=Em,i.addProjectAttachment=ef,i.addProjectAttachments=Fd,i.addProjectFile=af,i.addProjectFiles=zd,i.addTeam=Jd,i.addUsers=Dm,i.agentsReducer=dn,i.agentsSlice=St,i.areArraysEqual=Cl,i.assetAttachmentReducer=gn,i.assetAttachmentSlice=bt,i.assetReducer=In,i.assetSlice=Ft,i.assetStageCompletionReducer=jn,i.assetStageCompletionSlice=qt,i.assetStageReducer=kn,i.assetStageSlice=Ut,i.assetTypeAttachmentReducer=Kn,i.assetTypeAttachmentSlice=Bt,i.assetTypeFieldValuesAttachmentReducer=pa,i.assetTypeFieldValuesAttachmentSlice=Wt,i.assetTypeFieldValuesReducer=_a,i.assetTypeFieldValuesSlice=Yt,i.assetTypeFieldsAttachmentReducer=ta,i.assetTypeFieldsAttachmentSlice=Nt,i.assetTypeFieldsReducer=ra,i.assetTypeFieldsSlice=Ht,i.assetTypeReducer=Fa,i.assetTypeSlice=xt,i.authReducer=wa,i.authSlice=He,i.blobToBase64=Gl,i.categoryReducer=Ca,i.categorySlice=ns,i.clearTokens=Yu,i.constructUploadedFilePayloads=Bl,i.coordinatesAreEqual=Pl,i.createModelAdapter=I,i.createMultiPointGeometry=jl,i.createOfflineAction=Ad,i.createPayload=v,i.createPointGeometry=El,i.deleteAsset=wt,i.deleteAssetAttachment=mn,i.deleteAssetAttachments=Rt,i.deleteAssetStage=lu,i.deleteAssetStageCompletion=Dt,i.deleteAssetStageCompletions=Mt,i.deleteAssetStages=$e,i.deleteAssetType=ts,i.deleteAssetTypeAttachment=Gn,i.deleteAssetTypeAttachments=Lt,i.deleteAssetTypeFieldValues=Xt,i.deleteAssetTypeFieldValuesAttachment=ku,i.deleteAssetTypeFieldValuesAttachments=Ne,i.deleteAssetTypeFieldValuesMany=Ta,i.deleteAssetTypeFields=ca,i.deleteAssetTypeFieldsAttachment=Su,i.deleteAssetTypeFieldsAttachments=Qn,i.deleteAssetTypeFieldsMany=Ou,i.deleteAssetTypes=Nu,i.deleteAssets=bn,i.deleteCategory=qa,i.deleteDocumentAttachment=Va,i.deleteDocumentAttachments=$a,i.deleteEmailDomain=ec,i.deleteForm=Ss,i.deleteFormRevision=ys,i.deleteFormRevisionAttachment=fh,i.deleteFormRevisionAttachments=mc,i.deleteFormRevisions=Tc,i.deleteFormSubmission=Rs,i.deleteFormSubmissionAttachment=vh,i.deleteFormSubmissionAttachments=Je,i.deleteFormSubmissions=Qe,i.deleteGeoImage=Es,i.deleteGeoImages=Yc,i.deleteIssue=Ys,i.deleteIssueAssociation=ks,i.deleteIssueAssociations=Ds,i.deleteIssueAttachment=lo,i.deleteIssueAttachments=Vs,i.deleteIssueComment=Hs,i.deleteIssueCommentAttachment=To,i.deleteIssueCommentAttachments=bo,i.deleteIssueComments=Nh,i.deleteIssueTypeAttachment=Bo,i.deleteIssueTypeAttachments=Go,i.deleteIssueTypeFieldValues=ti,i.deleteIssueTypeFieldValuesAttachment=Im,i.deleteIssueTypeFieldValuesAttachments=st,i.deleteIssueTypeFieldValuesMany=rm,i.deleteIssueTypeFields=dr,i.deleteIssueTypeFieldsAttachment=tm,i.deleteIssueTypeFieldsAttachments=Zo,i.deleteIssueTypeFieldsMany=fm,i.deleteIssueUpdate=jr,i.deleteIssueUpdates=Pr,i.deleteIssues=ko,i.deleteOrganizationAccess=Wr,i.deleteProject=ad,i.deleteProjectAccess=Zr,i.deleteProjectAccesses=Qr,i.deleteProjectAttachment=Ed,i.deleteProjectAttachments=Ii,i.deleteProjectFile=Ud,i.deleteProjectFiles=Vd,i.deleteTeam=Ei,i.dequeue=hl,i.discard=Di,i.documentAttachmentReducer=Na,i.documentAttachmentSlice=rs,i.documentSlice=ds,i.documentsReducer=Za,i.downloadFile=Ll,i.downloadInMemoryFile=$l,i.emailDomainsReducer=ic,i.emailDomainsSlice=us,i.emailRegex=Xl,i.enqueue=ul,i.enqueueRequest=Sd,i.fallbackToEmptyArray=g,i.fallbackToEmptyObject=re,i.fileReducer=rc,i.fileSlice=hs,i.fileToBlob=Qi,i.formReducer=Oc,i.formRevisionAttachmentReducer=pc,i.formRevisionAttachmentSlice=ms,i.formRevisionReducer=Ic,i.formRevisionsSlice=fs,i.formSlice=As,i.formSubmissionAttachmentReducer=kc,i.formSubmissionAttachmentSlice=Ts,i.formSubmissionReducer=Bc,i.formSubmissionSlice=_s,i.geoImageReducer=Zc,i.geoImageSlice=ws,i.getFileIdentifier=Vl,i.getFileS3Key=gt,i.getLocalDateString=Xi,i.getLocalRelativeDateString=zl,i.getOutboxCoordinator=fe,i.getRenamedFile=Zi,i.hashFile=ge,i.initSDK=Bf,i.initializeAssetAttachments=_t,i.initializeAssetStageCompletions=Fn,i.initializeAssetStages=qn,i.initializeAssetTypeAttachments=Vn,i.initializeAssetTypeFieldValues=Aa,i.initializeAssetTypeFieldValuesAttachments=la,i.initializeAssetTypeFields=ia,i.initializeAssetTypeFieldsAttachments=Jn,i.initializeAssetTypes=Ra,i.initializeAssets=Tn,i.initializeCategories=ja,i.initializeConversations=an,i.initializeDocumentAttachments=Da,i.initializeEmailDomains=Qa,i.initializeFormRevisionAttachments=lc,i.initializeFormRevisions=gc,i.initializeFormSubmissionAttachments=jc,i.initializeFormSubmissions=Mc,i.initializeForms=Fc,i.initializeGeoImages=Lc,i.initializeIssueAssociations=xc,i.initializeIssueAttachments=zs,i.initializeIssueCommentAttachments=Bs,i.initializeIssueTypeAttachments=Zs,i.initializeIssueTypeFieldValues=sr,i.initializeIssueTypeFieldValuesAttachments=mr,i.initializeIssueTypeFields=cr,i.initializeIssueTypeFieldsAttachments=Yo,i.initializeIssueTypes=Tr,i.initializeIssueUpdates=vr,i.initializeIssues=qo,i.initializeLicences=Mr,i.initializeOrganizationAccesses=Nr,i.initializeProjectAccesses=Ai,i.initializeProjectAttachments=Rd,i.initializeProjectFiles=Md,i.initializeTeams=Yd,i.isToday=Ml,i.issueAssociationReducer=ao,i.issueAssociationSlice=Ps,i.issueAttachmentReducer=po,i.issueAttachmentSlice=Ms,i.issueCommentAttachmentReducer=Fo,i.issueCommentAttachmentSlice=$s,i.issueCommentReducer=jo,i.issueCommentSlice=Gs,i.issueReducer=Mo,i.issueSlice=Ws,i.issueTypeAttachmentReducer=Wo,i.issueTypeAttachmentSlice=Xs,i.issueTypeFieldValuesAttachmentReducer=gr,i.issueTypeFieldValuesAttachmentSlice=ai,i.issueTypeFieldValuesReducer=nr,i.issueTypeFieldValuesSlice=xs,i.issueTypeFieldsAttachmentReducer=er,i.issueTypeFieldsAttachmentSlice=Qs,i.issueTypeFieldsReducer=ur,i.issueTypeFieldsSlice=ni,i.issueTypeReducer=Fr,i.issueTypeSlice=oi,i.issueUpdateReducer=kr,i.issueUpdateSlice=ui,i.licenseReducer=Ur,i.licenseSlice=hi,i.logOnlyOnce=Nl,i.markAsDeleted=Td,i.markForDeletion=xm,i.memoize=yt,i.moveDocument=Ya,i.offline=R,i.onlyUniqueHashes=Jl,i.onlyUniqueOfflineIds=sn,i.organizationAccessReducer=Yr,i.organizationAccessSlice=fi,i.organizationReducer=yd,i.organizationSlice=Ti,i.outboxReducer=_d,i.outboxSlice=bi,i.overmapEnhancer=Ef,i.overmapReducers=rl,i.overmapRootReducer=Rf,i.performRequest=ki,i.projectAccessReducer=td,i.projectAccessSlice=yi,i.projectAttachmentReducer=kd,i.projectAttachmentSlice=_i,i.projectFileReducer=Hd,i.projectFileSlice=Ri,i.projectReducer=od,i.projectSlice=Si,i.rehydratedReducer=Wd,i.rehydratedSlice=Oi,i.removeDocuments=ls,i.removeIssueType=ri,i.removeUser=Br,i.resetProjectFileObjectUrls=of,i.resetStore=ll,i.restructureCreateSelectorWithArgs=S,i.saveActiveProjectFileBounds=Gd,i.selectAccessToken=Ju,i.selectActiveOrganizationAccess=Vm,i.selectActiveProjectFileId=df,i.selectActiveStatusLicenses=Pm,i.selectAllDocumentAttachments=Ga,i.selectAllProjectAttachments=Pd,i.selectAncestorIdsOfDocument=ah,i.selectAssetAttachmentById=yn,i.selectAssetAttachmentMapping=fn,i.selectAssetAttachments=pn,i.selectAssetById=Pt,i.selectAssetStageById=Dn,i.selectAssetStageCompletionById=wn,i.selectAssetStageCompletionMapping=zt,i.selectAssetStageCompletionsByIds=En,i.selectAssetStages=Mn,i.selectAssetStagesByIds=$t,i.selectAssetTypeAttachmentById=Hn,i.selectAssetTypeAttachmentMapping=Ln,i.selectAssetTypeAttachments=Nn,i.selectAssetTypeById=is,i.selectAssetTypeFieldValues=Zt,i.selectAssetTypeFieldValuesAttachmentById=Du,i.selectAssetTypeFieldValuesAttachments=ha,i.selectAssetTypeFieldValuesAttachmentsByIds=ma,i.selectAssetTypeFieldValuesAttachmentsMapping=Kt,i.selectAssetTypeFieldValuesById=Qt,i.selectAssetTypeFieldValuesMapping=ba,i.selectAssetTypeFieldValuesOfAsset=Uu,i.selectAssetTypeFields=Ge,i.selectAssetTypeFieldsAttachmentById=bu,i.selectAssetTypeFieldsAttachments=ea,i.selectAssetTypeFieldsAttachmentsMapping=xn,i.selectAssetTypeFieldsById=Eu,i.selectAssetTypeFieldsMapping=oa,i.selectAssetTypeFieldsOfAssetType=vu,i.selectAssetTypeStagesMapping=uu,i.selectAssetTypeValuesOfAssetType=Vu,i.selectAssetTypes=Hu,i.selectAssetTypesByIds=Wu,i.selectAssetTypesMapping=ss,i.selectAssets=_n,i.selectAssetsByIds=au,i.selectAssetsMapping=Et,i.selectAssetsOfAssetType=jt,i.selectAttachmentsOfAsset=An,i.selectAttachmentsOfAssetType=Wn,i.selectAttachmentsOfAssetTypeFieldValues=fa,i.selectAttachmentsOfAssetTypeFields=Tu,i.selectAttachmentsOfDocument=ih,i.selectAttachmentsOfFormRevision=ph,i.selectAttachmentsOfFormSubmission=Cc,i.selectAttachmentsOfIssue=mo,i.selectAttachmentsOfIssueComment=Gh,i.selectAttachmentsOfIssueType=Xh,i.selectAttachmentsOfIssueTypeFieldValues=Ar,i.selectAttachmentsOfIssueTypeFields=sm,i.selectAttachmentsOfProject=Cd,i.selectCategories=Zu,i.selectCategoriesByIds=Qu,i.selectCategoryById=os,i.selectCategoryMapping=cs,i.selectCommentsOfIssue=Hh,i.selectCompletedStagesByAsset=ou,i.selectConversation=Ql,i.selectConversationMapping=Tt,i.selectConversations=Zl,i.selectCurrentUser=at,i.selectDeletedRequests=Zm,i.selectDocumentAttachmentById=La,i.selectDocumentAttachmentMapping=Ba,i.selectDocumentById=Xa,i.selectDocuments=Ja,i.selectDocumentsByIds=nh,i.selectDocumentsMapping=Se,i.selectEmailDomains=sc,i.selectEmailDomainsAsMapping=tc,i.selectEmailDomainsOfOrganization=rh,i.selectFormById=wc,i.selectFormMapping=vc,i.selectFormRevisionAttachmentsMapping=fc,i.selectFormRevisionById=Ah,i.selectFormRevisionMapping=Ke,i.selectFormRevisions=bc,i.selectFormRevisionsOfForm=_c,i.selectFormSubmissionAttachemntsByIds=qc,i.selectFormSubmissionAttachmentsMapping=bs,i.selectFormSubmissionById=vs,i.selectFormSubmissions=Os,i.selectFormSubmissionsMapping=Fs,i.selectFormSubmissionsOfAsset=$c,i.selectFormSubmissionsOfForm=Uc,i.selectFormSubmissionsOfIssue=Vc,i.selectForms=_h,i.selectGeoImageById=js,i.selectGeoImageMapping=Jc,i.selectGeoImages=Xc,i.selectGeoImagesOfProject=Ph,i.selectIsImportingProjectFile=lf,i.selectIsLoggedIn=Xu,i.selectIssueAssociationById=to,i.selectIssueAssociationMapping=qe,i.selectIssueAssociations=Dh,i.selectIssueAssociationsOfAsset=no,i.selectIssueAssociationsOfIssue=io,i.selectIssueAssociationsToIssue=so,i.selectIssueAttachmentById=fo,i.selectIssueAttachmentMapping=uo,i.selectIssueAttachments=ho,i.selectIssueById=Js,i.selectIssueCommentAttachmentById=Ro,i.selectIssueCommentAttachmentMapping=_o,i.selectIssueCommentAttachments=Io,i.selectIssueCommentById=Eo,i.selectIssueCommentMapping=wo,i.selectIssueCountOfCategory=xu,i.selectIssueMapping=Do,i.selectIssueTypeAttachmentById=Ho,i.selectIssueTypeAttachmentMapping=Lo,i.selectIssueTypeAttachments=No,i.selectIssueTypeById=di,i.selectIssueTypeFieldValues=si,i.selectIssueTypeFieldValuesAttachmentById=Rm,i.selectIssueTypeFieldValuesAttachments=pr,i.selectIssueTypeFieldValuesAttachmentsByIds=yr,i.selectIssueTypeFieldValuesAttachmentsMapping=ci,i.selectIssueTypeFieldValuesById=ii,i.selectIssueTypeFieldValuesMapping=ir,i.selectIssueTypeFieldValuesOfIssue=dm,i.selectIssueTypeFields=et,i.selectIssueTypeFieldsAttachmentById=im,i.selectIssueTypeFieldsAttachments=xo,i.selectIssueTypeFieldsAttachmentsMapping=Qo,i.selectIssueTypeFieldsById=gm,i.selectIssueTypeFieldsMapping=lr,i.selectIssueTypeFieldsOfIssueType=pm,i.selectIssueTypeMapping=Ir,i.selectIssueTypeValuesOfIssueType=Am,i.selectIssueTypes=Rr,i.selectIssueTypesByIds=Fm,i.selectIssueTypesOfOrganization=Om,i.selectIssueUpdateMapping=qr,i.selectIssueUpdatesOfIssue=Cr,i.selectIssuesByIds=Wh,i.selectIssuesOfIssueType=li,i.selectIssuesOfIssueTypeCount=vm,i.selectLatestAssetTypeFieldsOfAssetType=wu,i.selectLatestFormRevisionOfForm=gh,i.selectLatestIssueTypeFieldsOfIssueType=ym,i.selectLatestRetryTime=Qm,i.selectLicense=jm,i.selectLicenseForProject=zr,i.selectLicenses=nt,i.selectLicensesForProjectsMapping=qm,i.selectLicensesOfOrganization=Jm,i.selectNumberOfAssetsOfAssetType=cu,i.selectOrganizationAccessById=Um,i.selectOrganizationAccessForUser=$m,i.selectOrganizationAccessUserMapping=Kr,i.selectOrganizationAccesses=pi,i.selectOrganizationById=Wm,i.selectOrganizationUsersAsMapping=pd,i.selectOrganizationUsersIds=fd,i.selectOrganizations=md,i.selectOrganizationsMapping=hd,i.selectOrganizationsWithAccess=Km,i.selectProjectAccessById=Bm,i.selectProjectAccessForUser=Gm,i.selectProjectAccessMapping=gi,i.selectProjectAccessUserMapping=ed,i.selectProjectAccesses=xr,i.selectProjectAttachmentById=qd,i.selectProjectAttachmentMapping=jd,i.selectProjectById=Nm,i.selectProjectFileById=rf,i.selectProjectFileMapping=Ld,i.selectProjectFiles=Nd,i.selectProjectMapping=rt,i.selectProjectUsersAsMapping=dd,i.selectProjectUsersIds=rd,i.selectProjects=Lm,i.selectProjectsOfOrganization=Ym,i.selectRehydrated=mf,i.selectRootDocuments=ch,i.selectSortedOrganizationUsers=Xm,i.selectSortedProjectUsers=Hm,i.selectStageMapping=Be,i.selectStagesOfAssetType=zn,i.selectTeamById=Ie,i.selectTeams=Pi,i.selectTeamsByIds=ff,i.selectTeamsMapping=ji,i.selectTeamsOfOrganization=pf,i.selectTeamsOfUser=yf,i.selectUploadUrl=oc,i.selectUserById=Mm,i.selectUsersByIds=zm,i.selectUsersMapping=ct,i.separateFilesFromValues=zi,i.separateImageFromFields=lp,i.setActiveProjectFileId=Bd,i.setAsset=iu,i.setAssetAttachment=un,i.setAssetAttachments=eu,i.setAssetStage=Cn,i.setAssetStages=ru,i.setAssetType=$u,i.setAssetTypeAttachment=$n,i.setAssetTypeAttachments=mu,i.setAssetTypeFieldValues=Mu,i.setAssetTypeFieldValuesAttachment=Pu,i.setAssetTypeFieldValuesAttachments=qu,i.setAssetTypeFieldValuesMany=zu,i.setAssetTypeFields=Iu,i.setAssetTypeFieldsAttachment=yu,i.setAssetTypeFieldsAttachments=Au,i.setAssetTypeFieldsMany=Ru,i.setAssetTypes=Bu,i.setAssets=nu,i.setConversation=on,i.setCurrentUser=Cm,i.setDocumentAttachment=za,i.setDocumentAttachments=th,i.setDocuments=Wa,i.setForm=Sh,i.setFormRevision=Ac,i.setFormRevisionAttachment=uh,i.setFormRevisionAttachments=hh,i.setFormSubmission=Xe,i.setFormSubmissionAttachment=Rh,i.setFormSubmissionAttachments=Fh,i.setFormSubmissions=wh,i.setGeoImage=Pe,i.setGeoImages=Nc,i.setIsImportingProjectFile=$d,i.setIssueAssociation=Ch,i.setIssueAssociations=qh,i.setIssueAttachment=oo,i.setIssueAttachments=zh,i.setIssueComment=Ls,i.setIssueCommentAttachment=go,i.setIssueCommentAttachments=$h,i.setIssueComments=vo,i.setIssueType=ke,i.setIssueTypeAttachment=Vo,i.setIssueTypeAttachments=Yh,i.setIssueTypeFieldValues=am,i.setIssueTypeFieldValuesAttachment=Tm,i.setIssueTypeFieldValuesAttachments=bm,i.setIssueTypeFieldValuesMany=cm,i.setIssueTypeFields=um,i.setIssueTypeFieldsAttachment=Qh,i.setIssueTypeFieldsAttachments=xh,i.setIssueTypeFieldsMany=hm,i.setIssueUpdate=wm,i.setLoggedIn=va,i.setOrganizations=ud,i.setProfilePicture=km,i.setProjectAttachment=Od,i.setProjectAttachments=vd,i.setProjectFile=sf,i.setProjectFiles=nf,i.setProjects=id,i.setRehydrated=hf,i.setTeam=_e,i.setTokens=Ku,i.setUploadUrl=cc,i.setUsers=$r,i.shallowEqual=ql,i.slugify=Kl,i.spacesToDashesLower=Wl,i.teamReducer=Xd,i.teamSlice=vi,i.toFileNameSafeString=Hl,i.toOfflineIdRecord=tn,i.truncate=Yl,i.updateAsset=ve,i.updateAssetAttachment=tu,i.updateAssetAttachments=hn,i.updateAssetStage=Vt,i.updateAssetStageCompletion=On,i.updateAssetStageCompletions=vn,i.updateAssetStages=Ve,i.updateAssetType=Ee,i.updateAssetTypeAttachment=fu,i.updateAssetTypeAttachments=Bn,i.updateAssetTypeFieldValues=we,i.updateAssetTypeFieldValuesAttachment=Cu,i.updateAssetTypeFieldValuesAttachments=ua,i.updateAssetTypeFieldValuesMany=Sa,i.updateAssetTypeFields=aa,i.updateAssetTypeFieldsAttachment=gu,i.updateAssetTypeFieldsAttachments=Zn,i.updateAssetTypeFieldsMany=Fu,i.updateAssetTypes=Lu,i.updateAssets=su,i.updateCategory=Pa,i.updateConversation=rn,i.updateDocumentAttachment=sh,i.updateDocumentAttachments=Ua,i.updateDocuments=oe,i.updateForm=bh,i.updateFormRevisionAttachment=mh,i.updateFormRevisionAttachments=hc,i.updateFormSubmission=zc,i.updateFormSubmissionAttachment=Oh,i.updateFormSubmissionAttachments=Pc,i.updateFormSubmissions=Eh,i.updateGeoImage=Kc,i.updateGeoImages=jh,i.updateIssue=xe,i.updateIssueAssociation=eo,i.updateIssueAssociations=kh,i.updateIssueAttachment=Uh,i.updateIssueAttachments=ro,i.updateIssueCommentAttachment=Bh,i.updateIssueCommentAttachments=So,i.updateIssueType=_r,i.updateIssueTypeAttachment=Jh,i.updateIssueTypeAttachments=$o,i.updateIssueTypeFieldValues=Ce,i.updateIssueTypeFieldValuesAttachment=_m,i.updateIssueTypeFieldValuesAttachments=fr,i.updateIssueTypeFieldValuesMany=om,i.updateIssueTypeFields=rr,i.updateIssueTypeFieldsAttachment=em,i.updateIssueTypeFieldsAttachments=Xo,i.updateIssueTypeFieldsMany=mm,i.updateLicense=ne,i.updateOrganizationAccess=Hr,i.updateProject=nd,i.updateProjectAccess=Xr,i.updateProjectAttachment=tf,i.updateProjectAttachments=wd,i.updateProjectFile=Fi,i.updateProjectFiles=cf,i.updateTeam=wi,i.userReducer=Gr,i.userSlice=mi,i.versioningReducer=Qd,i.versioningSlice=Zd,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|