1import{r as c,j as e,f as x}from"./app-b7lRDbNF.js";import{a as D,M as S}from"./MainLayout-17ttyEnN.js";import{D as p,a as g,b as h,c as u,d as y,B as o}from"./button-BFs-MH_H.js";import{L as j}from"./loader-circle-Cd2iafrx.js";import{R as k}from"./refresh-cw-BaTWnZEz.js";/* empty css */import"./chevron-right-BaSTC35i.js";import"./user-DyBdsuG_.js";import"./credit-card-DfJvY1i8.js";import"./landmark-DEGEqr4l.js";import"./key-round-Bqc1uyOZ.js";import"./building-2-BMR13yKo.js";import"./clock-B-SgbQ4I.js";import"./shield-check-D8ymVycp.js";import"./message-circle-CQvXNHPK.js";import"./mail-d6RxqtDB.js";import"./send-CLhj-iMU.js";import"./index-DLgjZhNm.js";import"./FlashMessages-CwpWbeyo.js";import"./lock-D9NL1nDS.js";const C=({isConnected:t,connectedAt:m,stats:d={documentsSynced:0,storageUsed:"0 GB",lastSync:"Never"},flash:s,hasPlan:l=!1})=>{const[n,i]=c.useState(!1),[b,r]=c.useState(!1),[f,a]=c.useState(!1),v=()=>{i(!0),window.location.href=route("admin.onedrive.connect")},N=w=>new Date(w).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"relative min-h-[60vh] space-y-3",children:[!l&&e.jsx("div",{className:"mb-4 bg-gradient-to-r from-red-50 via-white to-red-50/50 border-2 border-red-500/80 rounded-xl p-4 shadow-sm relative overflow-hidden transition-all duration-300",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-red-100 rounded-lg text-red-600 shadow-sm shrink-0",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-red-800",children:"No Active Subscription"}),e.jsx("p",{className:"text-xs text-gray-600 mt-0.5",children:"Please subscribe to a plan to start connecting OneDrive and backing up your documents."})]})]}),e.jsx("a",{href:"/pricing",className:"inline-flex items-center justify-center px-4 py-1.5 bg-red-600 hover:bg-red-700 text-white text-xs font-semibold rounded-md shadow transition-all duration-200 shrink-0",children:"Upgrade Plan"})]})}),e.jsxs("div",{className:l?"space-y-3":"pointer-events-none select-none space-y-3 opacity-60",children:[(s==null?void 0:s.success)&&e.jsx("div",{className:"rounded-md border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-800",children:s.success}),(s==null?void 0:s.error)&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:s.error}),e.jsxs("div",{className:"overflow-hidden rounded-lg border border-gray-200 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-emerald-100 px-2 py-0.5 text-xs font-medium text-emerald-800",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"}),"Connected"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-700",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-gray-400"}),"Not connected"]}),t&&m&&e.jsxs("span",{className:"text-xs text-gray-500",children:["Since ",N(m)]})]}),!t&&e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Connect Microsoft OneDrive to sync invoices, mail attachments, and backups."})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>r(!0),disabled:n,className:"inline-flex items-center gap-1.5 rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50",children:[n?e.jsx(j,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(k,{className:"h-3.5 w-3.5"}),"Sync all"]}),e.jsx("button",{type:"button",onClick:()=>a(!0),disabled:n,className:"rounded-md border border-red-200 px-3 py-1.5 text-sm font-medium text-red-700 hover:bg-red-50 disabled:opacity-50",children:"Disconnect"})]}):e.jsxs("button",{type:"button",onClick:v,disabled:n,className:"inline-flex items-center gap-1.5 rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50",children:[n?e.jsx(j,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(D,{className:"h-3.5 w-3.5"}),"Connect OneDrive"]})})]}),t&&e.jsxs("div",{className:"grid grid-cols-1 divide-y sm:grid-cols-3 sm:divide-x sm:divide-y-0",children:[e.jsxs("div",{className:"px-3 py-2.5",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Documents synced"}),e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:d.documentsSynced})]}),e.jsxs("div",{className:"px-3 py-2.5",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Storage used"}),e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:d.storageUsed})]}),e.jsxs("div",{className:"px-3 py-2.5",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Last sync"}),e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:d.lastSync})]})]})]})]}),!l&&e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-white/70 px-4",role:"presentation",children:e.jsxs("div",{className:"max-w-md rounded-xl border border-gray-200 bg-white px-6 py-8 text-center shadow-lg",children:[e.jsx("p",{className:"text-lg font-semibold text-gray-800",children:"Kindly subscribe to an active plan to enable OneDrive integration."}),e.jsx("a",{href:"/pricing",className:"mt-5 inline-flex items-center justify-center rounded-lg bg-indigo-600 px-5 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",children:"Upgrade Plan"})]})}),e.jsx(p,{open:b,onOpenChange:r,children:e.jsxs(g,{className:"sm:max-w-md",children:[e.jsx(h,{children:e.jsx(u,{children:"Sync all to OneDrive?"})}),e.jsx("p",{className:"text-sm text-gray-600",children:"Uploads existing email attachments, Xero invoices, and backups that are not yet in OneDrive. This may take a few minutes."}),e.jsxs(y,{className:"gap-2 sm:gap-0",children:[e.jsx(o,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(o,{type:"button",onClick:()=>{r(!1),i(!0),x.post(route("admin.onedrive.full-sync"),{},{onFinish:()=>i(!1)})},children:"Start sync"})]})]})}),e.jsx(p,{open:f,onOpenChange:a,children:e.jsxs(g,{className:"sm:max-w-md",children:[e.jsx(h,{children:e.jsx(u,{children:"Disconnect OneDrive?"})}),e.jsx("p",{className:"text-sm text-gray-600",children:"New files will no longer upload automatically. Files already in OneDrive are not deleted."}),e.jsxs(y,{className:"gap-2 sm:gap-0",children:[e.jsx(o,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(o,{type:"button",variant:"destructive",onClick:()=>{a(!1),i(!0),x.post(route("admin.onedrive.disconnect"),{},{onFinish:()=>i(!1)})},children:"Disconnect"})]})]})})]})};C.layout=t=>e.jsx(S,{title:"OneDrive Settings",children:t});export{C 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.