PageSourceSearch

https://studio.findem.ai/assets/Account-BW7LzWIo.js

js findem.ai collected 2026-10-02 05:22:17 UTC 12,041 bytes, 1 lines download raw bytes

1import{r,f3 as B,j as e,N as W,B as S,S as M,T as q,y as H,e4 as J,b as V,c as K,f as U,f4 as C,f5 as G,f6 as Q,f7 as X,f8 as O,au as E,f9 as T,O as Z,m as z,q as ee,fa as te,g as se,bM as ae,cl as re}from"./index-_Ci2S7BU.js";function ie({api:s=B}){const[u,a]=r.useState(null),[m,f]=r.useState(!0),[v,c]=r.useState(!1),[x,i]=r.useState(""),[b,h]=r.useState(!1),[y,k]=r.useState(0);r.useEffect(()=>{let o=!0;return f(!0),i(""),s.get().then(l=>{if(typeof l?.notify_on_completion!="boolean")throw new Error("Invalid settings response");o&&a(l)}).catch(()=>{o&&i("Could not load your notification preferences. Please try again.")}).finally(()=>{o&&f(!1)}),()=>{o=!1}},[s,y]),r.useEffect(()=>{m||typeof window>"u"||window.location?.hash!=="#notifications"||document.getElementById("notifications")?.scrollIntoView?.({block:"start"})},[m]);async function p(o){if(!v){c(!0),h(!1),i("");try{const l=await s.update({notify_on_completion:o});if(l?.notify_on_completion!==o)throw new Error("Settings were not saved");a(l),h(!0)}catch{i("Could not confirm that your preference was saved. Please try again.")}finally{c(!1)}}}return e.jsxs("section",{id:"notifications",className:"pt-7","aria-labelledby":"account-notifications-heading",children:[e.jsx("h2",{id:"account-notifications-heading",className:"text-base font-semibold text-ink",children:"Notifications"}),x?e.jsxs(W,{tone:"danger",className:"mt-4",role:"alert",children:[x,!u&&!m?e.jsx(S,{theme:"studio",size:"sm",className:"ml-3",onClick:()=>k(o=>o+1),children:"Try again"}):null]}):null,m?e.jsx("div",{className:"mt-4 flex items-center gap-2 text-sm text-ink-soft",role:"status",children:e.jsx(M,{label:"Loading notification preferences…"})}):u?e.jsxs("div",{className:"mt-2 grid gap-x-6 gap-y-2 border-b border-paper-border py-3.5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{id:"solution-email-label",className:"text-sm font-medium text-ink",children:"Email me when a solution completes"}),e.jsxs("p",{id:"solution-email-description",className:"mt-0.5 text-sm text-ink-soft",children:["A link to your results, even after you close Studio.",u.recipient_email?e.jsxs(e.Fragment,{children:[" Sent to ",e.jsx("span",{className:"break-words text-ink",children:u.recipient_email}),"."]}):null]}),e.jsx("p",{className:"mt-1 text-xs text-ink-soft empty:hidden",role:"status",children:v?"Saving…":b?"Preference saved.":""})]}),e.jsx(q,{theme:"studio",checked:u.notify_on_completion,disabled:v,onChange:p,label:e.jsx("span",{className:"sr-only",children:"Email me when a solution completes"}),ariaDescribedBy:"solution-email-description",className:"sm:justify-self-end"})]}):null]})}const j="grid gap-x-6 gap-y-2 border-b border-paper-border py-3.5 sm:grid-cols-[minmax(0,220px)_minmax(0,1fr)] sm:items-center";function ne({auth:s,api:u=G}){const[a,m]=r.useState(()=>C(s.user)),[f,v]=r.useState(null),[c,x]=r.useState(!0),[i,b]=r.useState(!1),[h,y]=r.useState(""),[k,p]=r.useState(""),[o,l]=r.useState(0),[N,g]=r.useState(!1),w=r.useRef(null),P=r.useRef(null),A=()=>{g(!1),P.current?.focus()};r.useEffect(()=>{if(!N)return;const t=d=>{w.current&&!w.current.contains(d.target)&&g(!1)},n=d=>{d.key==="Escape"&&(d.preventDefault(),A())};return w.current?.querySelector('[aria-pressed="true"]')?.focus(),window.addEventListener("mousedown",t),window.addEventListener("keydown",n),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",n)}},[N]),r.useEffect(()=>{let t=!0;return x(!0),y(""),u.get().then(({profile:n})=>{if(!t)return;if(n?.user_id!==s.user.id)throw new Error("We could not verify your profile. Please retry.");const d=C(s.user,n);m(d),v(d)}).catch(n=>{t&&y(n.status===404?"Account preferences are not available on this server yet.":n.message||"Could not load your profile.")}).finally(()=>{t&&x(!1)}),()=>{t=!1}},[u,s.user.id,o]);const _=(t,n)=>{p(""),m(d=>({...d,[t]:n,...t==="work_category"&&n!=="other"?{work_title:""}:{}}))},I=f&&JSON.stringify(a)!==JSON.stringify(f),L=a.display_name.trim()&&(a.work_category!=="other"||a.work_title.trim());async function Y(t){if(t.preventDefault(),!(!f||!I||!L||i)){b(!0),y(""),p("");try{const n={...a,display_name:a.display_name.trim(),work_title:a.work_title.trim()},{profile:d}=await u.save(n);if(d?.user_id!==s.user.id)throw new Error("We could not verify the saved profile. Please reload.");const F=C(s.user,d);m(F),v(F),s.updateAccountProfile?.(d),p("Profile saved.")}catch(n){y(n.message||"Could not save your profile. Your changes are still here.")}finally{b(!1)}}}const R=Q({name:a.display_name,email:s.user.email}),D=X(a.avatar_glyph)||"initials",$=O.find(t=>
1t.id===D);return e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:Y,"aria-labelledby":"account-about-heading","aria-busy":c||i,children:[e.jsx("h2",{id:"account-about-heading",className:"text-base font-semibold text-ink",children:"About you"}),e.jsxs("div",{className:j,children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:"Avatar"}),e.jsxs("div",{ref:w,className:"relative flex items-center",children:[e.jsxs("button",{ref:P,type:"button","aria-haspopup":"true","aria-expanded":N,"aria-label":`Change avatar, currently ${$?.label||"Initials"}`,disabled:c||i,onClick:()=>g(t=>!t),className:`group relative flex h-12 w-12 shrink-0 items-center justify-center rounded-full text-sm font-semibold disabled:opacity-60 ${E.accountAvatar}`,children:[e.jsx(T,{glyph:a.avatar_glyph,fallback:R,size:24}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 grid place-items-center rounded-full bg-ink/45 text-white opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100",children:e.jsx(Z,{size:15,strokeWidth:2.2})})]}),N?e.jsx("div",{role:"group","aria-label":"Choose your avatar",className:"absolute left-0 top-[calc(100%+8px)] z-20 flex w-[248px] flex-wrap gap-1.5 rounded-xl border border-paper-border bg-white p-2 shadow-[0_18px_48px_rgba(0,0,0,0.18)]",children:O.map(t=>{const n=D===t.id;return e.jsx("button",{type:"button","aria-label":t.label,"aria-pressed":n,title:t.label,onClick:()=>{_("avatar_glyph",t.id),A()},className:`flex h-9 w-9 items-center justify-center rounded-[9px] text-[11px] font-semibold transition-colors ${n?E.accountAvatar:E.accountAvatarChoice}`,children:e.jsx(T,{glyph:t.id,fallback:R,size:18})},t.id)})}):null]})]}),e.jsxs("div",{className:j,children:[e.jsx("label",{htmlFor:"account-name",className:"text-sm font-medium text-ink",children:"Your name"}),e.jsx(z,{id:"account-name",name:"display_name",theme:"studio",value:a.display_name,required:!0,maxLength:120,autoComplete:"name",disabled:c||i,onChange:t=>_("display_name",t.target.value)})]}),e.jsxs("div",{className:j,children:[e.jsx("label",{htmlFor:"account-work",className:"text-sm font-medium text-ink",children:"What best describes your work?"}),e.jsxs(ee,{id:"account-work",name:"work_category",theme:"studio",value:a.work_category,disabled:c||i,onChange:t=>_("work_category",t.target.value),children:[e.jsx("option",{value:"",children:"Select your work"}),te.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))]})]}),a.work_category==="other"?e.jsxs("div",{className:j,children:[e.jsx("label",{htmlFor:"account-work-title",className:"text-sm font-medium text-ink",children:"Your work or job title"}),e.jsx(z,{id:"account-work-title",theme:"studio",name:"work_title",placeholder:"e.g. Product designer",value:a.work_title,required:!0,maxLength:120,disabled:c||i,onChange:t=>_("work_title",t.target.value)})]}):null,c?e.jsx("p",{role:"status",className:"mt-4 text-sm text-ink-soft",children:"Loading your profile…"}):null,h?e.jsxs(W,{role:"alert",tone:"danger",className:"mt-4",children:[h,f?null:e.jsx(S,{theme:"studio",size:"sm",className:"ml-3",onClick:()=>l(t=>t+1),children:"Retry"})]}):null,k?e.jsx("p",{role:"status",className:"mt-4 text-sm text-ink-soft",children:k}):null,I?e.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-3",children:[e.jsx(S,{theme:"studio",disabled:i,onClick:()=>{m(f),y(""),p("")},children:"Cancel"}),e.jsx(S,{theme:"studio",type:"submit",variant:"primary",disabled:!L||i||c,loading:i,children:"Save changes"})]}):null]})})}function oe({auth:s,api:u=G}){const a=s.mcpScopeOrg?.mcp_org_id,[m,f]=r.useState(null),[v,c]=r.useState(""),[x,i]=r.useState(!1),[b,h]=r.useState(""),[y,k]=r.useState(0);if(r.useEffect(()=>{if(!a||s.isPersonalMcpScope)return;let g=!0;return f(null),c(""),i(!1),h(""),u.workspace(a).then(w=>{if(g){if(w?.mcp_org_id!==a)throw new Error("Workspace details could not be verified.");f(w)}}).catch(w=>{g&&c(w.message||"Could not load workspace details.")}),()=>{g=!1}},[u,s.user.id,a,s.isPersonalMcpScope,y]),!a||s.isPersonalMcpScope)return null;const p=m?.mcp_org_id===a?m:null,o=p||s.mcpScopeOrg,l=p?p.primary_owner:s.mcpScopeOrg.is_primary_owner?{name:s.user.n
1ame,email:s.user.email,is_you:!0}:null,N=o?.is_primary_owner?"Primary owner":{owner:"Owner",admin:"Admin",member:"Member"}[o?.role]||"Not available";return e.jsxs("section",{className:"pt-7","aria-labelledby":"account-workspace-heading",children:[e.jsxs("h2",{id:"account-workspace-heading",className:"text-base font-semibold text-ink",children:["Current workspace: ",e.jsx("span",{className:"font-medium text-ink-soft",children:s.mcpScopeLabel})]}),e.jsx("p",{className:"mt-1.5 text-sm text-ink-soft",children:"These apply only while you are in this workspace. Your profile above follows you everywhere."}),e.jsxs("dl",{className:"mt-2",children:[e.jsxs("div",{className:j,children:[e.jsx("dt",{className:"text-sm font-medium text-ink",children:"Your role"}),e.jsx("dd",{className:"sm:text-right",children:e.jsx(se,{theme:"studio",children:N})})]}),e.jsxs("div",{className:j,children:[e.jsx("dt",{className:"text-sm font-medium text-ink",children:"Primary owner"}),e.jsx("dd",{className:"min-w-0 text-sm sm:text-right",children:l?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-ink",children:l.is_you?`${s.user.name||l.name||"You"} (you)`:l.name||"Primary owner"}),l.email?e.jsx("p",{className:"break-all text-ink-soft",children:l.email}):null]}):v?e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"alert",className:"text-ink-soft",children:"Could not load the primary owner."}),e.jsx(S,{theme:"studio",className:"mt-2",size:"sm",onClick:()=>k(g=>g+1),children:"Retry"})]}):e.jsx("span",{role:p?void 0:"status",className:"text-ink-soft",children:p?"Not available":"Loading owner details…"})})]}),e.jsxs("div",{className:j,children:[e.jsx("dt",{className:"text-sm font-medium text-ink",children:"Workspace ID"}),e.jsx("dd",{className:"flex min-w-0 items-center gap-2 sm:justify-end",children:e.jsxs("button",{type:"button","aria-label":x?"Workspace ID copied":"Copy workspace ID",title:"Click to copy",onClick:async()=>{h(""),i(!1);try{await navigator.clipboard.writeText(a),i(!0)}catch{h("Could not copy. Select the workspace ID to copy it manually.")}},className:"group inline-flex min-w-0 items-center gap-1.5 rounded-md bg-paper-soft px-2 py-1 text-left font-mono text-xs text-ink-soft transition-colors hover:bg-paper-active hover:text-ink",children:[e.jsx("span",{className:"min-w-0 break-all",children:a}),x?e.jsx(ae,{size:12,className:"shrink-0 text-ink"}):e.jsx(re,{size:12,className:"shrink-0 opacity-0 transition-opacity group-hover:opacity-100"})]})})]})]}),x?e.jsx("p",{role:"status",className:"mt-2 text-xs text-ink-soft",children:"Workspace ID copied."}):null,b?e.jsx("p",{role:"alert",className:"mt-2 text-xs text-ink-soft",children:b}):null]})}function ce(){const s=H();return s.user?e.jsx(J,{children:e.jsx(V,{children:e.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[e.jsx(K,{title:"Profile",description:"How you appear, and how Studio reaches you, across all your workspaces."}),e.jsxs(U,{theme:"studio",padding:"lg",children:[e.jsx(ne,{auth:s},s.user.id),e.jsx(ie,{},`notifications:${s.user.id}`),e.jsx(oe,{auth:s},`${s.user.id}:${s.mcpScopeId}`)]})]})})}):null}export{ne as AccountProfileForm,oe as AccountWorkspaceDetails,ce 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.