1import{C as e,r as o}from"./vendor-core-kDn7q5nn.js";import{g as Y,l5 as se,i as ae,aY as oe,b as re,nG as le,ng as ie,nH as A,nI as g,A as G,nJ as O,kC as ce,kg as v}from"./app-shared-D9Va_FlY.js";/* empty css */import{B as ue}from"./Background-BrSTIDJh.js";import{g as J,b2 as F,z as j,B as D,l as Q}from"./antd-DUwX4n57.js";import"./pro-components-U2bZqxZr.js";import"./mapbox-DrKvbh0K.js";import"./xlsx-DLNWaC59.js";import"./calendar-C0yHFNg9.js";import"./iso-3166-D9CfHPRA.js";import"./charts-B4kAPUKr.js";import"./html2canvas-CBrSDip1.js";const de=[{value:"read",key:"read"},{value:"read_write",key:"readWrite"}],he=({consent:t,bundle:n,onBundleChange:l,disabled:c})=>{var d;const{t:a}=Y();return e.jsxs("div",{className:"oauth-consent__summary",children:[e.jsxs("dl",{className:"oauth-consent__facts",children:[e.jsxs("div",{className:"oauth-consent__fact",children:[e.jsx("dt",{children:a("portal:oauthConsent.client.label")}),e.jsxs("dd",{children:[e.jsx("bdi",{className:"oauth-consent__client-name",children:se(t.client_name)}),e.jsx("span",{className:"oauth-consent__note",children:a("portal:oauthConsent.client.selfReported")})]})]}),e.jsxs("div",{className:"oauth-consent__fact",children:[e.jsx("dt",{children:a("portal:oauthConsent.redirect.label")}),e.jsx("dd",{children:e.jsx("bdi",{dir:"ltr",className:"oauth-consent__host",children:t.redirect_host})})]}),e.jsxs("div",{className:"oauth-consent__fact",children:[e.jsx("dt",{children:a("portal:oauthConsent.account.label")}),e.jsx("dd",{children:e.jsx("bdi",{children:t.account_name})})]}),((d=t.company_name)==null?void 0:d.trim())&&e.jsxs("div",{className:"oauth-consent__fact",children:[e.jsx("dt",{children:a("portal:oauthConsent.company.label")}),e.jsx("dd",{children:e.jsx("bdi",{children:t.company_name})})]})]}),t.is_loopback&&e.jsx(J,{className:"oauth-consent__alert",type:"warning",showIcon:!0,title:a("portal:oauthConsent.loopback.title"),description:a("portal:oauthConsent.loopback.description")}),e.jsx("h2",{id:"oauth-consent-bundle-legend",className:"oauth-consent__legend",children:a("portal:oauthConsent.bundle.legend")}),e.jsx(F.Group,{className:"oauth-consent__bundles","aria-labelledby":"oauth-consent-bundle-legend",name:"oauth-consent-bundle",value:n,disabled:c,onChange:p=>l(p.target.value),children:de.map(({value:p,key:b})=>e.jsxs("div",{className:"oauth-consent__bundle",children:[e.jsx(F,{value:p,"aria-describedby":`oauth-consent-bundle-${b}`,children:a(`portal:oauthConsent.bundle.${b}.label`)}),e.jsx("p",{id:`oauth-consent-bundle-${b}`,className:"oauth-consent__bundle-description",children:a(`portal:oauthConsent.bundle.${b}.description`)})]},p))}),e.jsx("p",{className:"oauth-consent__note",children:a("portal:oauthConsent.roleHint")})]})},pe=new Set(["127.0.0.1","localhost","[::1]"]),me=t=>{const n=t.trim().toLowerCase();return n.includes(":")&&!n.startsWith("[")&&n.split(":").length>2?`[${n}]`:n},_e=(t,n,l)=>{if(typeof t!="string"||!t.trim()||!(n!=null&&n.trim()))return null;let c;try{c=new URL(t)}catch{return null}if(c.username||c.password)return null;const a=c.hostname.toLowerCase(),d=pe.has(a);if(c.protocol==="http:"){if(!d||!l)return null}else if(c.protocol!=="https:")return null;if(d!==l)return null;const p=me(n);return p!==a&&p!==c.host.toLowerCase()?null:c.toString()},E="request",H={not_entitled:"notEntitled",customer:"customer",disabled_by_company:"disabledByCompany"},fe=t=>typeof t=="string"&&t in H,V=t=>{var l;const n=(l=t==null?void 0:t.response)==null?void 0:l.status;return n===404||n===410},W=t=>{var l;const n=t==null?void 0:t.response;return(n==null?void 0:n.status)===409&&((l=n.data)==null?void 0:l.reason)==="bound_to_other_account"},Ae=()=>{const{t}=Y(),n=ae(),[l,c]=oe(),{authenticated:a,loading:d,bootUnreachable:p,attemptLogin:b,logout:B}=o.useContext(re),[r]=o.useState(()=>{const s=l.get(E);return s!==null?le(s)?s:null:ie()}),[_,m]=o.useState(r?"loading":"invalid"),[i,T]=o.useState(null),[w,I]=o.useState("read"),[L,k]=o.useState(null),[C,P]=o.useState(null),[X,q]=o.useState(0),R=o.useRef(!1),f=o.useRef(null);o.useEffect(()=>{document.title=t("portal:oauthConsent.pageTitle")},[t]),o.useEffect(()=>{if(r?A(r):g(),l.has(E)){const s=new URLSearchParams(l);s.delete(E),c(s,{replace:!0})}},[]);const Z=d,z=!d&&!a&&!!p,S=!d&&!a&&!p;o.useEffect(()=>{!r||!S||(A(r),n(G.LOGIN,{replace:!0}))},[r,S,n]),o.useEffect(()=>{if(!r||!a||d)return;let s=!1;return m("loading"),O.getConsent(r).then(h=>{s||(T(h),I(h.requested_bundle==="read_write"?"read_write":"read"),m("ready"))}).catch(h=>{s||(V(h)?(g(),m("invalid")):W(h)?(g(),m("boundToOther")):m("error"))}),()=>{s=!0}},[r,a,d,X]),o.useEffect(()=>{var s;_!=="loading"&&((s=f.current)==null||s.focus())},[_]);const y=o.useCallback(async(s,h)=>{var N;if(!(!r||!i||R.current)){R.current=!0,P(s),k(null);try{const{redirect_to:x}=await h(r);g();const u=_e(x,i.redirect_host,i.is_loopback);if(!u){m("unsafeRedirect");return}m("redirecting"),ce(u)}
1catch(x){if(V(x))g(),m("invalid");else if(W(x))g(),m("boundToOther");else{const u=x==null?void 0:x.response,$=(N=u==null?void 0:u.data)==null?void 0:N.reason;(u==null?void 0:u.status)===403&&fe($)?T({...i,eligible:!1,reason:$}):k((u==null?void 0:u.status)===402?"licenseExpired":"generic")}}finally{R.current=!1,P(null)}}},[r,i]),ee=o.useCallback(()=>y("approve",s=>O.approveConsent(s,w)),[y,w]),K=o.useCallback(()=>y("deny",s=>O.denyConsent(s)),[y]),te=o.useCallback(async()=>{r&&A(r),await B(),n(G.LOGIN,{replace:!0})},[r,B,n]),M=e.jsx("div",{className:"oauth-consent__switch",children:e.jsx(v,{type:"link",onClick:te,disabled:C!==null,errorMessage:!1,children:t("portal:oauthConsent.switchAccount")})}),U=L&&e.jsx(J,{className:"oauth-consent__alert",type:"error",showIcon:!0,title:t(L==="licenseExpired"?"portal:oauthConsent.error.licenseExpired":"portal:oauthConsent.error.decision")}),ne=()=>{var s;if(!r||_==="invalid")return e.jsx(j,{status:"warning",title:e.jsx("h1",{ref:f,tabIndex:-1,className:"oauth-consent__heading",children:t("portal:oauthConsent.invalid.title")}),subTitle:t("portal:oauthConsent.invalid.description")});if(_==="boundToOther")return e.jsx(j,{status:"warning",title:e.jsx("h1",{ref:f,tabIndex:-1,className:"oauth-consent__heading",children:t("portal:oauthConsent.boundToOther.title")}),subTitle:t("portal:oauthConsent.boundToOther.description")});if(z||_==="error")return e.jsx(j,{status:"error",title:e.jsx("h1",{ref:f,tabIndex:-1,className:"oauth-consent__heading",children:t("portal:oauthConsent.error.title")}),subTitle:t("portal:oauthConsent.error.description"),extra:e.jsx(D,{type:"primary",onClick:()=>{z?b():q(h=>h+1)},children:t("portal:oauthConsent.error.retry")})});if(Z||S||_==="loading"||!i)return e.jsx("div",{role:"status","aria-live":"polite","aria-label":t("portal:oauthConsent.loading"),children:e.jsx(Q,{active:!0,title:!0,paragraph:{rows:5}})});if(_==="unsafeRedirect")return e.jsx(j,{status:"error",title:e.jsx("h1",{ref:f,tabIndex:-1,className:"oauth-consent__heading",children:t("portal:oauthConsent.unsafeRedirect.title")}),subTitle:t("portal:oauthConsent.unsafeRedirect.description")});if(_==="redirecting")return e.jsxs("div",{role:"status","aria-live":"polite",children:[e.jsx("h1",{ref:f,tabIndex:-1,className:"oauth-consent__heading",children:t("portal:oauthConsent.redirecting")}),e.jsx(Q,{active:!0,title:!1,paragraph:{rows:2}})]});if(!i.eligible){const h=i.reason?H[i.reason]:void 0;return e.jsxs(e.Fragment,{children:[e.jsx(j,{status:"info",title:e.jsx("h1",{ref:f,tabIndex:-1,className:"oauth-consent__heading",children:t("portal:oauthConsent.blocked.title")}),subTitle:t(`portal:oauthConsent.blocked.${h??"generic"}`),extra:e.jsxs("span",{className:"oauth-consent__note",children:[t("portal:oauthConsent.account.label"),": ",e.jsx("bdi",{children:i.account_name}),((s=i.company_name)==null?void 0:s.trim())&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("bdi",{children:i.company_name})]})]})}),U,e.jsxs("div",{className:"oauth-consent__actions",children:[e.jsx(v,{size:"large",onClick:K,errorMessage:!1,children:t("portal:oauthConsent.deny")}),i.reason!=="customer"&&e.jsx(D,{type:"primary",size:"large",disabled:C!==null,onClick:()=>{k(null),q(N=>N+1)},children:t("portal:oauthConsent.blocked.recheck")})]}),M]})}return e.jsxs(e.Fragment,{children:[e.jsx("h1",{ref:f,tabIndex:-1,className:"oauth-consent__heading",children:t("portal:oauthConsent.heading")}),e.jsx("p",{className:"oauth-consent__intro",children:t("portal:oauthConsent.intro")}),e.jsx(he,{consent:i,bundle:w,onBundleChange:I,disabled:C!==null}),U,e.jsxs("div",{className:"oauth-consent__actions",children:[e.jsx(v,{size:"large",onClick:K,disabled:C==="approve",errorMessage:!1,children:t("portal:oauthConsent.deny")}),e.jsx(v,{type:"primary",size:"large",onClick:ee,disabled:C==="deny",errorMessage:!1,children:t("portal:oauthConsent.approve")})]}),M]})};return e.jsx(ue,{children:e.jsx("main",{className:"oauth-consent oauth-consent__state",children:ne()})})};export{Ae as default};
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.