1import{r as S,j as d,e,bl as O,aE as P,F as f,x as b,B as R,i as u,Q as N,M as W,bm as _,aW as H,aX as $,bn as G,bo as D,bp as V,bq as B}from"./index-dK-KQR3u.js";import{C as x}from"./ColorPicker-DtIFk8qv.js";import{u as Q,r as F}from"./useGoogleFonts-Fqy5_7pk.js";import{T as A,c as K}from"./templates-api-BFxMJLMP.js";import{o as X,c as C,a as J,b as U,d as c,e as Y}from"./index.esm-DDWa65cW.js";import{u as Z,C as p}from"./index.esm-C4qE9m-H.js";import{A as y}from"./Autocomplete-AdwFbrGX.js";import"./chunk-hHWxwtHM.js";const ee=u("form",{target:"e1pcjagu2"})({name:"budh8k",styles:"display:flex;flex-direction:column;gap:16px"}),T="Failed to load fonts. Please try again.",m=u(N,{target:"e1pcjagu1"})({name:"1lt3k67",styles:"& .MuiFormHelperText-root{font-size:1.2rem;}"}),E=u("div",{target:"e1pcjagu0"})({name:"1yydxi7",styles:"display:flex;align-items:center;gap:8px"}),I=/^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/,re=C({srcProjectId:c().required("Project ID is required"),templateName:c().required("Template name is required"),tags:Y().of(c().required("Each tag must be a string")).optional(),fonts:C({primary:c().required("Primary font is required"),secondary:c().optional(),tertiary:c().optional()}).required(),colors:C({primary:c().required("Primary color is required").matches(I,"Primary color must be a valid hex color"),secondary:c().optional().matches(I,"Secondary color must be a valid hex color"),tertiary:c().optional().matches(I,"Tertiary color must be a valid hex color")}).required(),visibility:U().oneOf(Object.values(A),"Visibility must be SHOW or HIDE").required("Visibility is required"),rank:J().typeError("Rank must be a number").required("Rank is required")}),ae=({projectId:g,handleClose:v})=>{const h=S.useRef(null),a=Q(),{control:l,register:k,handleSubmit:j,formState:{errors:n,isSubmitting:w}}=Z({resolver:X(re),defaultValues:{srcProjectId:g,fonts:{primary:""},colors:{primary:""},visibility:A.HIDE,rank:0}}),L=async r=>{await K(r),v()},q=r=>{r.key!=="Enter"&&(r.key==="Tab"&&r.preventDefault(),r.stopPropagation())};return S.useEffect(()=>{const r=h.current;return r&&r.addEventListener("keydown",q),()=>{r&&r.removeEventListener("keydown",q)}},[]),d(ee,{ref:h,onSubmit:j(L),children:[e(m,{fullWidth:!0,label:"Template Name",variant:"outlined",inputProps:{...k("templateName")},error:!!n.templateName,helperText:n.templateName?n.templateName.message:""}),e(p,{name:"tags",control:l,render:({field:{onChange:r,onBlur:t,value:o}})=>e(y,{multiple:!0,freeSolo:!0,options:[],onChange:(i,s)=>{r(s)},onBlur:t,value:o,renderTags:(i,s)=>i.map((z,M)=>e(O,{label:z,...s({index:M}),sx:{fontSize:"1.5rem",margin:"4px"}})),renderInput:i=>e(m,{...i,label:"Tags",variant:"outlined"})})}),e(P,{variant:"caption",as:"h6",weight:700,children:"Fonts"}),e(p,{name:"fonts.primary",control:l,render:({field:r})=>e(y,{options:a.data??[],loading:a.isLoading,value:r.value,onChange:(t,o)=>r.onChange(o),disabled:a.isError,renderInput:t=>{var o,i,s;return e(m,{...t,label:"Primary Font",variant:a.isError?"standard":"outlined",error:!!((o=n.fonts)!=null&&o.primary)||a.isError,helperText:((s=(i=n.fonts)==null?void 0:i.primary)==null?void 0:s.message)??(a.isError?T:void 0),InputProps:{...t.InputProps,endAdornment:d(f,{children:[a.isLoading?e(b,{color:"primary",size:20}):null,t.InputProps.endAdornment]})}})}})}),e(p,{name:"fonts.secondary",control:l,render:({field:r})=>e(y,{options:a.data??[],loading:a.isLoading,value:r.value,onChange:(t,o)=>r.onChange(o),disabled:a.isError,renderInput:t=>{var o,i,s;return e(m,{...t,label:"Secondary Font",variant:a.isError?"standard":"outlined",error:!!((o=n.fonts)!=null&&o.secondary)||a.isError,helperText:((s=(i=n.fonts)==null?void 0:i.secondary)==null?void 0:s.message)??(a.isError?T:void 0),InputProps:{...t.InputProps,endAdornment:d(f,{children:[a.isLoading?e(b,{color:"primary",size:20}):null,t.InputProps.endAdornment]})}})}})}),e(p,{name:"fonts.tertiary",control:l,render:({field:r})=>e(y,{options:a.data??[],loading:a.isLoading,value:r.value,onChange:(t,o)=>r.onChange(o),disabled:a.isError,renderInput:t=>{var o,i,s;return e(m,{...t,label:"Tertiary Font",variant:a.isError?"standard":"outlined",error:!!((o=n.fonts)!=null&&o.tertiary)||a.isError,helperText:((s=(i=n.fonts)==null?void 0:i.tertiary)==null?void 0:s.message)??(a.isError?T:void 0),InputProps:{...t.InputProps,endAdornment:d(f,{children:[a.isLoading?e(b,{color:"primary",size:20}):null,t.InputProps.endAdornment]})}})}})}),e(P,{variant:"caption",as:"h6",weight:700,children:"Colors"}),e(p,{name:"colors.primary",control:l,render:({field:r})=>{var t,o;return d(E,{children:[e(x,{size:"48px",onChange:i=>r.onChange(F(i)),value:r.value||""}),e(m,{...r,fullWidth:!0,label:"Primary Color",variant:"outlined",placeholder:"#FFFFFF",error:!!((t=n.colors)!=null&&t.primary),helperText:(o=n.colors)!=null&&o.primary?n.colors.primary.message:""})]})}}),e(p,{name:"colors.secondary",control:l,render:({field:r})=>d(E,{children:[e(x,{size:"48px",onChange:t=>r.onChange(F(t)),value:r.value||""}),e(m,{...r,fullWidth:!0,label:"Secondary Color",variant:"outlined",placeholder:"#FFFFFF"})]})}),e(p,{name:"colors.tertiary",control:l,render:({field:r})=>d(E,{children:[e(x,{size:"48px",onChange:t=>r.onChange(F(t)),value:r.value||""}),e(m,{...r,fullWidth:!0,label:"Tertiary Color",variant:"outlined",placeholder:"#FFFFFF"})]})}),e(m,{fullWidth:!0,label:"Rank",variant:"outlined",type:"number",inputProps:{...k("rank")},error:!!n.rank,helperText:n.rank?n.rank.message:""}),e(R,{type:"submit",variant:"contained",color:"primary",disabled:w,children:"Save as Template"})]})},te=u("div",{target:"e1tqrtwq1"}
1)({name:"aj6721",styles:"position:absolute;border-radius:8px;padding:24px;overflow:auto;width:50vw;background:white;font-size:16px;max-height:90vh;top:50%;left:50%;transform:translate(-50%, -50%)"}),oe=u("div",{target:"e1tqrtwq0"})({name:"1talpdj",styles:"display:flex;align-items:center;justify-content:space-between;margin-bottom:16px"}),ue=({projectId:g,closeMenu:v})=>{const[h,a]=S.useState(!1),l=()=>{a(!1),v()};return d(B,{onClick:()=>a(!0),children:[e(H,{children:e(W,{src:_,size:"24px"})}),e($,{children:"Save as Template"}),e(V,{open:h,onClose:l,children:d(te,{children:[d(oe,{children:[e(P,{variant:"heading",as:"h3",children:"Save as Template"}),e(G,{ariaLabel:"close",onClick:l,children:e(D,{color:"secondary",fontSize:"large"})})]}),e(ae,{projectId:g,handleClose:l})]})})]})};export{ue as SaveAsTemplateMenuItem};
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.