import{B as e,Bt as t,Ct as n,D as r,F as i,L as a,N as o,Nt as s,Pt as c,R as l,U as u,Vt as d,W as f,X as p,Y as m,_t as h,a as g,at as _,ft as v,g as y,it as b,mt as x,o as S,ot as C,pt as w,u as T,v as E,vt as D,w as O,x as k,z as A}from"./xY0c-UfG.js";import"./xihTtKlq.js";import"./9K8VREGP.js";import{t as ee}from"./qwr5boV8.js";import{t as j}from"./Dn3R8S-U.js";import{M}from"./B7ikU8uG.js";import{r as N}from"./DzWts1972.js";import{n as P,r as F}from"./N0nIzSkb.js";import{i as I}from"./B-eCsAwG.js";import{t as L}from"./BLs1h0Rh.js";var R=e(`<title> </title>`),z=e(`<svg><!><path d="M12,10H6.78A11,11,0,0,1,27,16h2A13,13,0,0,0,6,7.68V4H4v8h8Z"></path><path d="M20,22h5.22A11,11,0,0,1,5,16H3a13,13,0,0,0,23,8.32V28h2V20H20Z"></path></svg>`);function B(e,n){let r=g(n,[`children`,`$$slots`,`$$events`,`$$legacy`]),l=g(r,[`size`,`title`]);c(n,!1);let u=h(),f=h(),x=S(n,`size`,8,16),w=S(n,`title`,8,void 0);b(()=>(m(r),m(w())),()=>{D(u,r[`aria-label`]||r[`aria-labelledby`]||w())}),b(()=>(p(u),m(r)),()=>{D(f,{"aria-hidden":p(u)?void 0:!0,role:p(u)?`img`:void 0,focusable:Number(r.tabindex)===0?!0:void 0})}),_(),T();var E=z();y(E,()=>({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,fill:`currentColor`,preserveAspectRatio:`xMidYMid meet`,width:x(),height:x(),...p(f),...l}));var O=v(E),k=e=>{var t=R(),n=v(t,!0);d(t),C(()=>i(n,w())),a(e,t)};o(O,e=>{w()&&e(k)}),t(2),d(E),a(e,E),s()}var V=A(`<div><span class="sg-attachment-chip-icon"><!></span> <span class="sg-attachment-chip-name"> </span> <span class="sg-attachment-chip-actions"><button class="sg-attachment-chip-btn" type="button"><!></button></span></div>`),H=A(`<img/>`),U=A(`<span class="sg-attachment-chip-overlay"><!></span>`),W=A(`<span class="sg-attachment-chip-sub"> </span>`),G=A(`<span class="sg-attachment-chip-sub"> </span>`),K=A(`<!><span>Saving…</span>`,1),q=A(`<!><span>Saved to library</span>`,1),J=A(`<!><span>Save to library</span>`,1),Y=A(`<button type="button"><!></button>`),te=A(`<button class="sg-attachment-chip-close sg-attachment-chip-retry" aria-label="Retry upload" type="button"><!></button>`),ne=A(`<div><span><!> <!></span> <span class="sg-attachment-chip-body"><span class="sg-attachment-chip-name"> </span> <!></span> <!> <!> <button class="sg-attachment-chip-close" type="button"><!></button></div>`);function X(e,u){c(u,!0);let m=S(u,`status`,3,`ready`),h=S(u,`compact`,3,!1),g=S(u,`saveState`,3,`idle`),_=n(()=>!h()&&!!u.imageUrl);function y(e){let t=/\.([^.\s]+)\s*$/.exec(e);return t?t[1].toLowerCase():``}let b=n(()=>{let e=y(u.label);return e===`pdf`?{label:`PDF`,icon:F}:e===`csv`||e===`xls`||e===`xlsx`?{label:`Spreadsheet`,icon:P}:e===`md`||e===`markdown`?{label:`Markdown`,icon:N}:e===`txt`||e===`text`?{label:`Text`,icon:N}:{label:`Document`,icon:N}});var T=l(),D=w(T),A=e=>{var t=V();let n;var r=v(t);N(v(r),{size:14}),d(r);var o=x(r,2),s=v(o,!0);d(o),O(o,e=>I?.(e));var c=x(o,2),l=v(c);M(v(l),{size:14}),d(l),d(c),d(t),C(()=>{n=k(t,1,`sg-attachment-chip is-compact`,null,n,{"is-error":m()===`error`}),E(t,`title`,u.label),i(s,u.label),E(l,`aria-label`,`Remove ${u.label??``}`)}),f(`click`,l,function(...e){u.onremove?.apply(this,e)}),a(e,t)},R=e=>{var s=ne();let c;var h=v(s);let y;var S=v(h),T=e=>{var t=H();C(()=>{E(t,`src`,u.imageUrl),E(t,`alt`,u.label)}),a(e,t)},D=e=>{let t=n(()=>p(b).icon);var i=l();r(w(i),()=>p(t),(e,t)=>{t(e,{size:20})}),a(e,i)};o(S,e=>{p(_)?e(T):e(D,-1)});var A=x(S,2),N=e=>{var t=U();j(v(t),{size:16}),d(t),a(e,t)};o(A,e=>{m()===`uploading`&&e(N)}),d(h);var P=x(h,2),F=v(P),R=v(F,!0);d(F),O(F,e=>I?.(e));var z=x(F,2),V=e=>{var t=W(),n=v(t,!0);d(t),C(()=>i(n,u.sub)),a(e,t)},X=e=>{var t=G(),n=v(t,!0);d(t),C(()=>i(n,p(b).label)),a(e,t)};o(z,e=>{m()===`error`&&u.sub?e(V):p(_)||e(X,1)}),d(P);var Z=x(P,2),re=e=>{var n=Y();let r;var i=v(n),s=e=>{var n=K();j(w(n),{size:12}),t(),a(e,n)},c=e=>{var n=q();ee(w(n),{size:12}),t(),a(e,n)},l=e=>{var n=J();L(w(n),{size:12}),t(),a(e,n)};o(i,e=>{g()===`saving`?e(s):g()===`saved`?e(c,1):e(l,-1)}),d(n),C(()=>{r=k(n,1,`sg-attachment-chip-save`,null,r,{"is-saving":g()===`saving`,"is-saved":g()===`saved`}),n.disabled=g()===`saving`||g()===`saved`}),f(`click`,n,function(...e){u.onsave?.apply(this,e)}),a(e,n)};o(Z,e=>{u.onsave&&m()===`ready`&&e(re)});var Q=x(Z,2),ie=e=>{var t=te();B(v(t),{size:12}),d(t),f(`click`,t,function(...e){u.onretry?.apply(this,e)}),a(e,t)};o(Q,e=>{m()===`error`&&u.onretry&&e(ie)});var $=x(Q,2);M(v($),{size:12}),d($),d(s),C(()=>{c=k(s,1,`sg-attachment-chip`,null,c,{"is-error":m()===`error`}),E(s,`title`,u.label),y=k(h,1,`sg-attachment-chip-thumb`,null,y,{"is-doc":!p(_)}),i(R,u.label),E($,`aria-label`,`Remove ${u.label??``}`)}),f(`click`,$,function(...e){u.onremove?.apply(this,e)}),a(e,s)};o(D,e=>{h()?e(A):e(R,-1)}),a(e,T),s()}u([`click`]);export{X as t};