1import{O as j,r as i,j as e,f as r,g as h}from"./vendor-BwK0dhQk.js";import{A as E}from"./ActionSection-CwuazLsz.js";import{F as R}from"./FormSection-DTvPK4-w.js";import{S as _}from"./SectionBorder-C_PMABpP.js";import{u as U,T as z,B as n}from"./app-DV1NBe11.js";import{F as G,L as A,E as O,a as M,b as Y}from"./fieldset-Q9rpUMi8.js";import{I as H}from"./input-Cnpa-Bcj.js";import{C as D,a as f,b as $}from"./checkbox-wO03cmHe.js";import{D as b,a as k,b as J,c as I,d as T}from"./dialog-Htp6yugq.js";import{a as K}from"./index-DISIrodZ.js";import"./ToastProvider-B_z24CVG.js";/* empty css */function oe({tokens:C,availablePermissions:o,defaultPermissions:S,newToken:u,setNewToken:v}){const a=j({name:"",permissions:S}),t=j({permissions:[]}),g=j({}),[F,x]=i.useState(!1),[m,c]=i.useState(null),[p,d]=i.useState(null);U();const y=i.useRef(null);i.useEffect(()=>{!u||!y.current||requestAnimationFrame(()=>{const s=document.createRange();s.selectNodeContents(y.current);const l=window.getSelection();l?.removeAllRanges(),l?.addRange(s)})},[u]);function N(){a.post(K.store().url,{preserveScroll:!0,onSuccess:()=>{x(!0),a.reset()}})}function L(s){t.setData("permissions",s.scopes),c(s)}function q(){m&&t.put(K.update(m.id).url,{preserveScroll:!0,preserveState:!0,onSuccess:()=>c(null)})}function w(s){d(s)}function B(){p&&g.delete(K.destroy(p).url,{preserveScroll:!0,preserveState:!0,onSuccess:()=>d(null)})}return e.jsxs("div",{children:[e.jsxs(R,{onSubmit:N,title:"Create API Token",description:"API tokens allow third-party services to authenticate with our application on your behalf.",renderActions:()=>e.jsx(i.Fragment,{children:e.jsx(r,{color:"brand-blue",disabled:a.processing,isLoading:a.processing,type:"submit",$as:n,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/3/openingElement/3/value/expression/body/1"})}),children:[e.jsxs(G,{children:[e.jsx(r,{$as:A,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/3/3/1"}),e.jsx(H,{id:"name",type:"text",value:a.data.name,onChange:s=>a.setData("name",s.currentTarget.value),autoComplete:"name",invalid:!!a.errors.name}),!!a.errors.name&&e.jsx(O,{children:a.errors.name})]}),o.length>0&&e.jsx(i.Fragment,{children:e.jsxs(M,{className:"mt-6",children:[e.jsx(r,{$as:Y,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/3/7/expression/right/1/1"}),e.jsx(r,{$as:z,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/3/7/expression/right/1/3"}),e.jsxs(h,{role:"group","aria-label":"Permissions",$attrAs:D,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$attributes:{"aria-label":"15/declaration/body/14/argument/3/7/expression/right/1/5-aria-label"},children:[e.jsxs(f,{children:[e.jsx($,{checked:a.data.permissions.length>0,indeterminate:a.data.permissions.length!==o.length,onChange:s=>a.setData("permissions",s?o:[])}),e.jsx(r,{$as:A,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/3/7/expression/right/1/5/1/3"})]}),o.map(s=>e.jsxs(f,{children:[e.jsx($,{name:s,checked:a.data.permissions.includes(s),onChange:l=>a.setData("permissions",l?[...a.data.permissions,s]:a.data.permissions.filter(P=>P!==s))}),e.jsx(A,{children:`${s[0].toUpperCase()+s.slice(1)}`})]},s))]})]})})]}),C.length>0?e.jsxs("div",{children:[e.jsx(_,{}),e.jsx("div",{className:"mt-10 sm:mt-0",children:e.jsx(h,{title:"Manage API Tokens",description:"You may delete any of your existing tokens if they are no longer needed.",$attrAs:E,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$attributes:{title:"15/declaration/body/14/argument/5/expression/consequent/5/1-title",description:"15/declaration/body/14/argument/5/expression/consequent/5/1-description"},children:e.jsx("div",{className:"space-y-6",children:C.map(s=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"break-all dark:text-white truncate max-w-[100px]",children:s.name}),e.jsxs("div",{className:"flex items-center space-x-2",children:[s.expires_at&&e.jsx(r,{className:"text-sm text-gray-400",$as:"div",$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/5/expression/consequent/5/1/3/1/expression/0/body/3/1/expression/right",$variables:{"token.expires_at_string":s.expires_at_string}}),o.length>0?e.jsx(r,{plain:!0,onClick:()=>L(s),$as:n,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/5/expression/consequent/5/1/3/1/expression/0/body/3/3/expression/consequent"}):null,e.jsx(r,{plain:!0,className:"!text-red-500",onClick:()=>w(s),$as:n,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/5/expression/consequent/5/1/3/1/expression/0/body/3/5"})]})]},s.id))})})})]}):null,e.jsxs(b,{open:F,onClose:()=>x(!1),children:[e.jsx(k,{children:"API Token"}),e.jsx(r,{$as:J,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/9/3"}),e.jsx(I,{className:"text-xs/6 text-zinc-900 dark:text-white break-all",children:e.jsx("code",{ref:y,className:"font-mono",children:u})}),e.jsx(T,{children:e.jsx(r,{color:"brand-blue",type:"button",onClick:()=>{x(!1),v(null)},$as:n,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/9/7/1"})})]}),e.jsxs(b,{open:!!m,onClose:()=>c(null),children:[e.jsx(k,{children:"API Token Permissions"}),e.jsx(I,{children:e.jsx(M,{children:e.jsx(h,{role:"group","aria-label":"Permissions",$attrAs:D,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$attributes:{"aria-label":"15/declaration/body/14/argument/13/3/1/1-aria-label"},children:o.map(s=>e.jsx(f,{children:e.jsxs("label",{className:"flex items-center",children:[e.jsx($,{checked:t.data.permissions.includes(s),onChange:l=>t.setData("permissions",l?[...a.data.permissions,s]:t.data.permissions.filter(P=>P!==s))}),e.jsx("span",{className:"ml-2 text-sm text-gray-600 dark:text-gray-400",children:`${s[0].toUpperCase()+s.slice(1)}`})]})},s))})})}),e.jsxs(T,{children:[e.jsx(r,{plain:!0,onClick:()=>c(null),$as:n,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/13/5/1"}),e.jsx(r,{color:"brand-blue",type:"submit",onClick:q,isLoading:t.processing,disabled:t.processing,$as:n,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/13/5/3"})]})]}),e.jsxs(b,{open:!!p,onClose:()=>d(null),children:[e.jsx(k,{children:"Delete API Token"}),e.jsx(r,{$as:I,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/17/3"}),e.jsxs(T,{children:[e.jsx(r,{plain:!0,onClick:()=>d(null),$as:n,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/17/5/1"}),e.jsx(r,{color:"red",type:"submit",onClick:B,isLoading:g.processing,disabled:g.processing,$as:n,$fileKey:"../resources/js/Pages/API/Partials/APITokenManager.tsx",$entryKey:"15/declaration/body/14/argument/17/5/3"})]})]})]})}export{oe 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.