1import{b as j,r as I,u as T,A as W,j as e,T as d,B as u,w as h}from"./index-BrT3F50e.js";import{M as _,a as R}from"./MainLayout-1gk5vpp4.js";import{g as v}from"./timezoneNormalizer-l1yj-VtS.js";import{F as t}from"./index-DObnsLqY.js";import{I as i}from"./index-BI2D8MSW.js";import{R as g,a as C}from"./InfoCircleOutlined-BBL5635V.js";import{T as L}from"./index-JIFlWX-e.js";import"./index-_hD6_PRw.js";import"./Sider-DNV35gRJ.js";import"./LeftOutlined-C9qxU1fR.js";import"./useBreakpoint-FD8ghq8d.js";import"./useForm-BVKnLQxW.js";import"./row-D-CZ3Hqh.js";import"./getAllowClear-C4A34otO.js";import"./Input-DOcZa3u3.js";import"./TextArea-BpydDq59.js";import"./styleChecker-CI4V7a_h.js";const{Title:K}=L;function O(){const n=j(),[w,c]=I.useState(!1),[l]=t.useForm(),{refreshWorkspaces:x}=T(),{message:m}=W.useApp(),p=r=>r?r.toLowerCase().replace(/[^a-z0-9]/g,"").substring(0,20):"",f=r=>{const a=r.target.value,s=p(a);l.setFieldsValue({id:s})},y=async r=>{try{c(!0);let a=null,s=null;if(r.website_url)try{const o=await h.detectFavicon(r.website_url);a=o.iconUrl,s=o.coverUrl||null}catch(o){console.error("Error detecting website assets:",o)}const k=v();await h.create({id:p(r.id),name:r.name,settings:{website_url:r.website_url||"",logo_url:a,cover_url:s,timezone:k,email_tracking_enabled:!0}}),await x(),m.success(`Workspace "${r.name}" created successfully!`),window.setTimeout(()=>{n({to:"/workspace/$workspaceId",params:{workspaceId:r.id}})},100)}catch(a){console.error("Error creating workspace:",a),m.error(a.message),c(!1)}},b=()=>{n({to:"/"})};return e.jsx(_,{children:e.jsx(R,{title:"New workspace",extra:e.jsx(u,{type:"primary",ghost:!0,icon:e.jsx(C,{}),onClick:b,style:{padding:"4px",lineHeight:1}}),children:e.jsxs(t,{name:"create-workspace",layout:"vertical",onFinish:y,autoComplete:"off",form:l,initialValues:{id:""},children:[e.jsx(t.Item,{label:"Workspace Name",name:"name",rules:[{required:!0,message:"Please enter a workspace name"},{min:3,message:"Workspace name must be at least 3 characters long"}],children:e.jsx(i,{placeholder:"Enter a name for your workspace",onChange:f})}),e.jsx(t.Item,{label:e.jsxs("span",{children:["Workspace ID Â ",e.jsx(d,{title:"This ID will be used in URLs and API requests. It can only contain lowercase letters, numbers, and hyphens.",children:e.jsx(g,{})})]}),name:"id",rules:[{required:!0,message:"Workspace ID is required"},{pattern:/^[a-z0-9-]+$/,message:"ID can only contain lowercase letters, numbers, and hyphens"}],children:e.jsx(i,{placeholder:"workspace-id",suffix:e.jsx(d,{title:"ID is automatically generated but can be modified if needed",children:e.jsx(g,{style:{color:"rgba(0,0,0,.45)"}})})})}),e.jsx(t.Item,{label:"Website URL",name:"website_url",rules:[{pattern:/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,message:"Please enter a valid URL",validateTrigger:"onBlur"}],extra:"We'll automatically detect and use your website's favicon",children:e.jsx(i,{placeholder:"https://example.com"})}),e.jsx(t.Item,{children:e.jsx(u,{type:"primary",htmlType:"submit",loading:w,style:{width:"100%",marginTop:20},children:"Create Workspace"})})]})})})}export{O as CreateWorkspacePage};
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.