1import{r as u,b as G,j as e,H,L as z}from"./admin-Bva5hjPk.js";import{A as J,G as K,F as S,a as V}from"./AdminLayout-epe4xJc7.js";import{a as W,B as c,c as d}from"./index-BM7CZe4h.js";import{I as B}from"./input-BcC3OAmu.js";import{L as m}from"./label-BFRXvFj2.js";import{B as P}from"./badge-CBthRa8s.js";import{C as h,a as k,b as j,c as $,d as N}from"./card-C4ygP2oq.js";import{A as q}from"./arrow-left-CLHuZd-G.js";import{L as Q}from"./loader-circle-DVCCROBP.js";import{S as Y}from"./save-CMNYVL76.js";import{C as T}from"./cloud-upload-CvfL_v4s.js";import{E as v}from"./external-link-CR5dMr_6.js";import{D as U}from"./download-C34LmI1G.js";import{C as Z}from"./circle-check-CCTimvuk.js";/* empty css */const M={name:"file-code-corner",size:24,node:[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],aliases:["file-code-2"]};M.node;const ee=W(M);function se(s){return s>=1048576?(s/1048576).toFixed(2)+" MB":s>=1024?(s/1024).toFixed(1)+" KB":s+" B"}function re(s,a){if(a)return{icon:K,label:"Tautan Eksternal / Cloud Storage",shortLabel:"URL",badgeClass:"bg-sky-500/10 text-sky-700 dark:text-sky-300 border-sky-500/30",iconClass:"text-sky-600 dark:text-sky-400"};const n=(s||"").toLowerCase().replace(/^\./,"");return n==="pdf"?{icon:S,label:"Berkas PDF Portable Document",shortLabel:"PDF",badgeClass:"bg-rose-500/10 text-rose-700 dark:text-rose-300 border-rose-500/30",iconClass:"text-rose-600 dar
1k:text-rose-400"}:["doc","docx"].includes(n)?{icon:S,label:"Microsoft Word Document",shortLabel:"DOC",badgeClass:"bg-blue-500/10 text-blue-700 dark:text-blue-300 border-blue-500/30",iconClass:"text-blue-600 dark:text-blue-400"}:["xls","xlsx"].includes(n)?{icon:V,label:"Spreadsheet / Excel Sheet",shortLabel:"XLS",badgeClass:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-500/30",iconClass:"text-emerald-600 dark:text-emerald-400"}:{icon:ee,label:"Berkas Dokumen Resmi",shortLabel:n?n.toUpperCase():"FILE",badgeClass:"bg-muted text-muted-foreground border-border",iconClass:"text-muted-foreground"}}function he({dokumen:s}){const a=!!s,n=u.useRef(null),[R,p]=u.useState(!1),[x,y]=u.useState(s?.berkas_nama||null),[_,D]=u.useState(s?.berkas_size||null),{data:r,setData:i,post:C,processing:w,errors:o}=G({_method:a?"PUT":"POST",nama_dokumen:s?.nama_dokumen||"",tipe_sumber:s?.tipe_sumber||"upload",berkas:null,link_dokumen:s?.link_dokumen||"",status:s?.status||"aktif"}),L=t=>{t&&(i("berkas",t),y(t.name),D(se(t.size)))},E=t=>{t.preventDefault(),t.stopPropagation(),p(!0)},I=t=>{t.preventDefault(),t.stopPropagation(),p(!1)},A=t=>{t.preventDefault(),t.stopPropagation(),p(!1);const g=t.dataTransfer.files;g&&g.length>0&&L(g[0])},O=()=>{i("berkas",null),y(null),D(null),n.current&&(n.current.value="")},X=t=>{t.preventDefault(),C(a?`/segododok/dokumen/${s.id_dokumen}`:"/segododok/dokumen")},b=r.tipe_sumber==="link"?"URL":x?x.split(".").pop()?.toUpperCase()||"FILE":s?.extension||"FILE",l=re(b,r.tipe_sumber==="link"),F=l.icon;let f="";if(r.tipe_sumber==="link"&&r.link_dokumen)try{f=new URL(r.link_dokumen).hostname.replace(/^www\./i,"")}catch{f="Tautan Belum Valid"}return e.jsxs(J,{children:[e.jsx(H,{title:a?`Sunting Dokumen: ${s.nama_dokumen}`:"Unggah Dokumen Publik"}),e.jsxs("div",{className:"space-y-6 w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 border-b border-border/40 pb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(z,{href:"/segododok/dokumen",children:e.jsx(c,{variant:"outline",size:"sm",className:"h-9 w-9 p-0 rounded-lg border-border text-muted-foreground hover:text-foreground",title:"Kembali ke Daftar Dokumen",children:e.jsx(q,{className:"h-4 w-4"})})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight text-foreground",children:a?"Sunting Dokumen Publik":"Unggah Dokumen Baru"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:a?"Perbarui data dan berkas dokumen regulasi":"Lengkapi formulir untuk menyimpan berkas dokumen atau regulasi ke repositori"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 self-end sm:self-auto",children:[e.jsx(z,{href:"/segododok/dokumen",children:e.jsx(c,{type:"button",variant:"outline",size:"sm",className:"h-9 px-3.5 text-xs rounded-lg border-border",children:"Batal"})}),e.jsx(c,{type:"submit",form:"dokumen-form",disabled:w,className:"h-9 px-4 text-xs rounded-lg gap-2 shadow-xs font-medium",children:w?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"size-3.5 animate-spin"}),e.jsx("span",{children:"Menyimpan..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"size-3.5"}),e.jsx("span",{children:a?"Simpan Perubahan":"Terbitkan Dokumen"})]})})]})]}),e.jsxs("form",{id:"dokumen-form",onSubmit:X,className:"grid grid-cols-1 lg:grid-cols-12 gap-6 items-start",children:[e.jsx("div",{className:"lg:col-span-7 space-y-6",children:e.jsxs(h,{className:"border-border/60 shadow-2xs",children:[e.jsxs(k,{className:"pb-4",children:[e.jsx(j,{className:"text-sm font-semibold text-foreground",children:"Rincian Dokumen & Regulasi"}),e.jsx($,{className:"text-xs text-muted-foreground",children:"Informasi judul dan berkas yang akan ditampilkan pada portal transparansi publik."})]}),e.jsxs(N,{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(m,{htmlFor:"nama_dokumen",className:"text-xs font-semibold text-foreground",children:["Judul Dokumen / Regulasi ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(B,{id:"nama_dokumen",type:"text",required:!0,value:r.nama_dokumen,onChange:t=>i("nama_dokumen",t.target.value),placeholder:"Contoh: Peraturan Bupati Jepara Nomor 14 Tahun 2026...",className:d("h-10 text-sm rounded-lg bg-background",o.nama_dokumen&&"border-destructive focus-visible:ring-destructive")}
1),o.nama_dokumen&&e.jsx("p",{className:"text-xs text-destructive font-medium",children:o.nama_dokumen})]}),e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border/40",children:[e.jsxs(m,{className:"text-xs font-semibold text-foreground",children:["Metode Penyimpanan Berkas ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>i("tipe_sumber","upload"),className:d("flex items-center gap-3 p-3 rounded-lg border text-left transition-all",r.tipe_sumber==="upload"?"border-primary bg-primary/10 text-foreground ring-1 ring-primary shadow-2xs":"border-border bg-background hover:bg-muted/40 text-muted-foreground hover:text-foreground"),children:[e.jsx("div",{className:"size-8 rounded-lg bg-primary/10 text-primary flex items-center justify-center shrink-0",children:e.jsx(T,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Unggah Berkas Langsung"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"PDF, DOCX, XLSX (Maks. 10MB)"})]})]}),e.jsxs("button",{type:"button",onClick:()=>i("tipe_sumber","link"),className:d("flex items-center gap-3 p-3 rounded-lg border text-left transition-all",r.tipe_sumber==="link"?"border-primary bg-primary/10 text-foreground ring-1 ring-primary shadow-2xs":"border-border bg-background hover:bg-muted/40 text-muted-foreground hover:text-foreground"),children:[e.jsx("div",{className:"size-8 rounded-lg bg-sky-500/10 text-sky-600 dark:text-sky-400 flex items-center justify-center shrink-0",children:e.jsx(v,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Tautan Eksternal (URL)"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Google Drive, JDIH, Cloud Storage"})]})]})]})]}),r.tipe_sumber==="upload"?e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border/40",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(m,{className:"text-xs font-semibold text-foreground",children:["File Dokumen ",!a&&e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx("span",{className:"text-[11px] text-muted-foreground font-mono",children:"Format: PDF, Word, Excel"})]}),e.jsx("input",{ref:n,type:"file",accept:".pdf,.doc,.docx,.xls,.xlsx",onChange:t=>L(t.target.files?.[0]||null),className:"hidden"}),x?e.jsxs("div",{className:"p-4 rounded-xl border border-border/80 bg-muted/20 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"size-10 rounded-lg bg-primary/10 text-primary flex items-center justify-center shrink-0",children:e.jsx(F,{className:"size-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground truncate max-w-[280px]",children:x}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-[11px] font-mono text-muted-foreground",children:_||"Ukuran tidak terdata"}),e.jsx(P,{variant:"outline",className:"text-[10px] px-1.5 py-0 uppercase",children:b})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(c,{type:"button",variant:"outline",size:"sm",onClick:()=>n.current?.click(),className:"h-8 text-xs px-2.5 rounded-lg border-border",children:"Ganti"}),e.jsx(c,{type:"button",variant:"ghost",size:"sm",onClick:O,className:"h-8 text-xs px-2.5 text-destructive hover:bg-destructive/10 rounded-lg",children:"Hapus"})]})]}),s?.berkas_url&&!r.berkas&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border/40 text-[11px]",children:[e.jsx("span",{className:"text-muted-foreground",children:"Berkas tersimpan di storage:"}),e.jsxs("a",{href:s.berkas_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1 font-medium",children:[e.jsx("span",{children:"Buka berkas saat ini"}),e.jsx(U,{className:"size-3"})]})]})]}):e.jsxs("div",{onClick:()=>n.current?.click(),onDragOver:E,onDragLeave:I,onDrop:A,className:d("border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all duration-150",R?"border-primary bg-primary/10":"border-border hover:border-primary/60 hover:bg-muted/30 bg-background"),children:[e.jsx("div",{className:"size-11 rounded-full bg-primary/10 text-primary flex items-center justify-center mx-auto mb-2.5",children:e.jsx(T,{className:"size-5"})}),e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Klik untuk memilih berkas atau geser ke sini (Drag & Drop)"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Mendukung PDF, DOC, DOCX, XLS, XLSX (Maksimal 10 MB)"})]}),o.berkas&&e.jsx("p",{className:"text-xs text-destructive font-medium",children:o.berkas})]}):e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border/40",children:[e.jsxs(m,{htmlFor:"link_dokumen",className:"text-xs font-semibold text-foreground",children:["Alamat Tautan Dokumen (URL) ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{id:"link_dokumen",type:"url",required:!0,value:r.link_dokumen,onChange:t=>i("link_dokumen",t.target.value),placeholder:"https://drive.google.com/... atau https://jdih.jepara.go.id/...",className:d("h-10 text-xs font-mono rounded-lg bg-background flex-1",o.link_dokumen&&"border-destructive focus-visible:ring-destructive")}
1),r.link_dokumen&&e.jsx("a",{href:r.link_dokumen,target:"_blank",rel:"noopener noreferrer",className:"size-10 rounded-lg border border-border flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted shrink-0 transition-colors",title:"Buka tautan eksternal",children:e.jsx(v,{className:"size-4"})})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Gunakan tautan lengkap diawali dengan ",e.jsx("code",{className:"font-mono text-foreground",children:"https://"})]}),o.link_dokumen&&e.jsx("p",{className:"text-xs text-destructive font-medium",children:o.link_dokumen})]}),e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border/40",children:[e.jsxs(m,{htmlFor:"status",className:"text-xs font-semibold text-foreground",children:["Status Publikasi Dokumen ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>i("status","aktif"),className:d("flex items-center gap-2.5 p-3 rounded-lg border text-left transition-all",r.status==="aktif"?"border-emerald-500 bg-emerald-500/10 text-foreground ring-1 ring-emerald-500":"border-border bg-background hover:bg-muted/40 text-muted-foreground"),children:[e.jsx("span",{className:"size-2 rounded-full bg-emerald-500"}),e.jsx("div",{children:e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Aktif"})})]}),e.jsxs("button",{type:"button",onClick:()=>i("status","non-aktif"),className:d("flex items-center gap-2.5 p-3 rounded-lg border text-left transition-all",r.status==="non-aktif"?"border-amber-500 bg-amber-500/10 text-foreground ring-1 ring-amber-500":"border-border bg-background hover:bg-muted/40 text-muted-foreground"),children:[e.jsx("span",{className:"size-2 rounded-full bg-amber-500"}),e.jsx("div",{children:e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Non-aktif"})})]})]}),o.status&&e.jsx("p",{className:"text-xs text-destructive font-medium",children:o.status})]})]})]})}),e.jsxs("div",{className:"lg:col-span-5 space-y-6",children:[e.jsxs(h,{className:"border-border/60 shadow-2xs overflow-hidden",children:[e.jsx(k,{className:"bg-muted/40 pb-3 border-b border-border/40",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"size-4 text-primary"}),e.jsx(j,{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Pratinjau Kartu Warga"})]}),e.jsx(P,{variant:"outline",className:"text-[10px] bg-background",children:"Portal Publik"})]})}),e.jsx(N,{className:"p-4 space-y-4",children:e.jsx("div",{className:"p-4 rounded-xl border border-border/80 bg-card hover:border-primary/50 transition-colors shadow-2xs",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:d("size-10 rounded-lg flex items-center justify-center shrink-0 border mt-0.5",l.badgeClass),children:e.jsx(F,{className:d("size-5",l.iconClass)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:d("text-[10px] font-semibold px-2 py-0.5 rounded border uppercase",l.badgeClass),children:l.shortLabel}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:r.tipe_sumber==="upload"?_||"Ukuran Berkas":f||"Cloud Storage"})]}),e.jsx("h3",{className:"text-xs font-bold text-foreground leading-snug line-clamp-2",children:r.nama_dokumen||"Judul Dokumen Belum Diisi"}),e.jsxs("div",{className:"mt-3 pt-2.5 border-t border-border/40 flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:r.status==="aktif"?e.jsx("span",{className:"text-emerald-600 dark:text-emerald-400 font-medium",children:"â Tayang Publik"}):e.jsx("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:"â Tersembunyi"})}),e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold text-primary",children:[e.jsx("span",{children:r.tipe_sumber==="link"?"Buka Tautan":"Unduh"}),r.tipe_sumber==="link"?e.jsx(v,{className:"size-3"}):e.jsx(U,{className:"size-3"})]})]})]})]})})})]}),e.jsxs(h,{className:"border-border/60 shadow-2xs",children:[e.jsx(k,{className:"pb-3 border-b border-border/40",children:e.jsx(j,{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Ringkasan Metadata"})}),e.jsxs(N,{className:"p-4 space-y-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between py-1 border-b border-border/30",children:[e.jsx("span",{className:"text-muted-foreground",children:"ID Record"}),e.jsx("span",{className:"font-mono font-medium text-foreground",children:a?`#${s.id_dokumen}`:"Otomatis dibuat (Auto ID)"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1 border-b border-border/30",children:[e.jsx("span",{className:"text-muted-foreground",children:"Metode Berkas"}),e.jsx("span",{className:"font-medium text-foreground",children:r.tipe_sumber==="upload"?"Upload Fisik Lokal":"Tautan Luar / Cloud"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1 border-b border-border/30",children:[e.jsx("span",{className:"text-muted-foreground",children:"Ekstensi Terdeteksi"}),e.jsx("span",{className:"font-mono font-semibold text-foreground uppercase",children:b})]}),e.jsxs("div",{className:"flex items-center justify-between py-1 border-b border-border/30",children:[e.jsx("span",{className:"text-muted-foreground",children:"Status Visibilitas"}),e.jsx("span",{className:d("font-medium",r.status==="aktif"?"text-emerald-600 dark:text-emerald-400":"text-amber-600 dar
1k:text-amber-400"),children:r.status==="aktif"?"Publik":"Arsip Tertutup"})]}),a&&(s?.updated_at||s?.created_at)&&e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Terakhir Diperbarui"}),e.jsx("span",{className:"text-[11px] text-foreground",children:s.updated_at||s.created_at})]})]})]})]})]})]})]})}export{he 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.