import{j as i,h as x,o as k,S as b,r as m}from"./vendor-ClLR6ncd.js";import{n as O,h as S,i as w,f as U}from"./index-OtVJl4GC.js";import{A as R,a as j,b as v}from"./AccordionDetails-Bqc4B-Ut.js";import{m as L,x as M,d as A}from"./lodash-ZyeDnt0e.js";import{u as C}from"./useDefaultMutationOptions-CUrzq21a.js";import{u as I}from"./usePrevious-BP64N3hu.js";function G({children:e}){const{value:t}=O();return i.jsxs(R,{sx:{width:1},children:[i.jsx(j,{style:t?{height:"38px",minHeight:"38px"}:void 0,expandIcon:i.jsx(k,{}),children:i.jsx(x,{children:"Import Options"})}),i.jsx(v,{children:i.jsx(b,{children:e})})]})}const E=e=>e.reduce((t,n)=>n.size+t,0),y=e=>e===""?null:e,F={context:{key:"graph",value:y},continueOnError:{key:"errorHandling",value:e=>e==="ignore"},useAgload:{key:"fileLoadingMode",value:e=>e==="agload"},bulkLoad:{key:"bulkMode"},bulkLoaders:{key:"agThreads",value:y},commit:{key:"commit",value:y},attributes:{key:"attributes"},externalReferences:{key:"externalReferences"},externalReferencesTimeout:{key:"externalReferencesTimeout"},baseURI:{key:"baseUri"},jsonLdStoreSource:{key:"storeSource"},type:{key:"format"}},P=()=>{},T=e=>{const t=new URL(e,window.origin);return t.searchParams.append("parse-only","true"),t.searchParams.set("continueOnError","false"),t.toString()};function _({files:e,httpQueryParams:t,setUploadProgress:n=P}){const s=m.useRef(new AbortController),c=C({onMutate:()=>{a(0)},onSettled:()=>{a(void 0)}}),o=E(e),a=r=>n(r!==void 0?Math.ceil(r*100/o):r),l=S(async(r,f)=>({total:(await Promise.all(e.map(p=>{const{url:d,...h}=t(p,f);return w({url:r!=null&&r.parseOnly?T(d):d,...h,signal:s.current.signal,headers:{"Content-Type":null},onUploadProgress:g=>{a(g.loaded)}})}))).reduce((p,d)=>p+d,0),parseOnly:!!(r!=null&&r.parseOnly)}),c),u=I(e);return m.useEffect(()=>{u!==e&&l.reset()},[e,u,l]),{abortUpload:m.useCallback(()=>{s.current.abort(),s.current=new AbortController},[s]),mutation:l}}function Q(e,t){for(const[n,{key:s,value:c=L}]of M(F)){const o=c(A(t,[s,"value"],null));o!==null&&e.searchParams.append(n,o)}}function K({fileNameGetter:e,fileNameOption:t,includeInData:n=!0,files:s,options:c,setUploadProgress:o}){return _({files:s,httpQueryParams:(a,l)=>{const u=new URL(U(l,"statements"),window.origin);return t&&u.searchParams.append(t,e(a)),Q(u,c),{url:u.toString(),method:"post",data:n?a:void 0}},setUploadProgress:o})}export{G as L,_ as a,E as f,Q as s,K as u};
