import{n as e,Q as a,p as l,P as s,M as t,k as o,e as n}from"./utils-lib.js?v=1761009159";import{c,r,q as i,v as m,x as u,z as d,e as p,y as E,B as v,F as f,b0 as y,Q as x,D as _,C as I,ah as k,G as V,A as D,ai as T}from"./base-lib.js?v=1761009159";import{aj as A}from"./config.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const h={class:"p-24px"},R={class:"flex items-center"},b={class:"w-[20rem] flex ml-[1rem]"},C={class:"my-6 flex items-center leading-[3rem]"},w={class:"flex ml-[1rem]"},g={key:0,class:"flex mt-12px"},N={class:"flex-1 mr-20px"},P={class:"flex-1"},S={class:"list-disc text-secondary px-20px pt-12px"},j={class:"flex items-center"},F=c({__name:"no-port-config",props:{compData:{}},emits:["close"],setup(c,{emit:F}){const K=c,Y=F,z=r("auto"),B=[{title:"自定义证书",value:"auto"},{title:"不部署证书",value:"no"},{title:"选择已有证书",value:"select"}],G=r(K.compData),U=l=>{z.value=l,"select"===l&&e({title:"选择已有证书",component:()=>a(()=>import("./cert-list-dialog.js?v=1761009159"),__vite__mapDeps([]),import.meta.url),area:70,compData:{refreshData:e=>{G.value.domain=(null==e?void 0:e.dns[0].replace(/^\*\./,"panel."))||"",G.value.cert=(null==e?void 0:e.fullchain)||"",G.value.key=(null==e?void 0:e.privkey)||"",G.value.certInfo=e.info||{}}}})},M=async()=>{(K.compData.domain?/^(?!:\/\/)([a-zA-Z0-9-_]{1,63}\.)+[a-zA-Z]{2,6}$/.test(K.compData.domain)?"no"===z.value||K.compData.key&&K.compData.cert||(t.error("请填写证书内容"),0):(t.error("域名格式不正确"),0):(t.error("域名不能为空"),0))&&(await l({title:"提示",icon:"warning-filled",content:"基于Nginx/Apache，如果环境运行异常会导致无法访问，是否继续操作？"}),await s({loading:"正在设置免端口访问配置，请稍候...",request:A({domain:K.compData.domain,key:"no"===z.value?"":G.value.key,cert:"no"===z.value?"":G.value.cert}),message:!0}),K.compData.refresh(),Y("close"))},Q=async(e,a)=>{if(!a)try{const a=await navigator.clipboard.readText(),l="key"===e?[/-----BEGIN PRIVATE KEY-----[\s\S]*?-----END PRIVATE KEY-----/,/-----BEGIN RSA PRIVATE KEY-----[\s\S]*?-----END RSA PRIVATE KEY-----/,/-----BEGIN EC PRIVATE KEY-----[\s\S]*?-----END EC PRIVATE KEY-----/]:[/-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/,/-----BEGIN CERTIFICATE REQUEST-----[\s\S]*?-----END CERTIFICATE REQUEST-----/];for(const s of l){const l=a.match(s);if(l&&l[0])switch(t.success("已从粘贴板检测到".concat("key"===e?"密钥":"证书")),e){case"key":G.value.key=l[0];break;case"cert":G.value.cert=l[0]}}}catch(l){}},q=()=>{window.location.href="/site/nginx"};return i(()=>{z.value=K.compData.use_ssl?"auto":"no"}),(e,a)=>{const l=o,s=T,t=k,c=V,r=n;return m(),u("div",h,[d("div",R,[a[6]||(a[6]=d("span",null,"绑定域名：",-1)),d("div",b,[p(l,{modelValue:E(G).domain,"onUpdate:modelValue":a[0]||(a[0]=e=>E(G).domain=e),placeholder:"请输入绑定域名"},null,8,["modelValue"])])]),d("div",C,[a[7]||(a[7]=d("span",null,"SSL证书：",-1)),d("div",w,[p(t,{modelValue:E(z),"onUpdate:modelValue":a[1]||(a[1]=e=>x(z)?z.value=e:null),size:"small",onChange:U},{default:v(()=>[(m(),u(f,null,y(B,(e,a)=>p(s,{key:a,label:e.value},{default:v(()=>[d("span",null,D(e.title),1)]),_:2},1032,["label"])),64))]),_:1},8,["modelValue"])])]),"no"!==E(z)?(m(),u("div",g,[d("div",N,[a[8]||(a[8]=d("div",{class:"text-small mb-[.8rem]"},"密钥(KEY)",-1)),p(l,{class:"text-small",type:"textarea",modelValue:E(G).key,"onUpdate:modelValue":a[2]||(a[2]=e=>E(G).key=e),rows:13,size:"small",onFocus:a[3]||(a[3]=e=>Q("key",E(G).key))},null,8,["modelValue"])]),d("div",P,[a[9]||(a[9]=d("div",{class:"text-small mb-[.8rem]"},"证书(PEM格式)",-1)),p(l,{type:"textarea",modelValue:E(G).cert,"onUpdate:modelValue":a[4]||(a[4]=e=>E(G).cert=e),rows:13,size:"small",onFocus:a[5]||(a[5]=e=>Q("cert",E(G).cert))},null,8,["modelValue"])])])):_("",!0),p(c,{onClick:M,type:"primary",class:"mt-4"},{default:v(()=>a[10]||(a[10]=[I("保存",-1)])),_:1,__:[10]}),d("ul",S,[d("li",null,[a[11]||(a[11]=I("配置后可在网站--反向代理项目中管理,",-1)),d("span",{class:"text-primary cursor-pointer",onClick:q},"点击前往")]),a[14]||(a[14]=d("li",null,"配置此域名的证书到面板，浏览器即可信任访问",-1)),d("li",null,[d("div",j,[a[13]||(a[13]=I(" 粘贴您的*.key以及*.pem内容，然后保存即可 ",-1)),p(r,{href:"https://www.bt.cn/bbs/thread-105443-1-1.html"},{default:v(()=>a[12]||(a[12]=[I("帮助",-1)])),_:1,__:[12]})])]),a[15]||(a[15]=d("li",null,"如果浏览器提示证书链不完整,请检查是否正确拼接PEM证书",-1)),a[16]||(a[16]=d("li",null,"PEM格式证书 = 域名证书.crt + 根证书(root_bundle).crt",-1))])])}}});export{F as default};
function __vite__mapDeps(indexes) {
  if (!__vite__mapDeps.viteFileDeps) {
    __vite__mapDeps.viteFileDeps = []
  }
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
