3 lines
5.7 KiB
JavaScript
3 lines
5.7 KiB
JavaScript
import{l as D,E as N,G as q,H as A,I as R}from"./TrayArrowDown-sRwZP_WA.chunk.mjs";import{a as W,u as z}from"./index-BGFNwqHi.chunk.mjs";import{l as b,N as H,F as I,a as M,P as p}from"./index-wzXhnBCQ.chunk.mjs";function C(){return D("files_sharing","isPublic",null)??document.querySelector('input#isPublic[type="hidden"][name="isPublic"][value="1"]')!==null}function O(){return D("files_sharing","sharingToken",null)??document.querySelector('input#sharingToken[type="hidden"]')?.value??null}function u(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function T(e,n,t){F(e,n),n.set(e,t)}function F(e,n){if(n.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function s(e,n){var t=$(e,n,"get");return G(e,t)}function G(e,n){return n.get?n.get.call(e):n.value}function L(e,n,t){var i=$(e,n,"set");return V(e,i,t),t}function $(e,n,t){if(!n.has(e))throw new TypeError("attempted to "+t+" private field on non-instance");return n.get(e)}function V(e,n,t){if(n.set)n.set.call(e,t);else{if(!n.writable)throw new TypeError("attempted to set read only private field");n.value=t}}var X=typeof Symbol<"u"?Symbol.toStringTag:"@@toStringTag",o=new WeakMap,f=new WeakMap;class v{constructor(n){var{executor:t=()=>{},internals:i=E(),promise:r=new Promise((a,c)=>t(a,c,d=>{i.onCancelList.push(d)}))}=n;T(this,o,{writable:!0,value:void 0}),T(this,f,{writable:!0,value:void 0}),u(this,X,"CancelablePromise"),this.cancel=this.cancel.bind(this),L(this,o,i),L(this,f,r||new Promise((a,c)=>t(a,c,d=>{i.onCancelList.push(d)})))}then(n,t){return w(s(this,f).then(m(n,s(this,o)),m(t,s(this,o))),s(this,o))}catch(n){return w(s(this,f).catch(m(n,s(this,o))),s(this,o))}finally(n,t){return t&&s(this,o).onCancelList.push(n),w(s(this,f).finally(m(()=>{if(n)return t&&(s(this,o).onCancelList=s(this,o).onCancelList.filter(i=>i!==n)),n()},s(this,o))),s(this,o))}cancel(){s(this,o).isCanceled=!0;var n=s(this,o).onCancelList;s(this,o).onCancelList=[];for(var t of n)if(typeof t=="function")try{t()}catch(i){console.error(i)}}isCanceled(){return s(this,o).isCanceled===!0}}class l extends v{constructor(n){super({executor:n})}}u(l,"all",function(e){return h(e,Promise.all(e))}),u(l,"allSettled",function(e){return h(e,Promise.allSettled(e))}),u(l,"any",function(e){return h(e,Promise.any(e))}),u(l,"race",function(e){return h(e,Promise.race(e))}),u(l,"resolve",function(e){return S(Promise.resolve(e))}),u(l,"reject",function(e){return S(Promise.reject(e))}),u(l,"isCancelable",P);function S(e){return w(e,E())}function P(e){return e instanceof l||e instanceof v}function m(e,n){if(e)return t=>{if(!n.isCanceled){var i=e(t);return P(i)&&n.onCancelList.push(i.cancel),i}return t}}function w(e,n){return new v({internals:n,promise:e})}function h(e,n){var t=E();return t.onCancelList.push(()=>{for(var i of e)P(i)&&i.cancel()}),new v({internals:t,promise:n})}function E(){return{isCanceled:!1,onCancelList:[]}}const K=function(e=""){let n=p.NONE;return e&&((e.includes("C")||e.includes("K"))&&(n|=p.CREATE),e.includes("G")&&(n|=p.READ),(e.includes("W")||e.includes("N")||e.includes("V"))&&(n|=p.UPDATE),e.includes("D")&&(n|=p.DELETE),e.includes("R")&&(n|=p.SHARE)),n},x=["d:getcontentlength","d:getcontenttype","d:getetag","d:getlastmodified","d:creationdate","d:displayname","d:quota-available-bytes","d:resourcetype","nc:has-preview","nc:is-encrypted","nc:mount-type","oc:comments-unread","oc:favorite","oc:fileid","oc:owner-display-name","oc:owner-id","oc:permissions","oc:size"],j={d:"DAV:",nc:"http://nextcloud.org/ns",oc:"http://owncloud.org/ns",ocs:"http://open-collaboration-services.org/ns"},ee=function(e,n={nc:"http://nextcloud.org/ns"}){typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...x],window._nc_dav_namespaces={...j});const t={...window._nc_dav_namespaces,...n};if(window._nc_dav_properties.find(r=>r===e))return b.warn(`${e} already registered`,{prop:e}),!1;if(e.startsWith("<")||e.split(":").length!==2)return b.error(`${e} is not valid. See example: 'oc:fileid'`,{prop:e}),!1;const i=e.split(":")[0];return t[i]?(window._nc_dav_properties.push(e),window._nc_dav_namespaces=t,!0):(b.error(`${e} namespace unknown`,{prop:e,namespaces:t}),!1)},ne=function(){return typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...x]),window._nc_dav_properties.map(e=>`<${e} />`).join(" ")},te=function(){return typeof window._nc_dav_namespaces>"u"&&(window._nc_dav_namespaces={...j}),Object.keys(window._nc_dav_namespaces).map(e=>`xmlns:${e}="${window._nc_dav_namespaces?.[e]}"`).join(" ")};function U(){return C()?`/files/${O()}`:`/files/${N()?.uid}`}const B=U();function J(){const e=q("dav");return C()?e.replace("remote.php","public.php"):e}const k=J(),ie=function(e=k,n={}){const t=W(e,{headers:n});function i(r){t.setHeaders({...n,"X-Requested-With":"XMLHttpRequest",requesttoken:r??""})}return R(i),i(A()),z().patch("fetch",(r,a)=>{const c=a.headers;return c?.method&&(a.method=c.method,delete c.method),fetch(r,a)}),t},re=function(e,n=B,t=k){let i=N()?.uid;if(C())i=i??"anonymous";else if(!i)throw new Error("No user id found");const r=e.props,a=K(r?.permissions),c=String(r?.["owner-id"]||i),d=r.fileid||0,_=new Date(Date.parse(e.lastmod)),y=new Date(Date.parse(r.creationdate)),g={id:d,source:`${t}${e.filename}`,mtime:!isNaN(_.getTime())&&_.getTime()!==0?_:void 0,crtime:!isNaN(y.getTime())&&y.getTime()!==0?y:void 0,mime:e.mime||"application/octet-stream",displayname:r.displayname!==void 0?String(r.displayname):void 0,size:r?.size||Number.parseInt(r.getcontentlength||"0"),status:d<0?H.FAILED:void 0,permissions:a,owner:c,root:n,attributes:{...e,...r,hasPreview:r?.["has-preview"]}};return delete g.attributes?.props,e.type==="file"?new I(g):new M(g)};export{te as a,ne as b,re as c,k as d,ie as g,ee as r};
|
|
//# sourceMappingURL=dav-CRTiYd1u.chunk.mjs.map
|