1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7997],{64807:(e,t,n)=>{n.d(t,{Nv:()=>s,Q3:()=>d,U7:()=>l,Y6:()=>f,ZA:()=>m,ao:()=>p,gP:()=>g,mM:()=>u,pZ:()=>o,uS:()=>a,yF:()=>c});var r=n(95979),i=n(10934);async function o(e,t,n){return(0,r.u)({endpoint:"entities/user",method:"get",accessToken:e,param:{email:t,...(0,i.R)(n)}})}async function a(e){return(0,r.u)({endpoint:"service-agreement",method:"post",accessToken:e})}async function u(e,t,n){return(0,r.u)({endpoint:"entities/entity-info",method:"get",accessToken:e,param:{entityKey:t,...(0,i.R)(n)}})}async function l(e,t){return(0,r.u)({endpoint:"user/entity-management",method:"get",accessToken:e,param:(0,i.R)(t)})}async function s(e,t){return(0,r.u)({endpoint:"projects/form-submitted",method:"get",accessToken:e,param:(0,i.R)(t)})}async function c(e,t){let n=await (0,r.u)({endpoint:"projects/client",method:"get",accessToken:e,param:{prospectKey:t}}),i=null;if("string"==typeof n.data)try{let e=JSON.parse(n.data);e&&"object"==typeof e&&!Array.isArray(e)&&(i=e)}catch(e){}else n.data&&"object"==typeof n.data&&!Array.isArray(n.data)&&(i=n.data);return{data:i,err:n.err}}async function d(e,t){return(0,r.u)({endpoint:"projects/client/documents",method:"get",accessToken:e,param:{prospectKey:t}})}async function m(e,t){return(0,r.u)({endpoint:"projects/client/participant-documents",method:"get",accessToken:e,param:{prospectKey:t}})}async function p(e,t,n){return(0,r.u)({endpoint:"entities/invoices",method:"get",accessToken:e,param:{key:t,...(0,i.R)(n)}})}async function f(e,t,n){return(0,r.u)({endpoint:"entities/submitted-documents",method:"get",accessToken:e,param:{key:t,...(0,i.R)(n)}})}async function g(e,t,n){return(0,r.u)({endpoint:"dashboard/services",method:"get",accessToken:e,param:{companyKey:t,...(0,i.R)(n)}})}},67997:(e,t,n)=>{n.d(t,{DO:()=>p,GK:()=>f,gH:()=>v,o1:()=>m,xL:()=>y});var r=n(4624),i=n(99356),o=n(1815),a=n(64807),u=n(75230),l=n(55064),s=n(15641);let c=(0,i.createContext)(null),d=(0,i.createContext)(null);function m(){let e=(0,i.useContext)(c);if(null===e)throw Error("useUserEntities must be used inside <UserEntitiesProvider>");return e}function p(){let e=(0,i.useContext)(d);if(null===e)throw Error("useUserEntitiesActions must be used inside <UserEntitiesProvider>");return e}function f(){return(0,i.useContext)(c)}let g={markServiceAgreed:()=>{},refetch:()=>{}};function y(){var e;return null!=(e=(0,i.useContext)(d))?e:g}function v(e){var t,n;let{children:m}=e,{ready:p,authenticated:f,user:g}=(0,o.h)(),y=(0,s.j)(g),[v,h]=(0,i.useState)({kind:"loading"}),j=(0,l.tg)(),k=null!=(t=null==j?void 0:j.active)?t:null,b=null!=(n=null==j?void 0:j.status)?n:"ready",x=(0,i.useRef)(null),[A,w]=(0,i.useState)(0);(0,i.useEffect)(()=>{if(!p||!f||"ready"!==b||null===k)return;let e="".concat(null!=y?y:"__no_email__","::").concat(k,"::").concat(A);if(x.current===e)return;x.current=e,h({kind:"loading"});let t=e=>{(0,u.R)(e)},n=!1,r=!1,i=e=>{r=!0,h(e)};return(async()=>{try{var e,r,u,l,s,c;let d=await (0,o.X)();if(n)return;if(!d)return void i({kind:"error",message:"Unable to obtain access token."});if(!y){t(!1),i({kind:"ready",entities:[],projects:[],email:null,serviceAgreed:!0});return}let[m,p,f]=await Promise.all([(0,a.pZ)(d,y,k),(0,a.U7)(d,k),(0,a.Nv)(d,k)]);if(n)return;let g=m.err?m.err instanceof Error?m.err.message:String(m.err):null;g&&console.warn("[UserEntitiesProvider] entities/user returned an error",{email:y,message:g});let v=null!=(l=null==(e=m.data)?void 0:e.entities)?l:[],h=null!=(s=null==(r=m.data)?void 0:r.projects)?s:[],j=Array.isArray(f.data)?f.data:[],b=Array.isArray(p.data)?p.data:[],x=new Map;for(let e of[...h,...j]){if(!(null==e?void 0:e.prospectKey))continue;let t=x.get(e.prospectKey);x.set(e.prospectKey,t?{...t,...Object.fromEntries(Object.entries(e).filter(e=>{let[,t]=e;return void 0!==t}))}:e)}let A=Array.from(x.values()),w=v.map(e=>{var t,n,r,i,o,a;let u=b.find(t=>t.companyKey===e.companyKey);return{...e,toDos:null!=(n=null!=(t=null==u?void 0:u.toDos)?t:e.toDos)?n:[],corporateTxs:null!=(i=null!=(r=null==u?void 0:u.corporateTxs)?r:e.corporateTxs)?i:[],einTx:null!=(a=null!=(o=null==u?void 0:u.einTx)?o:e.einTx)?a:null}});if(console.info("[UserEntitiesProvider] loaded",{email:y,entityCount:w.length,inProgressProjectCount:h.length,submittedProjectCount:j.length,totalProjectCount:A.length,entitiesErr:g}),g&&0===A.length&&0===w.length){t(!1),i({kind:"error",message:g});return}t(w.length>0||A.length>0);let E=null==(c=null==(u=m.data)?void 0:u.serviceAgreed)||c;i({kind:"ready",entities:w,projects:A,email:y,serviceAgreed:E})}catch(e){if(n)return;i({kind:"error",message:e instanceof Error?e.message:String(e)})}})(),()=>{n=!0,r||x.current!==e||(x.current=null)}},[p,f,y,b,k,A]);let E=(0,i.useCallback)(()=>{h(e=>"ready"!==e.kind||e.serviceAgreed?e:{...e,serviceAgreed:!0})},[]),C=(0,i.useCallback)(()=>{w(e=>e+1)},[]),P=(0,i.useMemo)(()=>({markServiceAgreed:E,refetch:C}),[E,C]);return p&&f?(0,r.jsx)(c.Provider,{value:v,children:(0,r.jsx)(d.Provider,{value:P,children:m})}):(0,r.jsx)(c.Provider,{value:{kind:"loading"},children:(0,r.jsx)(d.Provider,{value:P,children:m})})}},75230:(e,t,n)=>{n.d(t,{M:()=>i,R:()=>o});let r="otonomos-ai:dashboard-populated-hint";function i(){try{return"1"===window.localStorage.getItem(r)}catch(e){return!1}}function o(e){try{e?window.localStorage.setItem(r,"1"):window.localStorage.removeItem(r)}catch(e){}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.