PageSourceSearch

https://daply.ai/assets/Onboarding-29HZKsYM.js

js daply.ai collected 2026-10-05 14:56:22 UTC 14,605 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-components-CrH3hhmI.js";import{r as a,d as re,b as se}from"./react-core-Df-1f7lZ.js";import{L as B,bZ as ae,cN as ne,b$ as ie,c0 as ce,cO as oe,Q as Z,cP as S,ab as le,cQ as ue,cR as de,cS as q,b as me,u as ge,n as he,cT as xe,cU as fe,cV as D,cW as J,cv as pe,c8 as be,cX as ye,A as V,m as T}from"./index-baCrhAE7.js";import{O as we,C as Se,G as je}from"./OnboardingPagePanel-DUjRi6lX.js";import{c as ve,a as Ne,b as Pe}from"./subscriptionService-QYWGS-JN.js";import"./utils-BZSOOpUI.js";import"./editor-wwdhYSyT.js";import"./charts-DACaTPEh.js";const z=5;function Ee({onPaid:t}){const s=ie(),l=ce(),[c,m]=a.useState(!1),[n,h]=a.useState(""),[i,y]=a.useState(!1),g=async f=>{if(f.preventDefault(),!(!s||!l)){m(!0),h("");try{const{error:p,paymentIntent:r}=await s.confirmPayment({elements:l,redirect:"if_required",confirmParams:{return_url:typeof window<"u"?window.location.href:void 0}});if(p){h(p.message||"Payment failed. Please try again.");return}if(r?.status==="succeeded"){await Ne(r.id),t?.();return}h("Payment did not complete. Please try again.")}catch(p){h(p?.response?.data?.error||p?.message||"Payment failed. Please try again.")}finally{m(!1)}}};return e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsx(oe,{onReady:()=>y(!0)}),n&&e.jsx("p",{className:"text-xs text-red-500",children:n}),e.jsx(Z,{type:"submit",label:c?"Processing…":`Pay $${z}`,disabled:c||!s||!i,color:"blue-700",className:"w-full justify-center bg-blue-600 hover:bg-blue-500 text-white border border-blue-700"})]})}function Ce({isDarkMode:t,cmsId:s,onPaid:l,onAlreadyPaid:c}){const[m,n]=a.useState(""),[h,i]=a.useState(!0),[y,g]=a.useState("");return a.useEffect(()=>{let f=!1;return s&&(async()=>{i(!0),g("");try{const r=await ve(s);if(f)return;if(r?.alreadyPaid){c?.();return}if(!r?.clientSecret){g("Could not start payment. Please try again.");return}n(r.clientSecret)}catch(r){if(f)return;g(r?.response?.data?.error||r?.message||"Could not start payment. Please try again.")}finally{f||i(!1)}})(),()=>{f=!0}},[s,c]),e.jsxs("div",{className:"p-6 pt-7 pb-10",children:[e.jsx("div",{className:"flex justify-center mb-5",children:e.jsx("img",{src:t?"/logo-full-light.svg":"/logo-full-dark.svg",alt:"Daply",className:"h-8",onError:f=>{f.currentTarget.src="/logo.svg"}})}),e.jsx("h2",{className:`text-center text-xl font-extrabold tracking-tight mb-1 ${t?"text-white":"text-gray-900"}`,children:"Complete your payment"}),e.jsxs("p",{className:`text-center text-sm mb-7 ${t?"text-gray-400":"text-gray-500"}`,children:["Pay $",z," to finish setting up your workspace."]}),e.jsxs("div",{className:"max-w-sm mx-auto",children:[h&&e.jsxs("div",{className:"text-center py-6",children:[e.jsx(B,{className:`h-8 w-8 animate-spin mx-auto mb-3 ${t?"text-blue-400":"text-blue-500"}`}),e.jsx("p",{className:`text-sm ${t?"text-gray-300":"text-gray-600"}`,children:"Preparing checkout…"})]}),!h&&y&&!m&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:y}),!h&&m&&e.jsx(ae,{stripe:ne(),options:{clientSecret:m,appearance:{theme:t?"night":"stripe"}},children:e.jsx(Ee,{onPaid:l})})]})]})}function Re({onChange:t,isDarkMode:s=!1,disabled:l=!1}){const c=a.useRef(null),m=a.useRef(!1),[n,h]=a.useState(!0),i=r=>{const u=c.current;if(!u)return null;const d=u.getBoundingClientRect(),w=r.touches?.[0]||r;return{x:(w.clientX-d.left)/d.width*u.width,y:(w.clientY-d.top)/d.height*u.height}},y=r=>{if(l)return;r.preventDefault();const d=c.current?.getContext("2d"),w=i(r);!d||!w||(m.current=!0,d.beginPath(),d.moveTo(w.x,w.y))},g=r=>{if(!m.current||l)return;r.preventDefault();const u=c.current,d=u?.getContext("2d"),w=i(r);!d||!w||(d.lineTo(w.x,w.y),d.stroke(),h(!1),t?.(u.toDataURL("image/png")))},f=()=>{m.current=!1},p=()=>{const r=c.current,u=r?.getContext("2d");!r||!u||(u.clearRect(0,0,r.width,r.height),h(!0),t?.(""))};return a.useEffect(()=>{const r=c.current,u=r?.getContext("2d");!r||!u||(u.strokeStyle=s?"#f8fafc":"#111827",u.lineWidth=2.4,u.lineCap="round",u.lineJoin="round")},[s]),e.jsxs("div",{className:"space-y-2",children:[e.jsx("canvas",{ref:c,width:640,height:180,className:`w-full h-36 rounded-xl border touch-none ${s?"bg-gray-950 border-gray-700":"bg-white border-gray-300"} ${l?"opacity-60":"cursor-crosshair"}`,onMouseDown:y,onMouseMove:g,onMouseUp:f,onMouseLeave:f,onTouchStart:y,onTouchMove:g,onTouchEnd:f}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:n?"Draw your signature above":"Signature captured"}),e.jsx("button",{type:"button",onClick:p,disabled:l||n,className:"text-xs font-medium text-blue-600 hover:text-blue-500 disabled:opacity-40",children:"Clear"})]})]})}function M(t){try{return new URL(t,window.location.origin).pathname}catch{return String(t||"")}}function Q(t){return M(t).toLowerCase().endsWith(".pdf")}function X(t){const s=M(t);return s===S||s===q||s.endsWith(S)||s.endsWith(q)}function ee(t){const s=String(t||"").trim();if(!s||X(s))return S;if(s.startsWith("/")&&Q(s))return s;try{const l=new URL(s,window.location.origin);if(X(l.pathname))return S;if((l.protocol==="http:"||l.protocol==="https:")&&Q(l.pathname))return l.toString()}catch{}return S}function K(t){const s=String(t||"").trim();if(!s)return S;const[l]=s.split("#");return`${l}#pagemode=none&toolbar=0&navpanes=0&scrollbar=1&view=FitH`}async function Ae(t){const s=ee(t);try{const l=new URL(s,window.location.origin);if(l.origin!==window.location.origin)return K(s);const c=await fetch(l.pathname,{credentials:"same-origin"}),m=String(c.headers.get("content-type")||"").toLowerCase();if(!c.ok||m.includes("text/html"))throw new Error("Agreement file is not a PDF");const n=await c.blob();if(n.type.includes("html"))throw new Error("Agreement file is not a PDF");return URL.createObjectURL(n.type.includes("pdf")?n:new Blob([n],{type:"application/pdf"}))}catch{return K(S)}}function Le({isDarkMode:t,cmsId:s,inviteToken:l,onSigned:c}){const[m,n]=a.useState(!0),[h,i]=a.useState(!1),[y,g]=a.useState(""),[f,p]=a.use
1State(!1),[r,u]=a.useState(S),[d,w]=a.useState(""),[$,E]=a.useState(!0),[C,R]=a.useState(""),[I,A]=a.useState(!1),[L,F]=a.useState(""),[_,j]=a.useState("");a.useEffect(()=>{let o=!1;const x=async()=>{n(!0),g(""),p(!1);try{const b=await ue(s,l);if(o)return;if(b?.alreadySigned){c?.(b);return}u(ee(b?.documentUrl)),R(b?.cmsName||"")}catch(b){if(o)return;u(S),p(!0);const v=b?.response?.status;g(b?.response?.data?.error||(v===404?"This workspace could not be found. Open the invite link again.":b?.message)||"Could not load the publisher agreement.")}finally{o||n(!1)}};return u(S),s?x():(p(!0),g("Missing workspace for this invite. Open the invite link again."),n(!1)),()=>{o=!0}},[s,l]),a.useEffect(()=>{let o=!1,x="";return(async()=>{E(!0);const v=await Ae(r);if(o){v.startsWith("blob:")&&URL.revokeObjectURL(v);return}v.startsWith("blob:")&&(x=v),w(v),E(!1)})(),()=>{o=!0,x&&URL.revokeObjectURL(x)}},[r]);const k=async o=>{if(o.preventDefault(),!I){g("Accept the agreement to continue.");return}if(L.trim().length<2){g("Enter your full legal name.");return}if(!_){g("Draw your signature to continue.");return}i(!0),g("");try{const x=await de(s,{token:l,accepted:!0,signerName:L.trim(),signatureData:_});c?.(x)}catch(x){const b=x?.response?.status;g(x?.response?.data?.error||(b===404?"This workspace could not be found. Open the invite link again.":x?.message)||"Could not save your signature. Please try again.")}finally{i(!1)}};return e.jsxs("div",{className:"p-4 sm:p-5 pb-8",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:t?"/logo-full-light.svg":"/logo-full-dark.svg",alt:"Daply",className:"h-8",onError:o=>{o.currentTarget.src="/logo.svg"}})}),e.jsx("h2",{className:`text-center text-xl font-extrabold tracking-tight mb-1 ${t?"text-white":"text-gray-900"}`,children:"Sign the publisher agreement"}),e.jsx("p",{className:`text-center text-sm mb-4 ${t?"text-gray-400":"text-gray-500"}`,children:C?`Review and digitally sign the legal document to join ${C} as a publisher. You will not be asked to add a card.`:"Review and digitally sign the legal document to join as a publisher. You will not be asked to add a card."}),m?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(B,{className:`h-8 w-8 animate-spin mx-auto mb-3 ${t?"text-blue-400":"text-blue-500"}`}),e.jsx("p",{className:`text-sm ${t?"text-gray-300":"text-gray-600"}`,children:"Loading agreement…"})]}):e.jsxs("form",{onSubmit:k,className:"space-y-5 w-full",children:[e.jsx("div",{className:`rounded-xl border overflow-hidden ${t?"border-gray-700":"border-gray-200"}`,children:$?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center bg-white",children:[e.jsx(B,{className:`h-8 w-8 animate-spin mb-3 ${t?"text-blue-400":"text-blue-500"}`}),e.jsx("p",{className:"text-sm text-gray-600",children:"Loading agreement PDF…"})]}):d?e.jsxs("div",{children:[e.jsx("iframe",{title:"Publisher agreement",src:d,className:"w-full h-[min(78vh,52rem)] bg-white"}),e.jsx("div",{className:"px-4 py-2 text-center border-t border-gray-200",children:e.jsx("a",{href:r||S,target:"_blank",rel:"noreferrer",className:"text-sm text-blue-600 hover:text-blue-500",children:"Open the publisher agreement in a new tab"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx(le,{className:`h-8 w-8 mb-3 ${t?"text-gray-500":"text-gray-400"}`}),e.jsx("p",{className:`text-sm ${t?"text-gray-300":"text-gray-600"}`,children:"Could not preview the agreement."}),e.jsx("a",{href:S,target:"_blank",rel:"noreferrer",className:"mt-3 text-sm text-blue-600 hover:text-blue-500",children:"Open the publisher agreement"})]})}),e.jsxs("div",{className:"max-w-2xl mx-auto w-full space-y-5",children:[e.jsxs("label",{className:"flex items-start gap-3 text-sm",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:o=>A(o.target.checked),className:"mt-1"}),e.jsx("span",{className:t?"text-gray-300":"text-gray-700",children:"I have read and accept this legal document, and I agree to be bound by it."})]}),e.jsxs("div",{children:[e.jsx("label",{className:`block text-sm font-medium mb-1 ${t?"text-gray-200":"text-gray-800"}`,children:"Full legal name"}),e.jsx("input",{type:"text",value:L,onChange:o=>F(o.target.value),placeholder:"Type your name as it should appear on the agreement",className:`w-full px-4 py-2 rounded-lg border ${t?"bg-gray-950 border-gray-700 text-white":"bg-white border-gray-300 text-gray-900"}`})]}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm font-medium mb-1 ${t?"text-gray-200":"text-gray-800"}`,children:"Digital signature"}),e.jsx(Re,{isDarkMode:t,disabled:h,onChange:j})]}),y&&e.jsx("p",{className:"text-sm text-red-500",children:y}),e.jsx(Z,{type:"submit",label:h?"Signing…":"Accept and sign",disabled:h||f||!r,color:"blue-700",className:"w-full justify-center bg-blue-600 hover:bg-blue-500 text-white border border-blue-700"})]})]})]})}const G="create_workspace",W="payment",U="publisher_agreement";function H(t){return t?String(typeof t=="object"?t._id||t.id||"":t):""}function Be(){const t=re(),[s]=se(),{theme:l}=me(),c=l==="dark",{isLoggedIn:m,user:n,fetchUser:h}=ge(),{selected:i,setSelected:y,fetchAllCms:g,cmsList:f,siteloading:p}=he(),[r,u]=a.useState(G),[d,w]=a.useState(!1),[$,E]=a.useState(!1),[C,R]=a.use
1State(!1),[I,A]=a.useState(""),{getInviteData:L}=xe(),F={token:s.get("invite")||"",cmsId:s.get("cmsId")||""},_=L(),j=a.useMemo(()=>fe(n,f),[n,f]),k=j||(D(n,i)||J(n,i)?i:null),o=F.token||_.inviteToken||"",x=H(F.cmsId||_.cmsId||I||k?._id);a.useEffect(()=>{try{sessionStorage.removeItem("should_create_cms_now")}catch{}},[]),a.useEffect(()=>{m&&g()},[m,g]),a.useEffect(()=>{if(!o){E(!1),A(""),R(!0);return}let N=!1;return R(!1),pe(o).then(P=>{N||(E(!!(P?.requiresPublisherAgreement&&P?.status==="pending")),A(P?.cmsId?String(P.cmsId):""),R(!0))}).catch(()=>{N||(E(!1),A(""),R(!0))}),()=>{N=!0}},[o,m]),a.useEffect(()=>{if(j&&i?._id!==j._id){y(j);try{localStorage.setItem("selected",JSON.stringify(j))}catch{}}},[j,i,y]);const b=a.useCallback(async N=>{if(!d){w(!0);try{const P=N||i?._id;P&&await Pe(P),await h()}catch{}finally{t("/dashboard",{replace:!0})}}},[d,i,h,t]),v=a.useCallback(async()=>{await h(),t("/dashboard",{replace:!0})},[h,t]),te=a.useCallback(async()=>{await g(),await h(),t("/content",{replace:!0})},[g,h,t]);a.useEffect(()=>{if(!m||d||!n||p&&!i&&!j&&!o||o&&!C)return;if(!!j||D(n,i)||$){u(U);return}if(o&&x&&n.needsOnboarding!==!0){t(`/members?cmsId=${encodeURIComponent(x)}&invite=${encodeURIComponent(o)}&tab=accept-invite`,{replace:!0});return}if(n.needsOnboarding!==!0){t("/dashboard",{replace:!0});return}if(J(n,i)){b(i?._id);return}if(!i){u(G);return}if(!!n?.onboarding?.setupFeePaidAt||be(n)||!ye(n,i)){b();return}u(W)},[m,d,p,i,j,o,x,C,$,n,t,b]);const O=m&&(p&&!i&&!k&&!x||!!o&&!C)&&r!==U,Y=o&&x||H(k?._id)||H(i?._id)||x;return e.jsxs(e.Fragment,{children:[e.jsx(V,{mode:"wait",children:m&&e.jsx(T.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},children:e.jsx(we,{isDarkMode:c,wide:r===U,scrollable:r===W||r===U,children:e.jsxs(V,{mode:"wait",children:[(O||d)&&e.jsx(T.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"p-7 py-10",children:e.jsxs("div",{className:"max-w-sm mx-auto text-center",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("img",{src:c?"/logo-full-light.svg":"/logo-full-dark.svg",alt:"Daply",className:"h-8",onError:N=>{N.currentTarget.src="/logo.svg"}})}),e.jsx(B,{className:`h-8 w-8 animate-spin mx-auto mb-4 ${c?"text-blue-400":"text-blue-500"}`}),e.jsx("p",{className:`text-sm font-medium ${c?"text-gray-300":"text-gray-600"}`,children:d?"Taking you to your dashboard…":"Setting up your workspace…"})]})},"ws-loading"),!O&&!d&&r===G&&e.jsx(T.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:e.jsx(Se,{isDarkMode:c,fetchAllCms:g,setSelected:y,onWorkspaceCreated:()=>u(W)})},"create-workspace"),!O&&!d&&r===W&&i&&e.jsx(T.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:e.jsx(Ce,{isDarkMode:c,cmsId:i._id,onPaid:v,onAlreadyPaid:v})},"payment"),!O&&!d&&r===U&&Y&&e.jsx(T.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},children:e.jsx(Le,{isDarkMode:c,cmsId:Y,inviteToken:o,onSigned:te})},"publisher-agreement")]})})},"onboarding")}),e.jsx(V,{children:!m&&e.jsx(je,{open:!0,startWithSignup:!0},"auth-modal")})]})}export{Be 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.