|
|
import{G as s,d as K,c as D,i as re,s as $,E as Se,O as U,P as Ee,a2 as Me,F as pe,Q as Ne,o as X,b as J,e as S,t as xe,f as ne,w as F,q as x,J as te,u as _,g as Q,r as Ae,N as ce,K as He,h as ue,T as Ve,m as qe,p as Xe}from"./index-bVOhw2NF.js";import{s as me,_ as Ge}from"./http-D9Asdp-z.js";import{u as _e,S as Ke,_ as We}from"./Scrollbar-Db3aKfvv.js";import{N as Re,B as Y}from"./Button-B7xQqa1N.js";import{_ as Ze}from"./Tree-CzaEbcLe.js";import{E as Je,_ as Qe}from"./Input-CFQSA5NN.js";import{_ as Ye}from"./FormItem-Cp_SJVoE.js";import{_ as et}from"./Form-BZRGTIxb.js";import{_ as Ce}from"./Modal-BHLPhdX-.js";import{_ as tt}from"./Checkbox-DAl6jmZx.js";import{_ as ke,D as nt,N as ot}from"./Image-CAe7wDsQ.js";import{N as rt,T as it}from"./noImage-CAsvTj-5.js";import{c as b,b as O,u as Te,f as le,h as Be,v as ae,w as lt,d as H,a as G}from"./light-Cua7cqmF.js";import{t as at}from"./light-Blmb_y9V.js";import{c as st}from"./context-KbjOeZY_.js";import{i as dt}from"./is-browser-DqcmxZSF.js";import{a as ut}from"./resolve-slot-Dzko3qih.js";import{r as se,N as Z}from"./Icon-Ck7Ij_E6.js";import{A as ct}from"./Add-CgLKrdZy.js";import{_ as ft}from"./Progress-BpvQ1C2a.js";import{u as pt}from"./use-memo-BgHp9YyU.js";import{N as mt,i as gt}from"./icon-switch.cssr-BCTOxvoq.js";import{d as ht}from"./download-C2161hUv.js";import{f as ge}from"./fade-in-height-expand.cssr-Bx380MfO.js";import{u as vt}from"./light-DWk6YUKo.js";import{u as yt}from"./use-form-item-CNgNT5jP.js";import{u as bt}from"./use-merged-state-CzrzZJbg.js";import{c as he}from"./index-L98eAIry.js";import{c as ve}from"./call-f2ri57Kd.js";import{N as wt}from"./Icon-C8ZbiYW7.js";const xt=se("attach",s("svg",{viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},s("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},s("g",{fill:"currentColor","fill-rule":"nonzero"},s("path",{d:"M3.25735931,8.70710678 L7.85355339,4.1109127 C8.82986412,3.13460197 10.4127766,3.13460197 11.3890873,4.1109127 C12.365398,5.08722343 12.365398,6.67013588 11.3890873,7.64644661 L6.08578644,12.9497475 C5.69526215,13.3402718 5.06209717,13.3402718 4.67157288,12.9497475 C4.28104858,12.5592232 4.28104858,11.9260582 4.67157288,11.5355339 L9.97487373,6.23223305 C10.1701359,6.0369709 10.1701359,5.72038841 9.97487373,5.52512627 C9.77961159,5.32986412 9.4630291,5.32986412 9.26776695,5.52512627 L3.96446609,10.8284271 C3.18341751,11.6094757 3.18341751,12.8758057 3.96446609,13.6568542 C4.74551468,14.4379028 6.01184464,14.4379028 6.79289322,13.6568542 L12.0961941,8.35355339 C13.4630291,6.98671837 13.4630291,4.77064094 12.0961941,3.40380592 C10.7293591,2.0369709 8.51328163,2.0369709 7.14644661,3.40380592 L2.55025253,8 C2.35499039,8.19526215 2.35499039,8.51184464 2.55025253,8.70710678 C2.74551468,8.90236893 3.06209717,8.90236893 3.25735931,8.70710678 Z"}))))),_t=se("trash",s("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},s("path",{d:"M432,144,403.33,419.74A32,32,0,0,1,371.55,448H140.46a32,32,0,0,1-31.78-28.26L80,144",style:"fill: none; stroke: currentcolor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 32px;"}),s("rect",{x:"32",y:"64",width:"448",height:"80",rx:"16",ry:"16",style:"fill: none; stroke: currentcolor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 32px;"}),s("line",{x1:"312",y1:"240",x2:"200",y2:"352",style:"fill: none; stroke: currentcolor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 32px;"}),s("line",{x1:"312",y1:"352",x2:"200",y2:"240",style:"fill: none; stroke: currentcolor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 32px;"}))),Rt=se("cancel",s("svg",{viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},s("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},s("g",{fill:"currentColor","fill-rule":"nonzero"},s("path",{d:"M2.58859116,2.7156945 L2.64644661,2.64644661 C2.82001296,2.47288026 3.08943736,2.45359511 3.2843055,2.58859116 L3.35355339,2.64644661 L8,7.293 L12.6464466,2.64644661 C12.8417088,2.45118446 13.1582912,2.45118446 13.3535534,2.64644661 C1 box-sizing: border-box; transition: color .3s var(--n-bezier); margin: var(--n-margin); font-size: var(--n-font-size); line-height: var(--n-line-height); color: var(--n-text-color);`,[O("&:first-child","margin-top: 0;"),O("&:last-child","margin-bottom: 0;")]),Tt=Object.assign(Object.assign({},le.props),{depth:[String,Number]}),Bt=K({name:"P",props:Tt,setup(e){const{mergedClsPrefixRef:t,inlineThemeDisabled:n}=Te(e),o=le("Typography","-p",kt,at,e,t),d=D(()=>{const{depth:c}=e,g=c||"1",{common:{cubicBezierEaseInOut:a},self:{pFontSize:u,pLineHeight:l,pMargin:p,pTextColor:R,[`pTextColor${g}Depth`]:j}}=o.value;return{"--n-bezier":a,"--n-font-size":u,"--n-line-height":l,"--n-margin":p,"--n-text-color":c===void 0?R:j}}),r=n?Be("p",D(()=>`${e.depth||""}`),d,e):void 0;return{mergedClsPrefix:t,cssVars:n?void 0:d,themeClass:r==null?void 0:r.themeClass,onRender:r==null?void 0:r.onRender}},render(){var e;return(e=this.onRender)===null||e===void 0||e.call(this),s("p",{class:[`${this.mergedClsPrefix}-p`,this.themeClass],style:this.cssVars},this.$slots)}}),ee=st("n-upload"),Le="__UPLOAD_DRAGGER__",Fe=K({name:"UploadDragger",[Le]:!0,setup(e,{slots:t}){const n=re(ee,null);return n||ae("upload-dragger","`n-upload-dragger` must be placed inside `n-upload`."),()=>{const{mergedClsPrefixRef:{value:o},mergedDisabledRef:{value:d},maxReachedRef:{value:r}}=n;return s("div",{class:[`${o}-upload-dragger`,(d||r)&&`${o}-upload-dragger--disabled`]},t)}}});var fe=function(e,t,n,o){function d(r){return r instanceof n?r:new n(function(c){c(r)})}return new(n||(n=Promise))(function(r,c){function g(l){try{u(o.next(l))}catch(p){c(p)}}function a(l){try{u(o.throw(l))}catch(p){c(p)}}function u(l){l.done?r(l.value):d(l.value).then(g,a)}u((o=o.apply(e,t||[])).next())})};function Ue(e){return e.includes("image/")}function ye(e=""){const t=e.split("/"),o=t[t.length-1].split(/#|\?/)[0];return(/\.[^./\\]*$/.exec(o)||[""])[0]}const be=/(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico)$/i,Pe=e=>{if(e.type)return Ue(e.type);const t=ye(e.name||"");if(be.test(t))return!0;const n=e.thumbnailUrl||e.url||"",o=ye(n);return!!(/^data:image\//.test(n)||be.test(o))};function Lt(e){return fe(this,void 0,void 0,function*(){return yield new Promise(t=>{if(!e.type||!Ue(e.type)){t("");return}t(window.URL.createObjectURL(e))})})}const Ft=dt&&window.FileReader&&window.File;function Ut(e){return e.isDirectory}function Pt(e){return e.isFile}function Dt(e,t){return fe(this,void 0,void 0,function*(){const n=[];function o(d){return fe(this,void 0,void 0,function*(){for(const r of d)if(r){if(t&&Ut(r)){const c=r.createReader();try{const g=yield new Promise((a,u)=>{c.readEntries(a,u)});yield o(g)}catch{}}else if(Pt(r))try{const c=yield new Promise((g,a)=>{r.file(g,a)});n.push({file:c,entry:r,source:"dnd"})}catch{}}})}return yield o(e),n})}function oe(e){const{id:t,name:n,percentage:o,status:d,url:r,file:c,thumbnailUrl:g,type:a,fullPath:u,batchId:l}=e;return{id:t,name:n,percentage:o??null,status:d,url:r??null,file:c??null,thumbnailUrl:g??null,type:a??null,fullPath:u??null,batchId:l??null}}function jt(e,t,n){return e=e.toLowerCase(),t=t.toLocaleLowerCase(),n=n.toLocaleLowerCase(),n.split(",").map(d=>d.trim()).filter(Boolean).some(d=>{if(d.startsWith(".")){if(e.endsWith(d))return!0}else if(d.includes("/")){const[r,c]=t.split("/"),[g,a]=d.split("/");if((g==="*"||r&&g&&g===r)&&(a==="*"||c&&a&&a===c))return!0}else return!0;return!1})}const De=K({name:"UploadTrigger",props:{abstract:Boolean},setup(e,{slots:t}){const n=re(ee,null);n||ae("upload-trigger","`n-upload-trigger` must be placed inside `n-upload`.");const{mergedClsPrefixRef:o,mergedDisabledRef:d,maxReachedRef:r,listTypeRef:c,dragOverRef:g,openOpenFileDialog:a,draggerInsideRef:u,handleFileAddition:l,mergedDirectoryDndRef:p,triggerClassRef:R,triggerStyleRef:j}=n,E=D(()=>c.value==="image-card");function M(){d.value||r.value||a()}function v(w){w.preventDefault(),g.value=!0}function h(w){w.preventDefault(),g.value=!0}function C(w){w.preventDefault(),g.value=!1}function P(w){var i;if(w.preventDefault(),!u.value||d.value||r.value){g.value=!1;return}const f=(i=w.dataTransfer)===null||i===void 0?void 0:i.items;f!=null&&f.length?Dt(Array.from(f).map(y=>y.webkitGetAsEntry()),p.value).then(y=>{l(y)}).finally(()=>{g.value=!1}):g.value=!1}re
display: block; `)]),H("drag-over",[b("upload-dragger",` border: var(--n-dragger-border-hover); `)])]),b("upload-dragger",` cursor: pointer; box-sizing: border-box; width: 100%; text-align: center; border-radius: var(--n-border-radius); padding: 24px; opacity: 1; transition: opacity .3s var(--n-bezier), border-color .3s var(--n-bezier), background-color .3s var(--n-bezier); background-color: var(--n-dragger-color); border: var(--n-dragger-border); `,[O("&:hover",` border: var(--n-dragger-border-hover); `),H("disabled",` cursor: not-allowed; `)]),b("upload-trigger",` display: inline-block; box-sizing: border-box; opacity: 1; transition: opacity .3s var(--n-bezier); `,[O("+",[b("upload-file-list","margin-top: 8px;")]),H("disabled",` opacity: var(--n-item-disabled-opacity); cursor: not-allowed; `),H("image-card",` width: 96px; height: 96px; `,[b("base-icon",` font-size: 24px; `),b("upload-dragger",` padding: 0; height: 100%; width: 100%; display: flex; align-items: center; justify-content: center; `)])]),b("upload-file-list",` line-height: var(--n-line-height); opacity: 1; transition: opacity .3s var(--n-bezier); `,[O("a, img","outline: none;"),H("disabled",` opacity: var(--n-item-disabled-opacity); cursor: not-allowed; `,[b("upload-file","cursor: not-allowed;")]),H("grid",` display: grid; grid-template-columns: repeat(auto-fill, 96px); grid-gap: 8px; margin-top: 0; `),b("upload-file",` display: block; box-sizing: border-box; cursor: default; padding: 0px 12px 0 6px; transition: background-color .3s var(--n-bezier); border-radius: var(--n-border-radius); `,[ge(),b("progress",[ge({foldPadding:!0})]),O("&:hover",` background-color: var(--n-item-color-hover); `,[b("upload-file-info",[G("action",` opacity: 1; `)])]),H("image-type",` border-radius: var(--n-border-radius); text-decoration: underline; text-decoration-color: #0000; `,[b("upload-file-info",` padding-top: 0px; padding-bottom: 0px; width: 100%; height: 100%; display: flex; justify-content: space-between; align-items: center; padding: 6px 0; `,[b("progress",` padding: 2px 0; margin-bottom: 0; `),G("name",` padding: 0 8px; `),G("thumbnail",` width: 32px; height: 32px; font-size: 28px; display: flex; justify-content: center; align-items: center; `,[O("img",` width: 100%; `)])])]),H("text-type",[b("progress",` box-sizing: border-box; padding-bottom: 6px; margin-bottom: 6px; `)]),H("image-card-type",` position: relative; width: 96px; height: 96px; border: var(--n-item-border-image-card); border-radius: var(--n-border-radius); padding: 0; display: flex; align-items: center; justify-content: center; transition: border-color .3s var(--n-bezier), background-color .3s var(--n-bezier); border-radius: var(--n-border-radius); overflow: hidden; `,[b("progress",` position: absolute; left: 8px; bottom: 8px; right: 8px; width: unset; `),b("upload-file-info",` padding: 0; width: 100%; height: 100%; `,[G("thumbnail",` width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 36px; `,[O("img",` width: 100%; `)])]),O("&::before",` position: absolute; z-index: 1; left: 0; right: 0; top: 0; bottom: 0; border-radius: inherit; opacity: 0; transition: opacity .2s var(--n-bezier); content: ""; `),O("&:hover",[O("&::before","opacity: 1;"),b("upload-file-info",[G("thumbnail","opacity: .12;")])])]),H("error-status",[O("&:hover",` background-color: var(--n-item-color-hover-error); `),b("upload-file-info",[G("name","color: var(--n-item-text-color-error);"),G("thumbnail","color: var(--n-item-text-color-error);")]),H("image-card-type",` border: var(--n-item-border-image-card-error); `)]),H("with-url",` cursor: pointer; `,[b("upload-file-info",[G("name",` color: var(--n-item-text-color-success); text-decoration-color: var(--n-item-text-color-success); `,[O("a",` text-decoration: underline; `)])])]),b("upload-file-info",` position: relative; padding-top: 6px; padding-bottom: 6px; display: flex; flex-wrap: nowrap; `,[G("thumbnail",` font-size: 18px; opacity: 1; transition: opacity .2s var(--n-bezier); color: var(--n-item-icon-color); `,[b("base-icon",` margin-right: 2px; vertical-align: middle; transition: color .3s var(--n-bezier); `)]),G("action",` padding-top: inherit; padding-bottom: inherit; position: absolute; right: 0; top: 0; bottom: 0; width: 80px; display: flex; align-items: center; transition: opacity .2s var(--n-bezier); justify-content: flex-end; opacity: 0; `,[b("button",[O("&:not(:last-child)",{marginRight:"4px"}),b("base-icon",[O("svg",[gt()])])]),H("image-type",` position: relative; max-width: 80px; width: auto; `),H("image-card-type",` z-index: 2; position: absolute; width: 100%; height: 100%; left: 0; right: 0; bottom: 0; top: 0; display: flex; justify-content: center; align-items: center; `)]),G("name",` color: var(--n-item-text-color); flex: 1; display: flex; justify-content: center; text-overflow: ellipsis; overflow: hidden; flex-direction: column; text-decoration-color: #0000; font-size: var(--n-font-size); transition: color .3s var(--n-bezier), text-decoration-color .3s var(--n-bezier); `,[O("a",` color: inherit; text-decoration: underline; `)])])])]),b("upload-file-input",` display: none; width: 0; height: 0; opacity: 0; `)]);var we=function(e,t,n,o){function d(r){return r instanceof n?r:new n(function(c){c(r)})}return new(n||(n=Promise))(function(r,c){function g(l){try{u(o.next(l))}catch(p){c(p)}}function a(l){try{u(o.throw(l))}catch(p){c(p)}}function u(l){l.done?r(l.value):d(l.value).then(g,a)}u((o=o.apply(e,t||[])).next())})};function Nt(e,t,n){const{doChange:o,xhrMap:d}=e;let r=0;function c(a){var u;let l=Object.assign({},t,{status:"error",percentage:r});d.delete(t.id),l=oe(((u=e.onError)===null||u===void 0?void 0:u.call(e,{file:l,event:a}))||l),o(l,a)}function g(a){var u;if(e.isErrorState){if(e.isErrorState(n)){c(a);return}}else if(n.status<200||n.status>=300){c(a);return}let l=Object.assign({},t,{status:"finished",percentage:r});d.delete(t.id),l=oe(((u=e.onFinish)===null||u===void 0?void 0:u.call(e,{file:l,event:a}))||l),o(l,a)}return{handleXHRLoad:g,handleXHRError:c,handleXHRAbort(a){const u=Object.assign({},t,{status:"removed",file:null,percentage:r});d.delete(t.id),o(u,a)},handleXHRProgress(a){const u=Object.assign({},t,{status:"uploading"});if(a.lengthComputable){const l=Math.ceil(a.loaded/a.total*100);u.percentage=l,r=l}o(u,a)}}}function At(e){const{inst:t,file:n,data:o,headers:d,withCredentials:r,action:c,customRequest:g}=e,{doChange:a}=e.inst;let u=0;g({file:n,data:o,headers:d,withCredentials:r,action:c,onProgress(l){const p=Object.assign({},n,{status:"uploading"}),R=l.percent;p.percentage=R,u=R,a(p)},onFinish(){var l;let p=Object.assign({},n,{status:"finished",percentage:u});p=oe(((l=t.onFinish)===null||l===void 0?void 0:l.call(t,{file:p}))||p),a(p)},onError(){var l;let p=Object.assign({},n,{status:"error",percentage:u});p=oe(((l=t.onError)===null||l===void 0?void 0:l.call(t,{file:p}))||p),a(p)}})}function Ht(e,t,n){const o=Nt(e,t,n);n.onabort=o.handleXHRAbort,n.onerror=o.handleXHRError,n.onload=o.handleXHRLoad,n.upload&&(n.upload.onprogress=o.handleXHRProgress)}function je(e,t){return typeof e=="function"?e({file:t}):e||{}}function Vt(e,t,n){const o=je(t,n);o&&Object.keys(o).forEach(d=>{e.setRequestHeader(d,o[d])})}function qt(e,t,n){const o=je(t,n);o&&Object.keys(o).forEach(d=>{e.append(d,o[d])})}function Xt(e,t,n,{method:o,action:d,withCredentials:r,responseType:c,headers:g,data:a}){const u=new XMLHttpRequest;u.responseType=c,e.xhrMap.set(n.id,u),u.withCredentials=r;const l=new FormData;if(qt(l,a,n),n.file!==null&&l.append(t,n.file),Ht(e,n,u),d!==void 0){u.open(o.toUpperCase(),d),Vt(u,g,n),u.send(l);const p=Object.assign({},n,{status:"uploading"});e.doChange(p)}}const Gt=Object.assign(Object.assign({},le.props),{name:{type:String,default:"file"},accept:String,action:String,customRequest:Function,directory:Boolean,directoryDnd:{type:Boolean,default:void 0},method:{type:String,default:"POST"},multiple:Boolean,showFileList:{type:Boolean,default:!0},data:[Object,Function],headers:[Object,Function],withCredentials:Boolean,responseType:{type:String,default:""},disabled:{type:Boolean,default:void 0},onChange:Function,onRemove:Function,onFinish:Function,onError:Function,onBeforeUpload:Function,isErrorState:Function,onDownload:Function,defaultUpload:{type:Boolean,default:!0},fileList:Array,"onUpdate:fileList":[Function,Array],onUpdateFileList:[Function,Array],fileListClass:String,fileListStyle:[String,Object],defaultFileList:{type:Array,default:()=>[]},showCancelButton:{type:Boolean,default:!0},showRemoveButton:{type:Boolean,default:!0},showDownloadButton:Boolean,showRetryButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},listType:{type:String,default:"text"},onPreview:Function,shouldUseThumbnailUrl:{type:Function,default:e=>Ft?Pe(e):!1},createThumbnailUrl:Function,abstract:Boolean,max:Number,showTrigger:{type:Boolean,default:!0},imageGroupProps:Object,inputProps:Object,triggerClass:String,triggerStyle:[String,Object],renderIcon:Function}),Kt=K({name:"Upload",props:Gt,setup(e){e.abstract&&e.listType==="image-card"&&ae("upload","when the list-type is image-card, abstract is not supported.");const{mergedClsPrefixRef:t,inlineThemeDisabled:n}=Te(e),o=le("Upload","-upload",Mt,vt,e,t),d=yt(e),r=$(e.defaultFi
|