import{d as O,r as S,H as R,t as U,U as P,A as C,z as y,a8 as p,aP as A,V as q,aO as $,L as k}from"./D6By_0qX.js";import{u as L}from"./Cp_jxA-w.js";import{u as N}from"./BMh_0dZ2.js";import{V as K}from"./K8FKxV8_.js";function x(e){"@babel/helpers - typeof";return x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(e)}function F(e){var t=typeof e=="string"||e instanceof String;if(!t){var r=x(e);throw e===null?r="null":r==="object"&&(r=e.constructor.name),new TypeError("Expected a string but received a ".concat(r))}}function j(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var r in t)typeof e[r]>"u"&&(e[r]=t[r]);return e}var z={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function D(e,t){F(e),t=j(t,z),t.allow_trailing_dot&&e[e.length-1]==="."&&(e=e.substring(0,e.length-1)),t.allow_wildcard===!0&&e.indexOf("*.")===0&&(e=e.substring(2));var r=e.split("."),a=r[r.length-1];return t.require_tld&&(r.length<2||!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(a)||/\s/.test(a))||!t.allow_numeric_tld&&/^\d+$/.test(a)?!1:r.every(function(l){return!(l.length>63&&!t.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(l)||/[\uff01-\uff5e]/.test(l)||/^-|-$/.test(l)||!t.allow_underscores&&/_/.test(l))})}var V="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",_="(".concat(V,"[.]){3}").concat(V),M=new RegExp("^".concat(_,"$")),o="(?:[0-9a-fA-F]{1,4})",T=new RegExp("^("+"(?:".concat(o,":){7}(?:").concat(o,"|:)|")+"(?:".concat(o,":){6}(?:").concat(_,"|:").concat(o,"|:)|")+"(?:".concat(o,":){5}(?::").concat(_,"|(:").concat(o,"){1,2}|:)|")+"(?:".concat(o,":){4}(?:(:").concat(o,"){0,1}:").concat(_,"|(:").concat(o,"){1,3}|:)|")+"(?:".concat(o,":){3}(?:(:").concat(o,"){0,2}:").concat(_,"|(:").concat(o,"){1,4}|:)|")+"(?:".concat(o,":){2}(?:(:").concat(o,"){0,3}:").concat(_,"|(:").concat(o,"){1,5}|:)|")+"(?:".concat(o,":){1}(?:(:").concat(o,"){0,4}:").concat(_,"|(:").concat(o,"){1,6}|:)|")+"(?::((?::".concat(o,"){0,5}:").concat(_,"|(?::").concat(o,"){1,7}|:))")+")(%[0-9a-zA-Z-.:]{1,})?$");function b(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return F(e),t=String(t),t?t==="4"?M.test(e):t==="6"?T.test(e):!1:b(e,4)||b(e,6)}function B(e,t){return Z(e)||W(e,t)||Q(e,t)||H()}function H(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Q(e,t){if(e){if(typeof e=="string")return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(e,t)}}function E(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}function W(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,l,c,f,s=[],n=!0,i=!1;try{if(c=(r=r.call(e)).next,t!==0)for(;!(n=(a=c.call(r)).done)&&(s.push(a.value),s.length!==t);n=!0);}catch(d){i=!0,l=d}finally{try{if(!n&&r.return!=null&&(f=r.return(),Object(f)!==f))return}finally{if(i)throw l}}return s}}function Z(e){if(Array.isArray(e))return e}var G={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0},J=/^\[([^\]]+)\](?::([0-9]+))?$/;function X(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function I(e,t){for(var r=0;r<t.length;r++){var a=t[r];if(e===a||X(a)&&a.test(e))return!0}return!1}function Y(e,t){if(F(e),!e||/[\s<>]/.test(e)||e.indexOf("mailto:")===0||(t=j(t,G),t.validate_length&&e.length>=2083)||!t.allow_fragments&&e.includes("#")||!t.allow_query_components&&(e.includes("?")||e.includes("&")))return!1;var r,a,l,c,f,s,n,i;if(n=e.split("#"),e=n.shift(),n=e.split("?"),e=n.shift(),n=e.split("://"),n.length>1){if(r=n.shift().toLowerCase(),t.require_valid_protocol&&t.protocols.indexOf(r)===-1)return!1}else{if(t.require_protocol)return!1;if(e.slice(0,2)==="//"){if(!t.allow_protocol_relative_urls)return!1;n[0]=e.slice(2)}}if(e=n.join("://"),e==="")return!1;if(n=e.split("/"),e=n.shift(),e===""&&!t.require_host)return!0;if(n=e.split("@"),n.length>1){if(t.disallow_auth||n[0]===""||(a=n.shift(),a.indexOf(":")>=0&&a.split(":").length>2))return!1;var d=a.split(":"),h=B(d,2),v=h[0],w=h[1];if(v===""&&w==="")return!1}c=n.join("@"),s=null,i=null;var u=c.match(J);if(u?(l="",i=u[1],s=u[2]||null):(n=c.split(":"),l=n.shift(),n.length&&(s=n.join(":"))),s!==null&&s.length>0){if(f=parseInt(s,10),!/^[0-9]+$/.test(s)||f<=0||f>65535)return!1}else if(t.require_port)return!1;return t.host_whitelist?I(l,t.host_whitelist):l===""&&!t.require_host?!0:!(!b(l)&&!D(l,t)&&(!i||!b(i,6))||(l=l||i,t.host_blacklist&&I(l,t.host_blacklist)))}const ae=O({__name:"ScannerForm",props:{scanner:{type:Object,default:()=>({endpoint:"",apiKey:"",name:""})},isEditMode:{type:Boolean,defualt:!1}},emits:["close-form"],setup(e,{emit:t}){const r={endpoint:"",apiKey:"",name:""},a=e,l=S(),c=S(!1),f=t,s=L(),n=N(),i=S(r),d={required:u=>(u==null?void 0:u.trim())!==""||"",url:u=>Y(u)||"Must be a valid URL"};R(a.scanner,u=>{i.value={...u}},{immediate:!0,deep:!0});const h=async()=>{if(c.value===!0&&i.value!==null)try{s.addOrUpdateScanner(i.value),v(),f("close-form"),n.reportSuccess("Scanner saved successfully.")}catch{n.reportError("Failed to save scanner information. Please try again.")}},v=()=>{i.value=r},w=()=>{v(),f("close-form")};return(u,m)=>(U(),P(K,{ref_key:"form",ref:l,modelValue:p(c),"onUpdate:modelValue":m[3]||(m[3]=g=>$(c)?c.value=g:null),onSubmit:k(h,["prevent"])},{default:C(()=>[y(A,{modelValue:p(i).endpoint,"onUpdate:modelValue":m[0]||(m[0]=g=>p(i).endpoint=g),variant:"outlined",density:"compact",label:"Scanner Endpoint",placeholder:"https://api.example.com/graphql",disabled:e.isEditMode===!0,rules:[d.required,d.url]},null,8,["modelValue","disabled","rules"]),y(A,{modelValue:p(i).name,"onUpdate:modelValue":m[1]||(m[1]=g=>p(i).name=g),variant:"outlined",density:"compact",label:"Scanner Name",placeholder:"Scanner Name",rules:[d.required]},null,8,["modelValue","rules"]),y(A,{modelValue:p(i).apiKey,"onUpdate:modelValue":m[2]||(m[2]=g=>p(i).apiKey=g),variant:"outlined",density:"compact",label:"API Key",placeholder:"Enter API Key",rules:[d.required]},null,8,["modelValue","rules"]),y(q,{class:"me-2",type:"submit",color:"success",text:"Save","prepend-icon":"mdi-check",disabled:!p(c)},null,8,["disabled"]),y(q,{text:"Cancel","prepend-icon":"mdi-close",onClick:w})]),_:1},8,["modelValue"]))}});export{ae as _};
