PageSourceSearch

https://www.reguzziclaudiosa.ch/assets/EditableImg-CX2A5uvA.js

js reguzziclaudiosa.ch collected 2026-10-09 22:04:28 UTC 4,749 bytes, 1 lines download raw bytes

1import{o as e,t}from"./jsx-runtime-DVpe7PXp.js";import{n}from"./invariant-DgyN5bRW.js";import{t as r}from"./useMutation-DBPXcad8.js";import{B as i,F as a,b as o,n as s,s as c,ut as l}from"./lucide-react-COC_84y3.js";import{t as u}from"./dist-Buv3-4Y4.js";import{n as d,t as f}from"./admin-image-upload-CRZFmPER.js";import{a as p,i as m,o as h,r as g,s as _}from"./T-BsgPYbaz.js";var v=e(n(),1),y=t();function b({k:e,initial:t,isOverridden:n,onClose:i,title:p=`Cambia foto`}){let[m,b]=(0,v.useState)(d(t)),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(!1),T=g(),E=r({mutationFn:()=>_({data:{key:e,value:m,kind:`image`}}),onSuccess:async()=>{u.success(`Immagine aggiornata`),await T(),i()},onError:e=>u.error(e.message)}),D=r({mutationFn:()=>h({data:{key:e}}),onSuccess:async()=>{u.success(`Foto originale ripristinata`),await T(),i()},onError:e=>u.error(e.message)});async function O(e){w(!0);try{b(await f(e)),S(!0),u.success(`Foto caricata. Ora premi Salva per vederla sul sito.`)}catch(e){u.error(e.message||`Caricamento fallito`)}finally{w(!1)}}return(0,y.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm`,onClick:i,children:(0,y.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`w-full max-w-xl bg-background rounded-xl shadow-2xl border border-border overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border bg-secondary/50`,children:[(0,y.jsx)(`div`,{className:`font-medium`,children:p}),(0,y.jsx)(`button`,{onClick:i,className:`p-2 hover:bg-muted rounded-md`,children:(0,y.jsx)(s,{size:18})})]}),(0,y.jsxs)(`div`,{className:`p-5 space-y-4`,children:[m&&(0,y.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border bg-muted`,children:(0,y.jsx)(`img`,{src:m,alt:`Anteprima`,className:`w-full max-h-72 object-cover`})}),x&&(0,y.jsxs)(`div`,{className:`rounded-md border border-amber-400 bg-amber-50 px-3 py-2 text-sm text-amber-950`,children:[`Anteprima pronta: premi `,(0,y.jsx)(`strong`,{children:`Salva`}),` per applicare questa foto al sito.`]}),(0,y.jsxs)(`label`,{className:`block`,children:[(0,y.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-navy-deep/80 font-semibold`,children:`Carica da computer o telefono`}),(0,y.jsxs)(`label`,{className:`mt-2 flex items-center justify-center gap-2 w-full border-2 border-dashed border-navy-deep/30 bg-white rounded-md py-6 cursor-pointer hover:bg-secondary`,children:[C?(0,y.jsx)(a,{size:18,className:`animate-spin`}):(0,y.jsx)(c,{size:18}),(0,y.jsx)(`span`,{className:`text-sm`,children:C?`Caricamento…`:`Scegli un'immagine`}),(0,y.jsx)(`input`,{type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&O(t)}})]})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-navy-deep/80 font-semibold`,children:`…oppure incolla URL`}),(0,y.jsx)(`input`,{value:m,onChange:e=>{b(e.target.value),S(!1)},placeholder:`https://…`,className:`mt-2 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`})]})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-border bg-secondary/30`,children:[(0,y.jsx)(`div`,{children:n&&(0,y.jsxs)(`button`,{onClick:()=>D.mutate(),disabled:D.isPending,className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,y.jsx)(o,{size:12}),` Ripristina originale`]})}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(`button`,{onClick:i,className:`px-4 py-2 text-sm rounded-md hover:bg-muted`,children:`Annulla`}),(0,y.jsxs)(`button`,{onClick:()=>E.mutate(),disabled:E.isPending||!m,className:`inline-flex items-center gap-2 px-5 py-2 text-sm rounded-md text-white disabled:opacity-60 ${x?`bg-amber-700 hover:bg-amber-800`:`bg-navy hover:bg-navy/90`}`,children:[E.isPending?(0,y.jsx)(a,{size:14,className:`animate-spin`}):(0,y.jsx)(l,{size:14}),` `,x?`Salva e mostra sul sito`:`Salva`]})]})]})]})})}function x({id:e,src:t,alt:n,className:r,width:a,height:o,loading:s}){let c=m(),l=`img:${e}`,u=d(c[l]?.value||t),f=!!c[l],{isAdmin:h}=p(),[g,_]=(0,v.useState)(!1),x=(0,y.jsx)(`img`,{src:u,alt:n,className:r,width:a,height:o,loading:s});return h?(0,y.jsxs)(`div`,{className:`relative group/edit-img inline-block w-full h-full`,children:[x,(0,y.jsxs)(`button`,{type:`button`,"data-edit-affordance":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),_(!0)},className:`absolute top-2 right-2 z-30 opacity-90 group-hover/edit-img:opacity-100 transition edit-affordance`,title:`Cambia foto`,children:[(0,y.jsx)(i,{size:14}),` Cambia`]}
1),g&&(0,y.jsx)(b,{k:l,initial:u,isOverridden:f,onClose:()=>_(!1)})]}):x}export{x as t};

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.