1/* ANPG DEVTEAM - 29/09/2026, 14:34:20 */ 2import{e as M,u as G,d as f,j as e}from"./data-vendor-BRYI0K8G.js";import{r as g}from"./react-vendor-Bj9LQV-u.js";import{C as L}from"./ContentEntityManager-COKPHn2j.js";import{e as q,af as z,ag as O,ah as B,ai as H,bf as K,b as n,w as D,bM as Q,ae as u,bh as i,aj as $}from"./index-B5fS5HUA.js";import{I as w}from"./input-CtWCrhgd.js";import{L as v}from"./label-ByFBDaC1.js";import{S as R}from"./switch-B0x4NxgT.js";import{C as U,a as V}from"./card-SWKDiSm6.js";import{I as J}from"./ImageUpload-B-Fn_HAM.js";import{A as W,a as X,b as Y,c as Z,d as ee,e as ae,f as te,g as se}from"./alert-dialog-J_9uTetV.js";import{P as re}from"./plus-lNvdMfmK.js";import{I as ie}from"./image-off-B-j-b2pF.js";import{P as oe}from"./pencil-C8r3g6iN.js";import{T as le}from"./trash-2-BmjaA2Y9.js";import"./AdminLayout-h_nmul7P.js";import"./badge-jukGcCw8.js";import"./message-square-3F19oJ7J.js";import"./newspaper-B1VsFBcy.js";import"./tag-zpo8YYRH.js";import"./camera-DF73IPZH.js";import"./shield-check-DBFg_Isw.js";import"./sliders-horizontal-CI8TRfgr.js";import"./user-check-Omtv7yGv.js";import"./network-Bioht48n.js";import"./clock-DjVV6Aw0.js";import"./book-open-BvZy1lzn.js";import"./bot-Ckp6pNDt.js";import"./gavel-D8KhpCGX.js";import"./presentation-Bg7Ve6-F.js";import"./star-BMTUmwlW.js";import"./clipboard-check-AscQTU3D.js";import"./folder-open-DBolFNfs.js";import"./settings-2-5vee-iyr.js";import"./rocket-OwwOM41y.js";import"./user-B2J0vviq.js";import"./arrow-left-B5pHXlkl.js";import"./circle-check-big-R1zEC76Q.js";import"./textarea-DpaYHtFE.js";import"./table-BTascmHv.js";import"./select-CIRt4Z_4.js";import"./index-BdQq_4o_.js";import"./index-BatE7gkT.js";import"./index-D6PzSG9l.js";import"./chevron-up-CYP72WxE.js";import"./search-B8XA8FkL.js";import"./charts-vendor-Cs07Jtv5.js";import"./motion-vendor-DMc3mo8t.js";import"./i18n-vendor-BSIZ7LIS.js";import"./slider-BjX6YdR8.js";import"./index-DPb2Lsa1.js";import"./upload-DozJuQTi.js";/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const A=q("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]]),E={image_url:"",caption_pt:"",sort_order:0,is_active:!0};function ne({galleryId:s,galleryTitle:c,open:r,onOpenChange:y}){const k=M(),_=["gallery-photos",s],[m,b]=g.useState(null),[t,o]=g.useState({...E}),[x,h]=g.useState(null),{data:d,isLoading:S}=G({queryKey:_,enabled:r&&!!s,queryFn:async()=>(await u.list({gallery_id:s,sort:"sort_order",limit:500})).data}),j=()=>k.invalidateQueries({queryKey:_}),N=f({mutationFn:a=>u.create(a),onSuccess:()=>{j(),i.success("Foto adicionada"),p()},onError:a=>i.error(`Erro: ${a.message}`)}),C=f({mutationFn:({id:a,data:l})=>u.update(a,l),onSuccess:()=>{j(),i.success("Foto actualizada"),p()},onError:a=>i.error(`Erro: ${a.message}`)}),P=f({mutationFn:a=>u.delete(a),onSuccess:()=>{j(),i.success("Foto eliminada"),h(null)},onError:a=>i.error(`Erro: ${a.message}`)}),p=()=>{b(null),o({...E})},I=a=>{b(a),o({image_url:a.image_url??"",caption_pt:a.caption_pt??"",sort_order:a.sort_order??0,is_active:!!a.is_active})},T=a=>{if(a.preventDefault(),!t.image_url.trim()){i.error("Carregue uma imagem primeiro");return}const l={gallery_id:s,image_url:t.image_url.trim(),caption_pt:t.caption_pt.trim()||null,sort_order:Number(t.sort_order)||0,is_active:t.is_active?1:0};m?C.mutate({id:m.id,data:l}):N.mutate(l)},F=N.isPending||C.isPending;return e.jsxs(e.Fragment,{children:[e.jsx(z,{open:r,onOpenChange:a=>{a||p(),y(a)},children:e.jsxs(O,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(B,{children:[e.jsxs(H,{
7children:["Fotos â ",c]}),e.jsx(K,{children:"Faça a gestão das fotografias desta galeria. As fotos herdam o estado de publicação da galeria."})]}),e.jsxs("form",{onSubmit:T,className:"grid grid-cols-12 gap-3 border rounded-lg p-3 bg-muted/30",children:[e.jsx("div",{className:"col-span-12",children:e.jsx(J,{value:t.image_url,onChange:a=>o({...t,image_url:a}),folder:"exploration/galleries",label:"Imagem *",cropAspectRatio:16/9})}),e.jsxs("div",{className:"col-span-8 grid gap-1.5",children:[e.jsx(v,{children:"Legenda"}),e.jsx(w,{value:t.caption_pt,onChange:a=>o({...t,caption_pt:a.target.value}),placeholder:"Opcional"})]}),e.jsxs("div",{className:"col-span-4 grid gap-1.5",children:[e.jsx(v,{children:"Ordem"}),e.jsx(w,{type:"number",value:t.sort_order,onChange:a=>o({...t,sort_order:Number(a.target.value)})})]}),e.jsxs("div",{className:"col-span-12 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{checked:t.is_active,onCheckedChange:a=>o({...t,is_active:a})}),e.jsx(v,{children:"Activa (visÃvel)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m&&e.jsx(n,{type:"button",variant:"outline",onClick:p,children:"Cancelar edição"}),e.jsxs(n,{type:"submit",disabled:F,children:[F?e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(re,{className:"h-4 w-4 mr-2"}),m?"Guardar foto":"Adicionar foto"]})]})]})]}),e.jsx("div",{className:"mt-4",children:S?e.jsx("div",{className:"text-center py-10",children:e.jsx(D,{className:"h-5 w-5 animate-spin inline"})}):d!=null&&d.length?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:d.map(a=>e.jsx(U,{className:a.is_active?"":"opacity-50",children:e.jsxs(V,{className:"p-2 space-y-2",children:[e.jsx("div",{className:"aspect-video bg-muted rounded overflow-hidden flex items-center justify-center",children:e.jsx("img",{src:a.image_url,alt:a.caption_pt??"",className:"w-full h-full object-cover",loading:"lazy",onError:l=>{l.currentTarget.style.display="none"}})}),e.jsx("p",{className:"text-xs truncate",title:a.caption_pt??"",children:a.caption_pt||e.jsx("span",{className:"text-muted-foreground",children:"Sem legenda"})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["#",a.sort_order]}),e.jsxs("div",{className:"flex",children:[e.jsx(n,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>I(a),children:e.jsx(oe,{className:"h-3.5 w-3.5"})}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(a),children:e.jsx(le,{className:"h-3.5 w-3.5 text-destructive"})})]})]})]})},a.id))}):e.jsxs("div",{className:"text-center py-10 text-muted-foreground flex flex-col items-center gap-2",children:[e.jsx(ie,{className:"h-8 w-8 opacity-50"}),"Sem fotos nesta galeria. Adicione a primeira acima."]})}),e.jsx(Q,{children:e.jsx(n,{type:"button",variant:"outline",onClick:()=>y(!1),children:"Fechar"})})]})}),e.jsx(W,{open:!!x,onOpenChange:a=>{a||h(null)},children:e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsx(Z,{children:"Eliminar foto?"}),e.jsx(ee,{children:"Esta acção é irreversÃvel."})]}),e.jsxs(ae,{children:[e.jsx(te,{children:"Cancelar"}),e.jsx(se,{className:"bg-destructive text-destructive-foreground",onClick:()=>x&&P.mutate(x.id),children:"Eliminar"})]})]})})]})}const ce=[{name:"title_pt",label:"TÃtulo",type:"text",required:!0},{name:"basin_code",label:"Bacia",type:"taxonomy",vocabularyKey:"basin",half:!0},{name:"cover_url",label:"Imagem de capa",type:"image"},{name:"description_pt",label:"Descrição",type:"textarea"}],me=[{key:"title_pt",label:"TÃtulo"},{key:"basin_code",label:"Bacia"}];function na(){const[s,c]=g.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(L,{title:"Galerias Fotográficas",description:"Galerias de fotografias de exploração. Use 'Fotos' para gerir as imagens de cada galeria.",icon:A,api:$,queryKey:"admin-exploration-galleries",fields:ce,columns:me,searchFields:["title_pt"],rowActions:r=>e.jsxs(n,{variant:"outline",size:"sm",className:"mr-1",onClick:()=>c({id:r.id,title:r.title_pt??"Galeria"}),children:[e.jsx(A,{className:"h-3.5 w-3.5 mr-1.5"}),"Fotos"]})}),s&&e.jsx(ne,{galleryId:s.id,galleryTitle:s.title,open:!!s,onOpenChange:r=>{r||c(null)}})]})}export{na 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.