@thanhpv102/simple-image-asset-manager 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),xe=require("antd"),Y=require("@ant-design/icons");var Q={exports:{}},$={};var ce;function ye(){if(ce)return $;ce=1;var d=Symbol.for("react.transitional.element"),E=Symbol.for("react.fragment");function _(y,u,f){var T=null;if(f!==void 0&&(T=""+f),u.key!==void 0&&(T=""+u.key),"key"in u){f={};for(var N in u)N!=="key"&&(f[N]=u[N])}else f=u;return u=f.ref,{$$typeof:d,type:y,key:T,ref:u!==void 0?u:null,props:f}}return $.Fragment=E,$.jsx=_,$.jsxs=_,$}var q={};var ue;function ve(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&(function(){function d(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case v:return"Fragment";case w:return"Profiler";case O:return"StrictMode";case B:return"Suspense";case H:return"SuspenseList";case X:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case h:return"Portal";case g:return e.displayName||"Context";case ee:return(e._context.displayName||"Context")+".Consumer";case G:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return n=e.displayName||null,n!==null?n:d(e.type)||"Memo";case C:n=e._payload,e=e._init;try{return d(e(n))}catch{}}return null}function E(e){return""+e}function _(e){try{E(e);var n=!1}catch{n=!0}if(n){n=console;var i=n.error,l=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",l),E(e)}}function y(e){if(e===v)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===C)return"<...>";try{var n=d(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function u(){var e=j.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function T(e){if(F.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function N(e,n){function i(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function ie(){var e=d(this.type);return o[e]||(o[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function K(e,n,i,l,W,M){var s=i.ref;return e={$$typeof:z,type:e,key:n,props:i,_owner:l},(s!==void 0?s:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:ie}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function V(e,n,i,l,W,M){var s=n.children;if(s!==void 0)if(l)if(I(s)){for(l=0;l<s.length;l++)b(s[l]);Object.freeze&&Object.freeze(s)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(s);if(F.call(n,"key")){s=d(e);var R=Object.keys(n).filter(function(te){return te!=="key"});l=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",Z[s+l]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),ye=require("antd"),Y=require("@ant-design/icons");var Q={exports:{}},B={};var ue;function we(){if(ue)return B;ue=1;var c=Symbol.for("react.transitional.element"),E=Symbol.for("react.fragment");function _(v,u,m){var S=null;if(m!==void 0&&(S=""+m),u.key!==void 0&&(S=""+u.key),"key"in u){m={};for(var C in u)C!=="key"&&(m[C]=u[C])}else m=u;return u=m.ref,{$$typeof:c,type:v,key:S,ref:u!==void 0?u:null,props:m}}return B.Fragment=E,B.jsx=_,B.jsxs=_,B}var q={};var me;function je(){return me||(me=1,process.env.NODE_ENV!=="production"&&(function(){function c(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Z?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case k:return"Profiler";case A:return"StrictMode";case H:return"Suspense";case z:return"SuspenseList";case M:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case ee:return"Portal";case te:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case p:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case X:return n=e.displayName||null,n!==null?n:c(e.type)||"Memo";case T:n=e._payload,e=e._init;try{return c(e(n))}catch{}}return null}function E(e){return""+e}function _(e){try{E(e);var n=!1}catch{n=!0}if(n){n=console;var s=n.error,i=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return s.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",i),E(e)}}function v(e){if(e===f)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===T)return"<...>";try{var n=c(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function u(){var e=F.A;return e===null?null:e.getOwner()}function m(){return Error("react-stack-top-frame")}function S(e){if(N.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function C(e,n){function s(){P||(P=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}function se(){var e=c(this.type);return W[e]||(W[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function K(e,n,s,i,O,D){var o=s.ref;return e={$$typeof:L,type:e,key:n,props:s,_owner:i},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:se}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:O}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function J(e,n,s,i,O,D){var o=n.children;if(o!==void 0)if(i)if(I(o)){for(i=0;i<o.length;i++)b(o[i]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(o);if(N.call(n,"key")){o=c(e);var R=Object.keys(n).filter(function(re){return re!=="key"});i=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",j[o+i]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,l,s,R,s),Z[s+l]=!0)}if(s=null,i!==void 0&&(_(i),s=""+i),T(n)&&(_(n.key),s=""+n.key),"key"in n){i={};for(var U in n)U!=="key"&&(i[U]=n[U])}else i=n;return s&&N(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),K(e,s,i,u(),W,M)}function b(e){J(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===C&&(e._payload.status==="fulfilled"?J(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function J(e){return typeof e=="object"&&e!==null&&e.$$typeof===z}var P=c,z=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),g=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),A=Symbol.for("react.client.reference"),j=P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,I=Array.isArray,x=console.createTask?console.createTask:function(){return null};P={react_stack_bottom_frame:function(e){return e()}};var D,o={},k=P.react_stack_bottom_frame.bind(P,f)(),S=x(y(f)),Z={};q.Fragment=v,q.jsx=function(e,n,i){var l=1e4>j.recentlyCreatedOwnerStacks++;return V(e,n,i,!1,l?Error("react-stack-top-frame"):k,l?x(y(e)):S)},q.jsxs=function(e,n,i){var l=1e4>j.recentlyCreatedOwnerStacks++;return V(e,n,i,!0,l?Error("react-stack-top-frame"):k,l?x(y(e)):S)}})()),q}var fe;function we(){return fe||(fe=1,process.env.NODE_ENV==="production"?Q.exports=ye():Q.exports=ve()),Q.exports}var r=we();function m(d){return d.type==="FILE"}function oe(d){return d.type==="FOLDER"}const je=({accept:d="image/*",request:E,title:_="Asset Manager",upload:y,onCreateFile:u,onDeleteFile:f,onDeleteFolder:T,onUpdateFile:N,onUpdateFolder:ie,onCreateFolder:K,onSelect:V,visible:b=!1,setVisible:J,showUnacceptedFile:P=!1,addFolderEnabled:z=!0})=>{const[h,v]=c.useState(null),[O,w]=c.useState([]),[ee,g]=c.useState(!1),[G,B]=c.useState(null),[H,L]=c.useState(!1),[C,X]=c.useState(""),[A,j]=c.useState(!1),[F,I]=c.useState([]),[x,D]=c.useState(!1),[o,k]=c.useState(null),[S,Z]=c.useState("thumbnail"),e=c.useRef(null),[n,i]=c.useState(window.innerWidth);c.useEffect(()=>{b&&(g(!0),B(null),E(h===null?void 0:h).then(t=>w(t)).catch(t=>B(t?.message||"Failed to load assets")).finally(()=>g(!1)))},[h,b,E]),c.useEffect(()=>{b&&h===null&&I([])},[h,b]),c.useEffect(()=>{const t=()=>i(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);const l=()=>{J(!1),v(null),I([]),B(null)},W=t=>{t===-1?(v(null),I([])):(v(F[t].id),I(F.slice(0,t+1)))},M=async t=>{g(!0),await f({id:t.id}),w(a=>a.filter(p=>p!==t)),g(!1)},s=async t=>{g(!0),await T({id:t.id}),w(a=>a.filter(p=>p!==t)),g(!1)},R=async()=>{if(!C.trim())return;g(!0);const t=await K({name:C,parentFolderId:h});w(a=>[...a,t]),X(""),L(!1),g(!1)},U=async t=>{const a=t.target.files;if(!(!a||a.length===0)){j(!0);for(const p of Array.from(a)){if(d&&!p.type.match(d.replace("*",".*")))continue;const re=await y(p),ne=await u({name:p.name,url:re,parentFolderId:h});w(be=>[...be,ne])}j(!1),e.current&&(e.current.value="")}},te=t=>{t.preventDefault(),D(!0)},pe=t=>{t.preventDefault(),D(!1)},me=async t=>{if(t.preventDefault(),D(!1),!!t.dataTransfer.files){j(!0);for(const a of Array.from(t.dataTransfer.files)){if(d&&!a.type.match(d.replace("*",".*")))continue;const p=await y(a),re=await u({name:a.name,url:p,parentFolderId:h});w(ne=>[...ne,re])}j(!1)}},ae=t=>{k(t)},le=t=>{v(t.id),I(a=>[...a,t]),k(t)},he=()=>{o&&m(o)&&(V(o.url),l())},se=async()=>{o&&(m(o)?(await M(o),k(null)):oe(o)&&(await s(o),k(null)))},de=Math.round(n*.8),ge=Math.round(de*.6);return b?r.jsx(xe.Modal,{open:b,title:r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[r.jsx("span",{children:_}),r.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:0,marginRight:40,marginTop:-10},children:r.jsx("button",{onClick:()=>Z(S==="thumbnail"?"list":"thumbnail"),style:{background:"none",border:"none",cursor:"pointer",padding:0,marginTop:8,fontSize:22,color:"#222",display:"flex",alignItems:"center",transition:"color 0.2s"},title:S==="thumbnail"?"List view":"Thumbnail view",children:S==="thumbnail"?r.jsx(Y.BarsOutlined,{}):r.jsx(Y.AppstoreOutlined,{})})})]}),onCancel:l,footer:null,width:de,styles:{body:{padding:0}},destroyOnHidden:!0,mask:{closable:!1},centered:!0,children:r.jsxs("div",{className:"simple-image-asset-manager-modal",style:{padding:24},children:[r.jsxs("div",{className:"modal-body",style:{display:"flex",gap:24},children:[r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{marginBottom:8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap"},children:[r.jsx("span",{className:"breadcrumb",onClick:()=>W(-1),style:{cursor:"pointer",color:"#1890ff",textDecoration:"underline",fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:"All"}),F.map((t,a)=>{const p=a===F.length-1;return r.jsxs("span",{style:{display:"flex",alignItems:"center"},children:[r.jsx("span",{style:{margin:"0 4px",fontWeight:500},children:"/"}),p?r.jsx("span",{className:"breadcrumb",style:{color:"#222",fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name}):r.jsx("span",{className:"breadcrumb",onClick:()=>W(a),style:{cursor:"pointer",color:"#1890ff",textDecoration:"underline",fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]},t.id)})]}),z&&!H&&r.jsxs("button",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",userSelect:"none",fontWeight:500,fontSize:15,padding:"8px 20px",borderRadius:4,background:"#1890ff",color:"#fff",border:"none",boxShadow:"0 2px 8px rgba(24,144,255,0.12)",transition:"background 0.2s, box-shadow 0.2s"},onClick:()=>L(!0),children:[r.jsx("span",{children:"New folder"}),r.jsx(Y.FolderAddOutlined,{style:{fontSize:20}})]})]}),r.jsxs("div",{className:`drop-area${x?" drag-active":""}`,onDrop:me,onDragOver:te,onDragLeave:pe,style:{border:x?"2px solid #1890ff":"2px dashed #aaa",borderRadius:8,padding:32,marginBottom:24,textAlign:"center",background:x?"#e6f7ff":"#fafafa",position:"relative",transition:"border-color 0.3s, background 0.3s"},children:[r.jsx("div",{style:{marginBottom:8,fontWeight:500},children:x?"Drop file here to upload":"Drag & drop files here"}),r.jsx("button",{onClick:()=>e.current?.click(),disabled:A,style:{marginBottom:8,visibility:x?"hidden":"visible",padding:"8px 24px",borderRadius:4,background:A?"#ccc":"#1890ff",color:"#fff",border:"none",cursor:A?"not-allowed":"pointer",fontWeight:500,fontSize:15,boxShadow:A?"none":"0 2px 8px rgba(24,144,255,0.12)",transition:"background 0.2s, box-shadow 0.2s"},children:"Upload"}),r.jsx("input",{ref:e,type:"file",accept:d,style:{display:"none"},multiple:!0,onChange:U}),A&&r.jsx("div",{children:"Uploading..."})]}),ee?r.jsx("div",{children:"Loading..."}):G?r.jsx("div",{className:"error",children:G}):r.jsxs("div",{children:[z&&H&&r.jsxs("div",{style:{marginBottom:16,display:"flex",alignItems:"center",gap:8},children:[r.jsx("input",{value:C,onChange:t=>X(t.target.value),placeholder:"Folder name",style:{padding:"8px 12px",borderRadius:4,border:"1px solid #d9d9d9",fontSize:15,fontWeight:500,outline:"none",transition:"border-color 0.2s",boxSizing:"border-box"},onFocus:t=>t.target.style.borderColor="#1890ff",onBlur:t=>t.target.style.borderColor="#d9d9d9"}),r.jsx("button",{onClick:R,style:{padding:"8px 16px",borderRadius:4,background:"#1890ff",color:"#fff",border:"none",fontWeight:500,fontSize:15,cursor:"pointer",boxShadow:"0 2px 8px rgba(24,144,255,0.12)",transition:"background 0.2s"},children:"Create"}),r.jsx("button",{onClick:()=>L(!1),style:{padding:"8px 16px",borderRadius:4,background:"#f5f5f5",color:"#222",border:"1px solid #d9d9d9",fontWeight:500,fontSize:15,cursor:"pointer",transition:"background 0.2s"},children:"Cancel"})]}),S==="thumbnail"?r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16},children:O.filter(oe).map(t=>r.jsxs("div",{className:"folder-item",style:{cursor:"pointer",width:120,minWidth:120,maxWidth:120,display:"flex",flexDirection:"column",alignItems:"center",padding:8,borderRadius:8,background:"#fafafa",boxSizing:"border-box"},onClick:()=>le(t),children:[t.thumbnail?r.jsx("img",{src:t.thumbnail,alt:t.name,style:{width:64,height:64,objectFit:"cover",borderRadius:4,marginBottom:8,background:"#fff"}}):r.jsx("div",{style:{fontSize:40,width:64,height:64,display:"flex",alignItems:"center",justifyContent:"center",marginBottom:8,background:"#fff",borderRadius:4},children:"📁"}),r.jsx("div",{style:{fontSize:13,fontWeight:500,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]},t.id))}):r.jsx("div",{style:{display:"block",marginBottom:16},children:O.filter(oe).map(t=>r.jsxs("div",{className:"folder-item",style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0",borderBottom:"1px solid #f0f0f0",cursor:"pointer"},onClick:()=>le(t),children:[t.thumbnail?r.jsx("img",{src:t.thumbnail,alt:t.name,style:{width:32,height:32,objectFit:"cover",borderRadius:4,background:"#fff"}}):r.jsx("div",{style:{fontSize:24,width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"#fff",borderRadius:4},children:"📁"}),r.jsx("div",{style:{fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:t.name})]},t.id))}),S==="thumbnail"?r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,marginTop:16},children:O.filter(m).map(t=>{const a=o&&m(o)&&o.id===t.id;return r.jsxs("div",{className:"file-item",style:{cursor:"pointer",width:120,minWidth:120,maxWidth:120,border:"2px solid "+(a?"#1890ff":"transparent"),background:a?"#e6f7ff":"#fafafa",borderRadius:8,boxSizing:"border-box",transition:"border-color 0.2s, background 0.2s",padding:8,display:"flex",flexDirection:"column",alignItems:"center"},onClick:()=>ae(t),children:[r.jsx("img",{src:t.thumbnail||t.url,alt:t.name,style:{width:64,height:64,objectFit:"cover",borderRadius:4,background:"#fff",marginBottom:8}}),r.jsx("div",{style:{fontSize:12,fontWeight:500,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:t.name})]},t.id)})}):r.jsx("div",{style:{display:"block",marginTop:16},children:O.filter(m).map(t=>{const a=o&&m(o)&&o.id===t.id;return r.jsxs("div",{className:"file-item",style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0",borderBottom:"1px solid #f0f0f0",cursor:"pointer",background:a?"#e6f7ff":"#fff"},onClick:()=>ae(t),children:[r.jsx("img",{src:t.thumbnail||t.url,alt:t.name,style:{width:32,height:32,objectFit:"cover",borderRadius:4,background:"#fff"}}),r.jsx("div",{style:{fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:t.name})]},t.id)})})]})]}),o&&r.jsx("div",{style:{width:ge,minWidth:320,transition:"width 2s",overflow:"hidden"},children:r.jsxs("div",{style:{border:"1px solid #eee",borderRadius:8,padding:16,background:"#fff",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",position:"relative"},children:[r.jsx("button",{onClick:()=>k(null),style:{position:"absolute",top:12,right:12,background:"#f5f5f5",border:"none",borderRadius:4,padding:"4px 12px",cursor:"pointer",fontWeight:500,fontSize:14,color:"#222",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Hide"}),m(o)?r.jsxs(r.Fragment,{children:[r.jsx("img",{src:o.thumbnail||o.url,alt:o.name,style:{width:"100%",maxHeight:240,objectFit:"contain",borderRadius:4,marginBottom:16}}),r.jsx("div",{style:{fontWeight:500,marginBottom:8},children:o.name}),r.jsx("div",{style:{fontSize:12,color:"#888",marginBottom:8},children:o.url.startsWith("data:")?"URL: data-uri":r.jsxs(r.Fragment,{children:["URL: ",r.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",children:o.url})]})}),r.jsxs("button",{onClick:se,style:{display:"flex",alignItems:"center",gap:6,color:"#ff4d4f",background:"none",border:"none",cursor:"pointer",fontWeight:500,fontSize:15,marginTop:24},children:[r.jsx(Y.DeleteOutlined,{})," Delete"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:64,marginBottom:16},children:"📁"}),r.jsx("div",{style:{fontWeight:500,marginBottom:8},children:o.name}),r.jsx("div",{style:{fontSize:12,color:"#888",marginBottom:8},children:`Files: ${O.filter(t=>m(t)&&t.parentFolderId===o.id).length}`}),r.jsxs("button",{onClick:se,style:{display:"flex",alignItems:"center",gap:6,color:"#ff4d4f",background:"none",border:"none",cursor:"pointer",fontWeight:500,fontSize:15,marginTop:24},children:[r.jsx(Y.DeleteOutlined,{})," Delete"]})]})]})})]}),r.jsx("div",{className:"modal-footer",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",marginTop:24},children:r.jsx("button",{onClick:he,disabled:!(o&&m(o)),style:{padding:"8px 24px",borderRadius:4,background:o&&m(o)?"#1890ff":"#ccc",color:"#fff",border:"none",cursor:o&&m(o)?"pointer":"not-allowed",fontWeight:500},children:"Select"})})]})}):null};exports.AssetManager=je;
6
+ <%s key={someKey} {...props} />`,i,o,R,o),j[o+i]=!0)}if(o=null,s!==void 0&&(_(s),o=""+s),S(n)&&(_(n.key),o=""+n.key),"key"in n){s={};for(var U in n)U!=="key"&&(s[U]=n[U])}else s=n;return o&&C(s,typeof e=="function"?e.displayName||e.name||"Unknown":e),K(e,o,s,u(),O,D)}function b(e){G(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===T&&(e._payload.status==="fulfilled"?G(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function G(e){return typeof e=="object"&&e!==null&&e.$$typeof===L}var $=d,L=Symbol.for("react.transitional.element"),ee=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),te=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),Z=Symbol.for("react.client.reference"),F=$.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=Object.prototype.hasOwnProperty,I=Array.isArray,g=console.createTask?console.createTask:function(){return null};$={react_stack_bottom_frame:function(e){return e()}};var P,W={},a=$.react_stack_bottom_frame.bind($,m)(),w=g(v(m)),j={};q.Fragment=f,q.jsx=function(e,n,s){var i=1e4>F.recentlyCreatedOwnerStacks++;return J(e,n,s,!1,i?Error("react-stack-top-frame"):a,i?g(v(e)):w)},q.jsxs=function(e,n,s){var i=1e4>F.recentlyCreatedOwnerStacks++;return J(e,n,s,!0,i?Error("react-stack-top-frame"):a,i?g(v(e)):w)}})()),q}var fe;function Re(){return fe||(fe=1,process.env.NODE_ENV==="production"?Q.exports=we():Q.exports=je()),Q.exports}var r=Re();function x(c){return c.type==="FILE"}function V(c){return c.type==="FOLDER"}const Ee=({accept:c="image/*",request:E,title:_="Asset Manager",upload:v,onCreateFile:u,onDeleteFile:m,onDeleteFolder:S,onUpdateFile:C,onUpdateFolder:se,onCreateFolder:K,onSelect:J,visible:b=!1,setVisible:G,showUnacceptedFile:$=!1,addFolderEnabled:L=!0,getContainer:ee})=>{const[f,A]=d.useState(null),[k,y]=d.useState([]),[te,p]=d.useState(!1),[H,z]=d.useState(null),[X,T]=d.useState(!1),[M,Z]=d.useState(""),[F,N]=d.useState(!1),[I,g]=d.useState([]),[P,W]=d.useState(!1),[a,w]=d.useState(null),[j,e]=d.useState("thumbnail"),n=d.useRef(null),[s,i]=d.useState(window.innerWidth);d.useEffect(()=>{b&&(p(!0),z(null),E(f===null?void 0:f).then(t=>y(t)).catch(t=>z(t?.message||"Failed to load assets")).finally(()=>p(!1)))},[f,b,E]),d.useEffect(()=>{b&&f===null&&g([])},[f,b]),d.useEffect(()=>{const t=()=>i(window.innerWidth);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);const O=()=>{G(!1),A(null),g([]),z(null)},D=t=>{t===-1?(A(null),g([])):(A(I[t].id),g(I.slice(0,t+1)))},o=async t=>{p(!0),await m({id:t.id}),y(l=>l.filter(h=>h!==t)),p(!1)},R=async t=>{p(!0),await S({id:t.id}),y(l=>l.filter(h=>h!==t)),p(!1)},U=async()=>{if(!M.trim())return;p(!0);const t=await K({name:M,parentFolderId:f});y(l=>[...l,t]),Z(""),T(!1),p(!1)},re=async t=>{const l=t.target.files;if(!(!l||l.length===0)){N(!0);for(const h of Array.from(l)){if(c&&!h.type.match(c.replace("*",".*")))continue;const ne=await v(h),ae=await u({name:h.name,url:ne,parentFolderId:f});y(ve=>[...ve,ae])}N(!1),n.current&&(n.current.value="")}},he=t=>{t.preventDefault(),W(!0)},pe=t=>{t.preventDefault(),W(!1)},be=async t=>{if(t.preventDefault(),W(!1),!!t.dataTransfer.files){N(!0);for(const l of Array.from(t.dataTransfer.files)){if(c&&!l.type.match(c.replace("*",".*")))continue;const h=await v(l),ne=await u({name:l.name,url:h,parentFolderId:f});y(ae=>[...ae,ne])}N(!1)}},le=t=>{w(t)},ie=t=>{A(t.id),g(l=>[...l,t]),w(t)},ge=()=>{a&&x(a)&&(J(a.url),O())},oe=async()=>{a&&(x(a)?(await o(a),w(null)):V(a)&&(await R(a),w(null)))},ce=Math.round(s*.8),xe=Math.round(ce*.6),de=!!(a&&x(a));return b?r.jsx(ye.Modal,{open:b,title:r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[r.jsx("span",{children:_}),r.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:0,marginRight:40,marginTop:-10},children:r.jsx("button",{onClick:()=>e(j==="thumbnail"?"list":"thumbnail"),className:"asset-manager-btn asset-manager-btn--icon",title:j==="thumbnail"?"List view":"Thumbnail view",children:j==="thumbnail"?r.jsx(Y.BarsOutlined,{}):r.jsx(Y.AppstoreOutlined,{})})})]}),onCancel:O,footer:null,width:ce,styles:{body:{padding:0}},destroyOnHidden:!0,mask:{closable:!1},centered:!0,getContainer:ee,children:r.jsxs("div",{className:"simple-image-asset-manager-modal",style:{padding:24},children:[r.jsxs("div",{className:"modal-body",style:{display:"flex",gap:24},children:[r.jsxs("div",{style:{flex:1},children:[r.jsxs("div",{style:{marginBottom:8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap"},children:[r.jsx("span",{className:"breadcrumb breadcrumb--link",onClick:()=>D(-1),style:{fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:"All"}),I.map((t,l)=>{const h=l===I.length-1;return r.jsxs("span",{style:{display:"flex",alignItems:"center"},children:[r.jsx("span",{style:{margin:"0 4px",fontWeight:500},children:"/"}),h?r.jsx("span",{className:"breadcrumb breadcrumb--current",style:{fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name}):r.jsx("span",{className:"breadcrumb breadcrumb--link",onClick:()=>D(l),style:{fontWeight:500,maxWidth:120,display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]},t.id)})]}),L&&!X&&r.jsxs("button",{className:"asset-manager-btn asset-manager-btn--primary asset-manager-btn--new-folder",onClick:()=>T(!0),children:[r.jsx("span",{children:"New folder"}),r.jsx(Y.FolderAddOutlined,{style:{fontSize:20}})]})]}),r.jsxs("div",{className:`drop-area${P?" drag-active":""}`,onDrop:be,onDragOver:he,onDragLeave:pe,style:{borderRadius:8,padding:32,marginBottom:24,textAlign:"center",position:"relative"},children:[r.jsx("div",{style:{marginBottom:8,fontWeight:500},children:P?"Drop file here to upload":"Drag & drop files here"}),r.jsx("button",{className:"atn-btn atn-btn-primary asset-manager-btn asset-manager-btn--primary asset-manager-btn--upload",onClick:()=>n.current?.click(),disabled:F,style:{visibility:P?"hidden":"visible"},children:"Upload"}),r.jsx("input",{ref:n,type:"file",accept:c,style:{display:"none"},multiple:!0,onChange:re}),F&&r.jsx("div",{children:"Uploading..."})]}),te?r.jsx("div",{children:"Loading..."}):H?r.jsx("div",{className:"error",children:H}):r.jsxs("div",{children:[L&&X&&r.jsxs("div",{style:{marginBottom:16,display:"flex",alignItems:"center",gap:8},children:[r.jsx("input",{value:M,onChange:t=>Z(t.target.value),placeholder:"Folder name",style:{padding:"8px 12px",borderRadius:4,border:"1px solid #d9d9d9",fontSize:15,fontWeight:500,outline:"none",transition:"border-color 0.2s",boxSizing:"border-box"},onFocus:t=>t.target.style.borderColor="#1890ff",onBlur:t=>t.target.style.borderColor="#d9d9d9"}),r.jsx("button",{onClick:U,className:"asset-manager-btn asset-manager-btn--primary asset-manager-btn--compact",children:"Create"}),r.jsx("button",{onClick:()=>T(!1),className:"asset-manager-btn asset-manager-btn--secondary asset-manager-btn--compact",children:"Cancel"})]}),j==="thumbnail"?r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16},children:k.filter(V).map(t=>r.jsxs("div",{className:`folder-item folder-item--thumbnail ${a&&V(a)&&a.id===t.id?"folder-item--selected":""}`,style:{cursor:"pointer",width:120,minWidth:120,maxWidth:120,display:"flex",flexDirection:"column",alignItems:"center",padding:8,borderRadius:8,boxSizing:"border-box"},onClick:()=>ie(t),children:[t.thumbnail?r.jsx("img",{src:t.thumbnail,alt:t.name,className:"asset-icon-placeholder",style:{width:64,height:64,objectFit:"cover",borderRadius:4,marginBottom:8}}):r.jsx("div",{className:"asset-icon-placeholder asset-icon-folder",style:{fontSize:40,width:64,height:64,display:"flex",alignItems:"center",justifyContent:"center",marginBottom:8,borderRadius:4},children:"📁"}),r.jsx("div",{style:{fontSize:13,fontWeight:500,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]},t.id))}):r.jsx("div",{style:{display:"block",marginBottom:16},children:k.filter(V).map(t=>r.jsxs("div",{className:`folder-item folder-item--list ${a&&V(a)&&a.id===t.id?"folder-item--selected":""}`,style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0",borderBottom:"1px solid #f0f0f0",cursor:"pointer"},onClick:()=>ie(t),children:[t.thumbnail?r.jsx("img",{src:t.thumbnail,alt:t.name,className:"asset-icon-placeholder",style:{width:32,height:32,objectFit:"cover",borderRadius:4}}):r.jsx("div",{className:"asset-icon-placeholder asset-icon-folder",style:{fontSize:24,width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:4},children:"📁"}),r.jsx("div",{style:{fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:t.name})]},t.id))}),j==="thumbnail"?r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,marginTop:16},children:k.filter(x).map(t=>{const l=a&&x(a)&&a.id===t.id;return r.jsxs("div",{className:`file-item file-item--thumbnail ${l?"file-item--selected":""}`,style:{cursor:"pointer",width:120,minWidth:120,maxWidth:120,borderRadius:8,boxSizing:"border-box",padding:8,display:"flex",flexDirection:"column",alignItems:"center"},onClick:()=>le(t),children:[r.jsx("img",{src:t.thumbnail||t.url,alt:t.name,className:"asset-icon-placeholder",style:{width:64,height:64,objectFit:"cover",borderRadius:4,marginBottom:8}}),r.jsx("div",{style:{fontSize:12,fontWeight:500,width:"100%",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:t.name})]},t.id)})}):r.jsx("div",{style:{display:"block",marginTop:16},children:k.filter(x).map(t=>{const l=a&&x(a)&&a.id===t.id;return r.jsxs("div",{className:`file-item file-item--list ${l?"file-item--selected":""}`,style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0",borderBottom:"1px solid #f0f0f0",cursor:"pointer"},onClick:()=>le(t),children:[r.jsx("img",{src:t.thumbnail||t.url,alt:t.name,className:"asset-icon-placeholder",style:{width:32,height:32,objectFit:"cover",borderRadius:4}}),r.jsx("div",{style:{fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1},children:t.name})]},t.id)})})]})]}),a&&r.jsx("div",{style:{width:xe,minWidth:320,transition:"width 2s",overflow:"hidden"},children:r.jsxs("div",{className:"asset-preview-panel",children:[r.jsx("button",{onClick:()=>w(null),className:"asset-manager-btn asset-manager-btn--secondary asset-manager-btn--hide",children:"Hide"}),x(a)?r.jsxs(r.Fragment,{children:[r.jsx("img",{src:a.thumbnail||a.url,alt:a.name,style:{width:"100%",maxHeight:240,objectFit:"contain",borderRadius:4,marginBottom:16}}),r.jsx("div",{className:"asset-preview-title",children:a.name}),r.jsx("div",{className:"asset-preview-meta",children:a.url.startsWith("data:")?"URL: data-uri":r.jsxs(r.Fragment,{children:["URL: ",r.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",children:a.url})]})}),r.jsxs("button",{onClick:oe,className:"asset-manager-btn asset-manager-btn--danger asset-manager-btn--delete",children:[r.jsx(Y.DeleteOutlined,{})," Delete"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"asset-preview-folder-icon",children:"📁"}),r.jsx("div",{className:"asset-preview-title",children:a.name}),r.jsx("div",{className:"asset-preview-meta",children:`Files: ${k.filter(t=>x(t)&&t.parentFolderId===a.id).length}`}),r.jsxs("button",{onClick:oe,className:"asset-manager-btn asset-manager-btn--danger asset-manager-btn--delete",children:[r.jsx(Y.DeleteOutlined,{})," Delete"]})]})]})})]}),r.jsx("div",{className:"modal-footer",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",marginTop:24},children:r.jsx("button",{onClick:ge,disabled:!de,className:`asset-manager-btn asset-manager-btn--select ${de?"asset-manager-btn--primary":"asset-manager-btn--disabled"}`,children:"Select"})})]})}):null};exports.AssetManager=Ee;