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