import{r as l,j as e,a as g}from"./app-BwDemWQz.js";import{B as h}from"./Button-B-KWyoQR.js";import{A as S}from"./AppLayout-3zbhnyYw.js";import{I as u}from"./Input-BJaxI6jp.js";import{s as i,C as f}from"./index-CkDmAPFS.js";import{P as L}from"./PlatformIcon-BoGOJKWv.js";import{A as P}from"./arrow-left-B11txR0s.js";import{C as j}from"./copy-WN1DN5DF.js";/* empty css            */import"./createLucideIcon-BASx8f0E.js";import"./index-DxJALBsh.js";import"./Label-1lm7x8-L.js";import"./LanguageContext-zkEAKPTE.js";import"./zap-BsHQ4DWF.js";import"./rocket-Dt03WmgU.js";import"./users-g1HvrzO9.js";import"./globe-C_ZhZ5i9.js";function q({platform:r={name:"Platform",configuration:{}},dynamicFields:y}){const b=[{label:"Home",href:i("user.home")},{label:"Platform",href:i("user.platform.index")},{label:`${r.name} Settings`,href:"#"}],[c,N]=l.useState(r.configuration||{}),[m,d]=l.useState(null),[x,o]=l.useState(!1),n=t=>t.split("_").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "),v=(t,s)=>t.toLowerCase().includes("url")||typeof s=="string"&&s.startsWith("http"),C=(t,s)=>{N(a=>({...a,[t]:s}))},p=async(t,s)=>{try{await navigator.clipboard.writeText(t),d(s),setTimeout(()=>d(null),2e3)}catch(a){console.error("Failed to copy:",a)}},w=t=>{t.preventDefault(),o(!0),g.post(i("user.platform.setting.store"),{id:r.id,configuration:c},{onFinish:()=>o(!1),onError:()=>o(!1)})};return e.jsx(S,{breadcrumbs:b,children:e.jsxs("div",{className:"p-6 space-y-6 min-h-full",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-4 mb-4",children:e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>g.get(i("user.platform.index")),className:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[e.jsx(P,{className:"w-4 h-4 mr-2"}),"Back to Platforms"]})}),e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{children:e.jsx(L,{slug:r.slug,size:32})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl sm:text-2xl font-bold text-gray-900 dark:text-gray-100",children:[r.name," API Settings"]}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400",children:["Manage your ",r.name," API settings and connections"]})]})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-lg border border-gray-200 dark:border-zinc-800 lg:p-6 p-4",children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-6",children:"Update Configuration"}),e.jsxs("form",{onSubmit:w,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[Object.entries(c).map(([t,s])=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-zinc-100",children:n(t)}),e.jsxs("div",{className:"relative",children:[e.jsx(u,{type:"text",value:s||"",onChange:a=>C(t,a.target.value),placeholder:"Enter configuration value",className:"bg-gray-50 border-gray-200 pr-10"}),v(t,s)&&s&&e.jsx("button",{type:"button",onClick:()=>p(s,t),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-gray-400 hover:text-gray-600 transition-colors",children:m===t?e.jsx(f,{className:"h-4 w-4 text-green-500"}):e.jsx(j,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Enter the ",n(t).toLowerCase()," for your ",r.name.toLowerCase()," integration."]})]},t)),Object.entries(y).map(([t,s])=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-zinc-100",children:n(t)}),e.jsxs("div",{className:"relative",children:[e.jsx(u,{type:"text",value:s,readOnly:!0,className:"bg-gray-100 pr-10 cursor-text"}),e.jsx("button",{type:"button",onClick:()=>p(s,t),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-gray-400 hover:text-gray-600 transition-colors",children:m===t?e.jsx(f,{className:"h-4 w-4 text-green-500"}):e.jsx(j,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Use this URL for your ",r.name.toLowerCase()," integration."]})]},t))]}),e.jsx("div",{className:"flex items-center gap-4 pt-4",children:e.jsx(h,{type:"submit",disabled:x,className:"bg-gradient-to-r from-primary to-secondary text-white px-8 py-2 hover:from-secondary hover:to-primary",children:x?"Updating...":"Update"})})]})]})]})})}export{q as default};
