1import{j as e,h as t,r as s,eH as r,fN as a,g9 as o}from"./vendor.BneZ12fQ.js";import{u as i,a as l,b as m,q as n,L as c,A as p,c as d,O as x,C as u,I as j,d as f,V as h,T as b,P as _,D as v,e as g,B as y,f as w}from"./index.08gH9Ul-.js";import"./utilities.B_85_qqX.js";import{b as N,F as T,C as S}from"./forms.Zn99hHAv.js";import"./validation.5qx4JD53.js";import"./math-katex.Bw_N0rIA.js";import"./locales.D31PhMBo.js";import"./i18n.qpAXbdaN.js";import"./routing.CPxdrpdD.js";import"./radix-ui.DyEnOaHl.js";import"./react-interactions.BLj71M4e.js";import"./tanstack-vendor.BX6ev4Ss.js";import"./avatars.B-PntWQn.js";import"./advanced-inputs.9N-gK3zk.js";import"./virtualization.DAQAA7sP.js";import"./animations.DVtXuYGa.js";import"./headlessui.BK4q-QJj.js";import"./framer-motion.CykaD6Wu.js";import"./http-client.CoC4amwk.js";import"./date-utils.Bw39LL8F.js";import"./sandpack.f8Lxp6q2.js";import"./codemirror-core.Bci8E00X.js";import"./codemirror-state.C8nmO8dc.js";import"./codemirror-view.BO9MoAnA.js";import"./codemirror-language.Bt8JmF10.js";import"./markdown-processing.D3hw0oYM.js";import"./markdown_highlight.C1JtaQIn.js";import"./security-ui.DFG-TMIJ.js";import"./code-editor.CiOZSoMr.js";import"./heic-converter.Cz_Prg7D.js";import"./react-vtree.LTRSAQ0F.js";function k(){const t=i();return e.jsx("div",{className:"h-full w-full content-center text-center font-bold text-text-secondary",children:t("com_ui_select_or_create_prompt")})}const I={name:"",prompt:"",type:"text",category:"",oneliner:void 0,command:void 0},C=({defaultValues:a=I,onSuccess:o})=>{const w=i(),k=t(),{hasAccess:C}=l()??{},P=m({permissionType:n.PROMPTS,permission:c.CREATE}),R=C&&P;s.useEffect((()=>{let e;return R||o||(e=setTimeout((()=>{k("/c/new")}),1e3)),()=>{clearTimeout(e)}}),[R,k,o]);const q=N({defaultValues:{...a,category:localStorage.getItem(p.LAST_PROMPT_CATEGORY)??""}}),{watch:V,control:E,handleSubmit:A,formState:{isDirty:O,isSubmitting:M,errors:z,isValid:D}}=q,F=d({onSuccess:e=>{const t=e.prompt.groupId;o&&t?o(t):k(`/prompts/${t}`,{replace:!0})}}),L=V("prompt");return R?e.jsx(T,{...q,children:e.jsxs("form",{onSubmit:A((e=>{const{name:t,category:s,oneliner:r,command:a,...o}=e,i={name:t,category:s};(r?.length??0)>0&&(i.oneliner=r),(a?.length??0)>0&&(i.command=a),F.mutate({prompt:o,group:i})})),className:"w-full px-4 py-2",children:[e.jsx("h1",{className:"sr-only",children:w("com_ui_create_prompt_page")}),e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 sm:hidden",children:[e.jsx(x,{}),e.jsx(u,{})]}),e.jsx("div",{className:"mb-1 flex flex-col items-center justify-between font-bold sm:text-xl md:mb-0 md:text-2xl",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-between sm:flex-row",children:[e.jsx(S,{name:"name",control:E,rules:{required:w("com_ui_prompt_name_required")},render:({field:t})=>e.jsxs("div",{className:"relative mb-1 flex w-full flex-col sm:w-auto md:mb-0",children:[e.jsx(j,{...t,id:"prompt-name",type:"text",className:"peer mr-2 w-full border border-border-medium p-2 text-2xl text-text-primary",placeholder:" ",tabIndex:0,"aria-label":w("com_ui_prompt_name"),"aria-required":"true"}),e.jsxs("label",{htmlFor:"prompt-name",className:"pointer-events-none absolute -top-1 left-3 origin-[0] translate-y-3 scale-100 rounded bg-presentation px-1 text-base text-text-secondary transition-transform duration-200 peer-placeholder-shown:translate-y-3 peer-placeholder-shown:scale-100 peer-focus:-translate-y-2 peer-focus:scale-75 peer-focus:text-text-primary peer-[:not(:placeholder-shown)]:-translate-y-2 peer-[:not(:placeholder-shown)]:scale-75",children:[w("com_ui_prompt_name"),"*"]}),e.jsx("div",{className:f("mt-1 w-56 text-sm text-red-500",z.name?"visible h-auto":"invisible h-0"),children:z.name?z.name.message:" "})]})}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(u,{})})]})}),e.jsxs("div",{className:"flex w-full flex-col gap-4 md:mt-[1.075rem]",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("header",{className:"flex items-center justify-between rounded-t-xl border border-border-medium bg-transparent p-2",children:[e.jsxs("div",{className:"ml-1 flex items-center gap-2",children:[e.jsx(r,{className:"size-4 text-text-secondary","aria-hidden":"true"}),e.jsxs("h2",{className:"text-sm font-semibold text-text-primary",children:[w("com_ui_prompt_text"),"*"]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-2",children:e.jsx(h,{fieldName:"prompt"})})]}),e.jsx("div",{className:"min-h-32 rounded-b-xl border border-t-0 border-border-medium p-3 sm:p-4",children:e.jsx(S,{name:"prompt",control:E,rules:{required:w("com_ui_prompt_text_required")},render:({field:t})=>e.jsxs("div",{children:[e.jsx(b,{...t,className:"w-full resize-none overflow-y-auto bg-transparent font-mono text-sm leading-relaxed text-text-primary placeholder:text-text-tertiary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring-primary sm:text-base",minRows:4,maxRows:16,tabIndex:0,placeholder:w("com_ui_prompt_input"),"aria-label":w("com_ui_prompt_input_field"),"aria-required":"true"}),e.jsx("div",{className:f("mt-1 text-sm text-red-500",z.prompt?"visible h-auto":"invisible h-0"),children:z.prompt?z.prompt.message:" "})]})})})]}),e.jsx(_,{promptText:L}),e.jsx(v,{onValueChange:e=>q.setValue("oneliner",e),tabIndex:0}),e.jsx(g,{onValueChange:e=>q.setValue("command",e),tabIndex:0}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(y,{"aria-label":w("com_ui_create_prompt"),className:f("w-full sm:w-auto",(!O||M||!D)&&"opacity-50"),tabIndex:0,type:"submit","aria-disabled":!O||M||!D||void 0,onClick:e=>{O&&!M&&D||e.preventDefault()},children:w("com_ui_create_prompt")})})]})]})}):null};function P(){const{promptId:r}=a(),i=t(),l=void 0===r,p=m({permissionType:n.PROMPTS,permission:c.USE}),d=m({permissionType:n.PROMPTS,permission:c.CREATE}),x=s.useCallback((e=>{i(`/prompts/${e}`,{replace:!0})}),[i]);return p?l&&!d?e.jsx(k,{}):e.jsx("div",{className:"flex h-full w-full flex-col overflow-y-auto bg-presentation",children:l?e.jsx(C,{onSuccess:x}):e.jsx(w,{promptId:r})}):e.jsx(o,{to:"/c/new",replace:!0})}export{P 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.