@nextcloud/files 3.0.0-beta.22 → 3.0.0-beta.24
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/README.md +1 -1
- package/dist/humanfilesize.d.ts +10 -1
- package/dist/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +465 -443
- package/dist/index.mjs.map +1 -1
- package/dist/newFileMenu.d.ts +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/vendor.LICENSE.txt +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# @nextcloud/files
|
|
2
|
-
[](https://www.npmjs.com/package/@nextcloud/files) [](https://app.codecov.io/gh/nextcloud-libraries/nextcloud-files) [](https://nextcloud.github.io/nextcloud-files/)
|
|
2
|
+
[](https://www.npmjs.com/package/@nextcloud/files) [](https://app.codecov.io/gh/nextcloud-libraries/nextcloud-files) [](https://nextcloud-libraries.github.io/nextcloud-files/)
|
|
3
3
|
|
|
4
4
|
Nextcloud Files helpers for Nextcloud apps and libraries
|
|
5
5
|
|
package/dist/humanfilesize.d.ts
CHANGED
|
@@ -25,6 +25,15 @@
|
|
|
25
25
|
*
|
|
26
26
|
* @param size in bytes
|
|
27
27
|
* @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead
|
|
28
|
-
* @param binaryPrefixes True if binary prefixes like `KiB` should be used
|
|
28
|
+
* @param binaryPrefixes True if size base 2 (and binary prefixes like `KiB`) should be used
|
|
29
29
|
*/
|
|
30
30
|
export declare function formatFileSize(size: number | string, skipSmallSizes?: boolean, binaryPrefixes?: boolean): string;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a file size in bytes from a humanly readable string
|
|
33
|
+
* Note: `b` and `B` are both parsed as bytes and not as bit or byte.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} value file size in human-readable format
|
|
36
|
+
* @param {boolean} forceBinary for backwards compatibility this allows values to be base 2 (so 2KB means 2048 bytes instead of 2000 bytes)
|
|
37
|
+
* @return {number} or null if string could not be parsed
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseFileSize(value: string, forceBinary?: boolean): number | null;
|
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
<d:propfind ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@nextcloud/auth"),H=require("@nextcloud/logger"),gt=require("@nextcloud/l10n"),b=require("path"),mt=require("@nextcloud/router"),K=require("webdav"),wt=require("webdav/dist/node/request.js"),vt=t=>t===null?H.getLoggerBuilder().setApp("files").build():H.getLoggerBuilder().setApp("files").setUid(t.uid).build(),w=vt(A.getCurrentUser());class yt{_entries=[];registerEntry(e){this.validateEntry(e),this._entries.push(e)}unregisterEntry(e){const i=typeof e=="string"?this.getEntryIndex(e):this.getEntryIndex(e.id);if(i===-1){w.warn("Entry not found, nothing removed",{entry:e,entries:this.getEntries()});return}this._entries.splice(i,1)}getEntries(e){return e?this._entries.filter(i=>typeof i.if=="function"?i.if(e):!0):this._entries}getEntryIndex(e){return this._entries.findIndex(i=>i.id===e)}validateEntry(e){if(!e.id||!e.displayName||!(e.iconSvgInline||e.iconClass||e.handler))throw new Error("Invalid entry");if(typeof e.id!="string"||typeof e.displayName!="string")throw new Error("Invalid id or displayName property");if(e.iconClass&&typeof e.iconClass!="string"||e.iconSvgInline&&typeof e.iconSvgInline!="string")throw new Error("Invalid icon provided");if(e.if!==void 0&&typeof e.if!="function")throw new Error("Invalid if property");if(e.templateName&&typeof e.templateName!="string")throw new Error("Invalid templateName property");if(e.handler&&typeof e.handler!="function")throw new Error("Invalid handler property");if(!e.templateName&&!e.handler)throw new Error("At least a templateName or a handler must be provided");if(this.getEntryIndex(e.id)!==-1)throw new Error("Duplicate entry")}}const k=function(){return typeof window._nc_newfilemenu>"u"&&(window._nc_newfilemenu=new yt,w.debug("NewFileMenu initialized")),window._nc_newfilemenu},D=["B","KB","MB","GB","TB","PB"],S=["B","KiB","MiB","GiB","TiB","PiB"];function bt(t,e=!1,i=!0){typeof t=="string"&&(t=Number(t));let r=t>0?Math.floor(Math.log(t)/Math.log(i?1024:1e3)):0;r=Math.min((i?S.length:D.length)-1,r);const n=i?S[r]:D[r];let s=(t/Math.pow(i?1024:1e3,r)).toFixed(1);return e===!0&&r===0?(s!=="0.0"?"< 1 ":"0 ")+(i?S[1]:D[1]):(r<2?s=parseFloat(s).toFixed(0):s=parseFloat(s).toLocaleString(gt.getCanonicalLocale()),s+" "+n)}function xt(t,e=!1){try{t=`${t}`.toLocaleLowerCase().replaceAll(/\s+/g,"").replaceAll(",",".")}catch{return null}const i=t.match(/^([0-9]*(\.[0-9]*)?)([kmgtp]?)(i?)b?$/);if(i===null||i[1]==="."||i[1]==="")return null;const r={"":0,k:1,m:2,g:3,t:4,p:5,e:6},n=`${i[1]}`,s=i[4]==="i"||e?1024:1e3;return Math.round(Number.parseFloat(n)*s**r[i[3]])}var L=(t=>(t.DEFAULT="default",t.HIDDEN="hidden",t))(L||{});class Et{_action;constructor(e){this.validateAction(e),this._action=e}get id(){return this._action.id}get displayName(){return this._action.displayName}get title(){return this._action.title}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get default(){return this._action.default}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(e){if(!e.id||typeof e.id!="string")throw new Error("Invalid id");if(!e.displayName||typeof e.displayName!="function")throw new Error("Invalid displayName function");if("title"in e&&typeof e.title!="function")throw new Error("Invalid title function");if(!e.iconSvgInline||typeof e.iconSvgInline!="function")throw new Error("Invalid iconSvgInline function");if(!e.exec||typeof e.exec!="function")throw new Error("Invalid exec function");if("enabled"in e&&typeof e.enabled!="function")throw new Error("Invalid enabled function");if("execBatch"in e&&typeof e.execBatch!="function")throw new Error("Invalid execBatch function");if("order"in e&&typeof e.order!="number")throw new Error("Invalid order");if(e.default&&!Object.values(L).includes(e.default))throw new Error("Invalid default");if("inline"in e&&typeof e.inline!="function")throw new Error("Invalid inline function");if("renderInline"in e&&typeof e.renderInline!="function")throw new Error("Invalid renderInline function")}}const Nt=function(t){if(typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],w.debug("FileActions initialized")),window._nc_fileactions.find(e=>e.id===t.id)){w.error(`FileAction ${t.id} already registered`,{action:t});return}window._nc_fileactions.push(t)},_t=function(){return typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],w.debug("FileActions initialized")),window._nc_fileactions};class At{_header;constructor(e){this.validateHeader(e),this._header=e}get id(){return this._header.id}get order(){return this._header.order}get enabled(){return this._header.enabled}get render(){return this._header.render}get updated(){return this._header.updated}validateHeader(e){if(!e.id||!e.render||!e.updated)throw new Error("Invalid header: id, render and updated are required");if(typeof e.id!="string")throw new Error("Invalid id property");if(e.enabled!==void 0&&typeof e.enabled!="function")throw new Error("Invalid enabled property");if(e.render&&typeof e.render!="function")throw new Error("Invalid render property");if(e.updated&&typeof e.updated!="function")throw new Error("Invalid updated property")}}const Tt=function(t){if(typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],w.debug("FileListHeaders initialized")),window._nc_filelistheader.find(e=>e.id===t.id)){w.error(`Header ${t.id} already registered`,{header:t});return}window._nc_filelistheader.push(t)},It=function(){return typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],w.debug("FileListHeaders initialized")),window._nc_filelistheader};var m=(t=>(t[t.NONE=0]="NONE",t[t.CREATE=4]="CREATE",t[t.READ=1]="READ",t[t.UPDATE=2]="UPDATE",t[t.DELETE=8]="DELETE",t[t.SHARE=16]="SHARE",t[t.ALL=31]="ALL",t))(m||{});const R=["d:getcontentlength","d:getcontenttype","d:getetag","d:getlastmodified","d:quota-available-bytes","d:resourcetype","nc:has-preview","nc:is-encrypted","nc:mount-type","nc:share-attributes","oc:comments-unread","oc:favorite","oc:fileid","oc:owner-display-name","oc:owner-id","oc:permissions","oc:share-types","oc:size","ocs:share-permissions"],j={d:"DAV:",nc:"http://nextcloud.org/ns",oc:"http://owncloud.org/ns",ocs:"http://open-collaboration-services.org/ns"},Ot=function(t,e={nc:"http://nextcloud.org/ns"}){typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...R],window._nc_dav_namespaces={...j});const i={...window._nc_dav_namespaces,...e};if(window._nc_dav_properties.find(n=>n===t))return w.error(`${t} already registered`,{prop:t}),!1;if(t.startsWith("<")||t.split(":").length!==2)return w.error(`${t} is not valid. See example: 'oc:fileid'`,{prop:t}),!1;const r=t.split(":")[0];return i[r]?(window._nc_dav_properties.push(t),window._nc_dav_namespaces=i,!0):(w.error(`${t} namespace unknown`,{prop:t,namespaces:i}),!1)},I=function(){return typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...R]),window._nc_dav_properties.map(t=>`<${t} />`).join(" ")},O=function(){return typeof window._nc_dav_namespaces>"u"&&(window._nc_dav_namespaces={...j}),Object.keys(window._nc_dav_namespaces).map(t=>`xmlns:${t}="${window._nc_dav_namespaces?.[t]}"`).join(" ")},Pt=function(){return`<?xml version="1.0"?>
|
|
2
|
+
<d:propfind ${O()}>
|
|
3
3
|
<d:prop>
|
|
4
|
-
${
|
|
4
|
+
${I()}
|
|
5
5
|
</d:prop>
|
|
6
|
-
</d:propfind>`},
|
|
7
|
-
<oc:filter-files ${
|
|
6
|
+
</d:propfind>`},it=function(){return`<?xml version="1.0"?>
|
|
7
|
+
<oc:filter-files ${O()}>
|
|
8
8
|
<d:prop>
|
|
9
|
-
${
|
|
9
|
+
${I()}
|
|
10
10
|
</d:prop>
|
|
11
11
|
<oc:filter-rules>
|
|
12
12
|
<oc:favorite>1</oc:favorite>
|
|
13
13
|
</oc:filter-rules>
|
|
14
|
-
</oc:filter-files>`},
|
|
15
|
-
<d:searchrequest ${
|
|
14
|
+
</oc:filter-files>`},Ct=function(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
|
+
<d:searchrequest ${O()}
|
|
16
16
|
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
|
|
17
17
|
<d:basicsearch>
|
|
18
18
|
<d:select>
|
|
19
19
|
<d:prop>
|
|
20
|
-
${
|
|
20
|
+
${I()}
|
|
21
21
|
</d:prop>
|
|
22
22
|
</d:select>
|
|
23
23
|
<d:from>
|
|
24
24
|
<d:scope>
|
|
25
|
-
<d:href>/files/${
|
|
25
|
+
<d:href>/files/${A.getCurrentUser()?.uid}/</d:href>
|
|
26
26
|
<d:depth>infinity</d:depth>
|
|
27
27
|
</d:scope>
|
|
28
28
|
</d:from>
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
<ns:firstresult>0</ns:firstresult>
|
|
66
66
|
</d:limit>
|
|
67
67
|
</d:basicsearch>
|
|
68
|
-
</d:searchrequest>`},
|
|
69
|
-
`&&t[
|
|
70
|
-
`||t==="\r"}function
|
|
71
|
-
`);const e=new
|
|
72
|
-
`;function
|
|
68
|
+
</d:searchrequest>`},nt=function(t=""){let e=m.NONE;return t&&((t.includes("C")||t.includes("K"))&&(e|=m.CREATE),t.includes("G")&&(e|=m.READ),(t.includes("W")||t.includes("N")||t.includes("V"))&&(e|=m.UPDATE),t.includes("D")&&(e|=m.DELETE),t.includes("R")&&(e|=m.SHARE)),e};var P=(t=>(t.Folder="folder",t.File="file",t))(P||{});const rt=function(t,e){return t.match(e)!==null},W=(t,e)=>{if(t.id&&typeof t.id!="number")throw new Error("Invalid id type of value");if(!t.source)throw new Error("Missing mandatory source");try{new URL(t.source)}catch{throw new Error("Invalid source format, source must be a valid URL")}if(!t.source.startsWith("http"))throw new Error("Invalid source format, only http(s) is supported");if(t.mtime&&!(t.mtime instanceof Date))throw new Error("Invalid mtime type");if(t.crtime&&!(t.crtime instanceof Date))throw new Error("Invalid crtime type");if(!t.mime||typeof t.mime!="string"||!t.mime.match(/^[-\w.]+\/[-+\w.]+$/gi))throw new Error("Missing or invalid mandatory mime");if("size"in t&&typeof t.size!="number"&&t.size!==void 0)throw new Error("Invalid size type");if("permissions"in t&&t.permissions!==void 0&&!(typeof t.permissions=="number"&&t.permissions>=m.NONE&&t.permissions<=m.ALL))throw new Error("Invalid permissions");if(t.owner&&t.owner!==null&&typeof t.owner!="string")throw new Error("Invalid owner type");if(t.attributes&&typeof t.attributes!="object")throw new Error("Invalid attributes type");if(t.root&&typeof t.root!="string")throw new Error("Invalid root type");if(t.root&&!t.root.startsWith("/"))throw new Error("Root must start with a leading slash");if(t.root&&!t.source.includes(t.root))throw new Error("Root must be part of the source");if(t.root&&rt(t.source,e)){const i=t.source.match(e)[0];if(!t.source.includes(b.join(i,t.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}if(t.status&&!Object.values(M).includes(t.status))throw new Error("Status must be a valid NodeStatus")};var M=(t=>(t.NEW="new",t.FAILED="failed",t.LOADING="loading",t.LOCKED="locked",t))(M||{});class B{_data;_attributes;_knownDavService=/(remote|public)\.php\/(web)?dav/i;constructor(e,i){W(e,i||this._knownDavService),this._data=e;const r={set:(n,s,a)=>(this.updateMtime(),Reflect.set(n,s,a)),deleteProperty:(n,s)=>(this.updateMtime(),Reflect.deleteProperty(n,s))};this._attributes=new Proxy(e.attributes||{},r),delete this._data.attributes,i&&(this._knownDavService=i)}get source(){return this._data.source.replace(/\/$/i,"")}get basename(){return b.basename(this.source)}get extension(){return b.extname(this.source)}get dirname(){if(this.root){const i=this.source.indexOf(this.root);return b.dirname(this.source.slice(i+this.root.length)||"/")}const e=new URL(this.source);return b.dirname(e.pathname)}get mime(){return this._data.mime}get mtime(){return this._data.mtime}get crtime(){return this._data.crtime}get size(){return this._data.size}get attributes(){return this._attributes}get permissions(){return this.owner===null&&!this.isDavRessource?m.READ:this._data.permissions!==void 0?this._data.permissions:m.NONE}get owner(){return this.isDavRessource?this._data.owner:null}get isDavRessource(){return rt(this.source,this._knownDavService)}get root(){return this._data.root?this._data.root.replace(/^(.+)\/$/,"$1"):this.isDavRessource&&b.dirname(this.source).split(this._knownDavService).pop()||null}get path(){if(this.root){const e=this.source.indexOf(this.root);return this.source.slice(e+this.root.length)||"/"}return(this.dirname+"/"+this.basename).replace(/\/\//g,"/")}get fileid(){return this._data?.id||this.attributes?.fileid}get status(){return this._data?.status}set status(e){this._data.status=e}move(e){W({...this._data,source:e},this._knownDavService),this._data.source=e,this.updateMtime()}rename(e){if(e.includes("/"))throw new Error("Invalid basename");this.move(b.dirname(this.source)+"/"+e)}updateMtime(){this._data.mtime&&(this._data.mtime=new Date)}}class st extends B{get type(){return P.File}}class ot extends B{constructor(e){super({...e,mime:"httpd/unix-directory"})}get type(){return P.Folder}get extension(){return null}get mime(){return"httpd/unix-directory"}}const q=`/files/${A.getCurrentUser()?.uid}`,U=mt.generateRemoteUrl("dav"),Dt=function(t=U){const e=K.createClient(t,{headers:{requesttoken:A.getRequestToken()||""}});return K.getPatcher().patch("request",i=>(i.headers?.method&&(i.method=i.headers.method,delete i.headers.method),wt.request(i))),e},St=async(t,e="/",i=q)=>(await t.getDirectoryContents(`${i}${e}`,{details:!0,data:it(),headers:{method:"REPORT"},includeSelf:!0})).data.filter(r=>r.filename!==e).map(r=>at(r,i)),at=function(t,e=q,i=U){const r=t.props,n=nt(r?.permissions),s=A.getCurrentUser()?.uid,a={id:r?.fileid||0,source:`${i}${t.filename}`,mtime:new Date(Date.parse(t.lastmod)),mime:t.mime,size:r?.size||Number.parseInt(r.getcontentlength||"0"),permissions:n,owner:s,root:e,attributes:{...t,...r,hasPreview:r?.["has-preview"]}};return delete a.attributes?.props,t.type==="file"?new st(a):new ot(a)};class lt{_views=[];_currentView=null;register(e){if(this._views.find(i=>i.id===e.id))throw new Error(`View id ${e.id} is already registered`);this._views.push(e)}remove(e){const i=this._views.findIndex(r=>r.id===e);i!==-1&&this._views.splice(i,1)}get views(){return this._views}setActive(e){this._currentView=e}get active(){return this._currentView}}const Ft=function(){return typeof window._nc_navigation>"u"&&(window._nc_navigation=new lt,w.debug("Navigation service initialized")),window._nc_navigation};class dt{_column;constructor(e){$t(e),this._column=e}get id(){return this._column.id}get title(){return this._column.title}get render(){return this._column.render}get sort(){return this._column.sort}get summary(){return this._column.summary}}const $t=function(t){if(!t.id||typeof t.id!="string")throw new Error("A column id is required");if(!t.title||typeof t.title!="string")throw new Error("A column title is required");if(!t.render||typeof t.render!="function")throw new Error("A render function is required");if(t.sort&&typeof t.sort!="function")throw new Error("Column sortFunction must be a function");if(t.summary&&typeof t.summary!="function")throw new Error("Column summary must be a function");return!0};var z={},C={};(function(t){const e=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",i=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",r="["+e+"]["+i+"]*",n=new RegExp("^"+r+"$"),s=function(o,l){const d=[];let u=l.exec(o);for(;u;){const c=[];c.startIndex=l.lastIndex-u[0].length;const p=u.length;for(let h=0;h<p;h++)c.push(u[h]);d.push(c),u=l.exec(o)}return d},a=function(o){const l=n.exec(o);return!(l===null||typeof l>"u")};t.isExist=function(o){return typeof o<"u"},t.isEmptyObject=function(o){return Object.keys(o).length===0},t.merge=function(o,l,d){if(l){const u=Object.keys(l),c=u.length;for(let p=0;p<c;p++)d==="strict"?o[u[p]]=[l[u[p]]]:o[u[p]]=l[u[p]]}},t.getValue=function(o){return t.isExist(o)?o:""},t.isName=a,t.getAllMatches=s,t.nameRegexp=r})(C);const G=C,Vt={allowBooleanAttributes:!1,unpairedTags:[]};z.validate=function(t,e){e=Object.assign({},Vt,e);const i=[];let r=!1,n=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=Z(t,s),s.err)return s}else if(t[s]==="<"){let a=s;if(s++,t[s]==="!"){s=J(t,s);continue}else{let o=!1;t[s]==="/"&&(o=!0,s++);let l="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
|
|
69
|
+
`&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!Ut(l)){let c;return l.trim().length===0?c="Invalid space after '<'.":c="Tag '"+l+"' is an invalid name.",f("InvalidTag",c,g(t,s))}const d=Rt(t,s);if(d===!1)return f("InvalidAttr","Attributes for '"+l+"' have open quote.",g(t,s));let u=d.value;if(s=d.index,u[u.length-1]==="/"){const c=s-u.length;u=u.substring(0,u.length-1);const p=Q(u,e);if(p===!0)r=!0;else return f(p.err.code,p.err.msg,g(t,c+p.err.line))}else if(o)if(d.tagClosed){if(u.trim().length>0)return f("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",g(t,a));{const c=i.pop();if(l!==c.tagName){let p=g(t,c.tagStartPos);return f("InvalidTag","Expected closing tag '"+c.tagName+"' (opened in line "+p.line+", col "+p.col+") instead of closing tag '"+l+"'.",g(t,a))}i.length==0&&(n=!0)}}else return f("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",g(t,s));else{const c=Q(u,e);if(c!==!0)return f(c.err.code,c.err.msg,g(t,s-u.length+c.err.line));if(n===!0)return f("InvalidXml","Multiple possible root nodes found.",g(t,s));e.unpairedTags.indexOf(l)!==-1||i.push({tagName:l,tagStartPos:a}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=J(t,s);continue}else if(t[s+1]==="?"){if(s=Z(t,++s),s.err)return s}else break;else if(t[s]==="&"){const c=Bt(t,s);if(c==-1)return f("InvalidChar","char '&' is not expected.",g(t,s));s=c}else if(n===!0&&!Y(t[s]))return f("InvalidXml","Extra text at the end",g(t,s));t[s]==="<"&&s--}}else{if(Y(t[s]))continue;return f("InvalidChar","char '"+t[s]+"' is not expected.",g(t,s))}if(r){if(i.length==1)return f("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",g(t,i[0].tagStartPos));if(i.length>0)return f("InvalidXml","Invalid '"+JSON.stringify(i.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return f("InvalidXml","Start tag expected.",1);return!0};function Y(t){return t===" "||t===" "||t===`
|
|
70
|
+
`||t==="\r"}function Z(t,e){const i=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(i,e-i);if(e>5&&r==="xml")return f("InvalidXml","XML declaration allowed only at the start of the document.",g(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function J(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let i=1;for(e+=8;e<t.length;e++)if(t[e]==="<")i++;else if(t[e]===">"&&(i--,i===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}const kt='"',Lt="'";function Rt(t,e){let i="",r="",n=!1;for(;e<t.length;e++){if(t[e]===kt||t[e]===Lt)r===""?r=t[e]:r!==t[e]||(r="");else if(t[e]===">"&&r===""){n=!0;break}i+=t[e]}return r!==""?!1:{value:i,index:e,tagClosed:n}}const jt=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Q(t,e){const i=G.getAllMatches(t,jt),r={};for(let n=0;n<i.length;n++){if(i[n][1].length===0)return f("InvalidAttr","Attribute '"+i[n][2]+"' has no space in starting.",N(i[n]));if(i[n][3]!==void 0&&i[n][4]===void 0)return f("InvalidAttr","Attribute '"+i[n][2]+"' is without value.",N(i[n]));if(i[n][3]===void 0&&!e.allowBooleanAttributes)return f("InvalidAttr","boolean attribute '"+i[n][2]+"' is not allowed.",N(i[n]));const s=i[n][2];if(!qt(s))return f("InvalidAttr","Attribute '"+s+"' is an invalid name.",N(i[n]));if(!r.hasOwnProperty(s))r[s]=1;else return f("InvalidAttr","Attribute '"+s+"' is repeated.",N(i[n]))}return!0}function Mt(t,e){let i=/\d/;for(t[e]==="x"&&(e++,i=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(i))break}return-1}function Bt(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Mt(t,e);let i=0;for(;e<t.length;e++,i++)if(!(t[e].match(/\w/)&&i<20)){if(t[e]===";")break;return-1}return e}function f(t,e,i){return{err:{code:t,msg:e,line:i.line||i,col:i.col}}}function qt(t){return G.isName(t)}function Ut(t){return G.isName(t)}function g(t,e){const i=t.substring(0,e).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function N(t){return t.startIndex+t[1].length}var F={};const ut={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,i){return t}},zt=function(t){return Object.assign({},ut,t)};F.buildOptions=zt,F.defaultOptions=ut;class Gt{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,i){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:i})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}var Xt=Gt;const Ht=C;function Kt(t,e){const i={};if(t[e+3]==="O"&&t[e+4]==="C"&&t[e+5]==="T"&&t[e+6]==="Y"&&t[e+7]==="P"&&t[e+8]==="E"){e=e+9;let r=1,n=!1,s=!1,a="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(n&&Zt(t,e))e+=7,[entityName,val,e]=Wt(t,e+1),val.indexOf("&")===-1&&(i[ee(entityName)]={regx:RegExp(`&${entityName};`,"g"),val});else if(n&&Jt(t,e))e+=8;else if(n&&Qt(t,e))e+=8;else if(n&&te(t,e))e+=9;else if(Yt)s=!0;else throw new Error("Invalid DOCTYPE");r++,a=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,r--):r--,r===0)break}else t[e]==="["?n=!0:a+=t[e];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:i,i:e}}function Wt(t,e){let i="";for(;e<t.length&&t[e]!=="'"&&t[e]!=='"';e++)i+=t[e];if(i=i.trim(),i.indexOf(" ")!==-1)throw new Error("External entites are not supported");const r=t[e++];let n="";for(;e<t.length&&t[e]!==r;e++)n+=t[e];return[i,n,e]}function Yt(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function Zt(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="N"&&t[e+4]==="T"&&t[e+5]==="I"&&t[e+6]==="T"&&t[e+7]==="Y"}function Jt(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="L"&&t[e+4]==="E"&&t[e+5]==="M"&&t[e+6]==="E"&&t[e+7]==="N"&&t[e+8]==="T"}function Qt(t,e){return t[e+1]==="!"&&t[e+2]==="A"&&t[e+3]==="T"&&t[e+4]==="T"&&t[e+5]==="L"&&t[e+6]==="I"&&t[e+7]==="S"&&t[e+8]==="T"}function te(t,e){return t[e+1]==="!"&&t[e+2]==="N"&&t[e+3]==="O"&&t[e+4]==="T"&&t[e+5]==="A"&&t[e+6]==="T"&&t[e+7]==="I"&&t[e+8]==="O"&&t[e+9]==="N"}function ee(t){if(Ht.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var ie=Kt;const ne=/^[-+]?0x[a-fA-F0-9]+$/,re=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const se={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function oe(t,e={}){if(e=Object.assign({},se,e),!t||typeof t!="string")return t;let i=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(i))return t;if(e.hex&&ne.test(i))return Number.parseInt(i,16);{const r=re.exec(i);if(r){const n=r[1],s=r[2];let a=ae(r[3]);const o=r[4]||r[6];if(!e.leadingZeros&&s.length>0&&n&&i[2]!=="."||!e.leadingZeros&&s.length>0&&!n&&i[1]!==".")return t;{const l=Number(i),d=""+l;return d.search(/[eE]/)!==-1||o?e.eNotation?l:t:i.indexOf(".")!==-1?d==="0"&&a===""||d===a||n&&d==="-"+a?l:t:s?a===d||n+a===d?l:t:i===d||i===n+d?l:t}}else return t}}function ae(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substr(0,t.length-1))),t}var le=oe;const X=C,_=Xt,de=ie,ue=le;"<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g,X.nameRegexp);let ce=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"}},this.addExternalEntities=he,this.parseXml=we,this.parseTextData=pe,this.resolveNameSpace=fe,this.buildAttributesMap=me,this.isItStopNode=xe,this.replaceEntitiesValue=ye,this.readStopNodeData=Ne,this.saveTextToParentTag=be,this.addChild=ve}};function he(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const r=e[i];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function pe(t,e,i,r,n,s,a){if(t!==void 0&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t));const o=this.options.tagValueProcessor(e,t,i,n,s);return o==null?t:typeof o!=typeof t||o!==t?o:this.options.trimValues?V(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?V(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function fe(t){if(this.options.removeNSPrefix){const e=t.split(":"),i=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=i+e[1])}return t}const ge=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function me(t,e,i){if(!this.options.ignoreAttributes&&typeof t=="string"){const r=X.getAllMatches(t,ge),n=r.length,s={};for(let a=0;a<n;a++){const o=this.resolveNameSpace(r[a][1]);let l=r[a][4],d=this.options.attributeNamePrefix+o;if(o.length)if(this.options.transformAttributeName&&(d=this.options.transformAttributeName(d)),d==="__proto__"&&(d="#__proto__"),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);const u=this.options.attributeValueProcessor(o,l,e);u==null?s[d]=l:typeof u!=typeof l||u!==l?s[d]=u:s[d]=V(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[d]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=s,a}return s}}const we=function(t){t=t.replace(/\r\n?/g,`
|
|
71
|
+
`);const e=new _("!xml");let i=e,r="",n="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const a=x(t,">",s,"Closing Tag is not closed.");let o=t.substring(s+2,a).trim();if(this.options.removeNSPrefix){const u=o.indexOf(":");u!==-1&&(o=o.substr(u+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),i&&(r=this.saveTextToParentTag(r,i,n));const l=n.substring(n.lastIndexOf(".")+1);if(o&&this.options.unpairedTags.indexOf(o)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);let d=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(d=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):d=n.lastIndexOf("."),n=n.substring(0,d),i=this.tagsNodeStack.pop(),r="",s=a}else if(t[s+1]==="?"){let a=$(t,s,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,i,n),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){const o=new _(a.tagName);o.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(o[":@"]=this.buildAttributesMap(a.tagExp,n,a.tagName)),this.addChild(i,o,n)}s=a.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const a=x(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const o=t.substring(s+4,a-2);r=this.saveTextToParentTag(r,i,n),i.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}s=a}else if(t.substr(s+1,2)==="!D"){const a=de(t,s);this.docTypeEntities=a.entities,s=a.i}else if(t.substr(s+1,2)==="!["){const a=x(t,"]]>",s,"CDATA is not closed.")-2,o=t.substring(s+9,a);if(r=this.saveTextToParentTag(r,i,n),this.options.cdataPropName)i.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]);else{let l=this.parseTextData(o,i.tagname,n,!0,!1,!0);l==null&&(l=""),i.add(this.options.textNodeName,l)}s=a+2}else{let a=$(t,s,this.options.removeNSPrefix),o=a.tagName;const l=a.rawTagName;let d=a.tagExp,u=a.attrExpPresent,c=a.closeIndex;this.options.transformTagName&&(o=this.options.transformTagName(o)),i&&r&&i.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,i,n,!1));const p=i;if(p&&this.options.unpairedTags.indexOf(p.tagname)!==-1&&(i=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),o!==e.tagname&&(n+=n?"."+o:o),this.isItStopNode(this.options.stopNodes,n,o)){let h="";if(d.length>0&&d.lastIndexOf("/")===d.length-1)s=a.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)s=a.closeIndex;else{const E=this.readStopNodeData(t,l,c+1);if(!E)throw new Error(`Unexpected end of ${l}`);s=E.i,h=E.tagContent}const v=new _(o);o!==d&&u&&(v[":@"]=this.buildAttributesMap(d,n,o)),h&&(h=this.parseTextData(h,o,n,!0,u,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),v.add(this.options.textNodeName,h),this.addChild(i,v,n)}else{if(d.length>0&&d.lastIndexOf("/")===d.length-1){o[o.length-1]==="/"?(o=o.substr(0,o.length-1),n=n.substr(0,n.length-1),d=o):d=d.substr(0,d.length-1),this.options.transformTagName&&(o=this.options.transformTagName(o));const h=new _(o);o!==d&&u&&(h[":@"]=this.buildAttributesMap(d,n,o)),this.addChild(i,h,n),n=n.substr(0,n.lastIndexOf("."))}else{const h=new _(o);this.tagsNodeStack.push(i),o!==d&&u&&(h[":@"]=this.buildAttributesMap(d,n,o)),this.addChild(i,h,n),i=h}r="",s=c}}else r+=t[s];return e.child};function ve(t,e,i){const r=this.options.updateTag(e.tagname,i,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const ye=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const i=this.docTypeEntities[e];t=t.replace(i.regx,i.val)}for(let e in this.lastEntities){const i=this.lastEntities[e];t=t.replace(i.regex,i.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const i=this.htmlEntities[e];t=t.replace(i.regex,i.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function be(t,e,i,r){return t&&(r===void 0&&(r=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,i,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function xe(t,e,i){const r="*."+i;for(const n in t){const s=t[n];if(r===s||e===s)return!0}return!1}function Ee(t,e,i=">"){let r,n="";for(let s=e;s<t.length;s++){let a=t[s];if(r)a===r&&(r="");else if(a==='"'||a==="'")r=a;else if(a===i[0])if(i[1]){if(t[s+1]===i[1])return{data:n,index:s}}else return{data:n,index:s};else a===" "&&(a=" ");n+=a}}function x(t,e,i,r){const n=t.indexOf(e,i);if(n===-1)throw new Error(r);return n+e.length-1}function $(t,e,i,r=">"){const n=Ee(t,e+1,r);if(!n)return;let s=n.data;const a=n.index,o=s.search(/\s/);let l=s,d=!0;o!==-1&&(l=s.substr(0,o).replace(/\s\s*$/,""),s=s.substr(o+1));const u=l;if(i){const c=l.indexOf(":");c!==-1&&(l=l.substr(c+1),d=l!==n.data.substr(c+1))}return{tagName:l,tagExp:s,closeIndex:a,attrExpPresent:d,rawTagName:u}}function Ne(t,e,i){const r=i;let n=1;for(;i<t.length;i++)if(t[i]==="<")if(t[i+1]==="/"){const s=x(t,">",i,`${e} is not closed`);if(t.substring(i+2,s).trim()===e&&(n--,n===0))return{tagContent:t.substring(r,i),i:s};i=s}else if(t[i+1]==="?")i=x(t,"?>",i+1,"StopNode is not closed.");else if(t.substr(i+1,3)==="!--")i=x(t,"-->",i+3,"StopNode is not closed.");else if(t.substr(i+1,2)==="![")i=x(t,"]]>",i,"StopNode is not closed.")-2;else{const s=$(t,i,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&n++,i=s.closeIndex)}}function V(t,e,i){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:ue(t,i)}else return X.isExist(t)?t:""}var _e=ce,ct={};function Ae(t,e){return ht(t,e)}function ht(t,e,i){let r;const n={};for(let s=0;s<t.length;s++){const a=t[s],o=Te(a);let l="";if(i===void 0?l=o:l=i+"."+o,o===e.textNodeName)r===void 0?r=a[o]:r+=""+a[o];else{if(o===void 0)continue;if(a[o]){let d=ht(a[o],e,l);const u=Oe(d,e);a[":@"]?Ie(d,a[":@"],l,e):Object.keys(d).length===1&&d[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?d=d[e.textNodeName]:Object.keys(d).length===0&&(e.alwaysCreateTextNode?d[e.textNodeName]="":d=""),n[o]!==void 0&&n.hasOwnProperty(o)?(Array.isArray(n[o])||(n[o]=[n[o]]),n[o].push(d)):e.isArray(o,l,u)?n[o]=[d]:n[o]=d}}}return typeof r=="string"?r.length>0&&(n[e.textNodeName]=r):r!==void 0&&(n[e.textNodeName]=r),n}function Te(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const r=e[i];if(r!==":@")return r}}function Ie(t,e,i,r){if(e){const n=Object.keys(e),s=n.length;for(let a=0;a<s;a++){const o=n[a];r.isArray(o,i+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}}function Oe(t,e){const{textNodeName:i}=e,r=Object.keys(t).length;return!!(r===0||r===1&&(t[i]||typeof t[i]=="boolean"||t[i]===0))}ct.prettify=Ae;const{buildOptions:Pe}=F,Ce=_e,{prettify:De}=ct,Se=z;let Fe=class{constructor(t){this.externalEntities={},this.options=Pe(t)}parse(t,e){if(typeof t!="string")if(t.toString)t=t.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(e){e===!0&&(e={});const n=Se.validate(t,e);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const i=new Ce(this.options);i.addExternalEntities(this.externalEntities);const r=i.parseXml(t);return this.options.preserveOrder||r===void 0?r:De(r,this.options)}addEntity(t,e){if(e.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(e==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}};var $e=Fe;const Ve=`
|
|
72
|
+
`;function ke(t,e){let i="";return e.format&&e.indentBy.length>0&&(i=Ve),pt(t,e,"",i)}function pt(t,e,i,r){let n="",s=!1;for(let a=0;a<t.length;a++){const o=t[a],l=Le(o);if(l===void 0)continue;let d="";if(i.length===0?d=l:d=`${i}.${l}`,l===e.textNodeName){let v=o[l];Re(d,e)||(v=e.tagValueProcessor(l,v),v=ft(v,e)),s&&(n+=r),n+=v,s=!1;continue}else if(l===e.cdataPropName){s&&(n+=r),n+=`<![CDATA[${o[l][0][e.textNodeName]}]]>`,s=!1;continue}else if(l===e.commentPropName){n+=r+`<!--${o[l][0][e.textNodeName]}-->`,s=!0;continue}else if(l[0]==="?"){const v=tt(o[":@"],e),E=l==="?xml"?"":r;let T=o[l][0][e.textNodeName];T=T.length!==0?" "+T:"",n+=E+`<${l}${T}${v}?>`,s=!0;continue}let u=r;u!==""&&(u+=e.indentBy);const c=tt(o[":@"],e),p=r+`<${l}${c}`,h=pt(o[l],e,d,u);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?n+=p+">":n+=p+"/>":(!h||h.length===0)&&e.suppressEmptyNode?n+=p+"/>":h&&h.endsWith(">")?n+=p+`>${h}${r}</${l}>`:(n+=p+">",h&&r!==""&&(h.includes("/>")||h.includes("</"))?n+=r+e.indentBy+h+r:n+=h,n+=`</${l}>`),s=!0}return n}function Le(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const r=e[i];if(t.hasOwnProperty(r)&&r!==":@")return r}}function tt(t,e){let i="";if(t&&!e.ignoreAttributes)for(let r in t){if(!t.hasOwnProperty(r))continue;let n=e.attributeValueProcessor(r,t[r]);n=ft(n,e),n===!0&&e.suppressBooleanAttributes?i+=` ${r.substr(e.attributeNamePrefix.length)}`:i+=` ${r.substr(e.attributeNamePrefix.length)}="${n}"`}return i}function Re(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let i=t.substr(t.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===t||e.stopNodes[r]==="*."+i)return!0;return!1}function ft(t,e){if(t&&t.length>0&&e.processEntities)for(let i=0;i<e.entities.length;i++){const r=e.entities[i];t=t.replace(r.regex,r.val)}return t}var je=ke;const Me=je,Be={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function y(t){this.options=Object.assign({},Be,t),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=ze),this.processTextOrObjNode=qe,this.options.format?(this.indentate=Ue,this.tagEndChar=`>
|
|
73
73
|
`,this.newLine=`
|
|
74
|
-
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}y.prototype.build=function(t){return this.options.preserveOrder?
|
|
74
|
+
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}y.prototype.build=function(t){return this.options.preserveOrder?Me(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0).val)},y.prototype.j2x=function(t,e){let i="",r="";for(let n in t)if(t.hasOwnProperty(n))if(typeof t[n]>"u")this.isAttribute(n)&&(r+="");else if(t[n]===null)this.isAttribute(n)?r+="":n[0]==="?"?r+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+n+"/"+this.tagEndChar;else if(t[n]instanceof Date)r+=this.buildTextValNode(t[n],n,"",e);else if(typeof t[n]!="object"){const s=this.isAttribute(n);if(s)i+=this.buildAttrPairStr(s,""+t[n]);else if(n===this.options.textNodeName){let a=this.options.tagValueProcessor(n,""+t[n]);r+=this.replaceEntitiesValue(a)}else r+=this.buildTextValNode(t[n],n,"",e)}else if(Array.isArray(t[n])){const s=t[n].length;let a="";for(let o=0;o<s;o++){const l=t[n][o];typeof l>"u"||(l===null?n[0]==="?"?r+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+n+"/"+this.tagEndChar:typeof l=="object"?this.options.oneListGroup?a+=this.j2x(l,e+1).val:a+=this.processTextOrObjNode(l,n,e):a+=this.buildTextValNode(l,n,"",e))}this.options.oneListGroup&&(a=this.buildObjectNode(a,n,"",e)),r+=a}else if(this.options.attributesGroupName&&n===this.options.attributesGroupName){const s=Object.keys(t[n]),a=s.length;for(let o=0;o<a;o++)i+=this.buildAttrPairStr(s[o],""+t[n][s[o]])}else r+=this.processTextOrObjNode(t[n],n,e);return{attrStr:i,val:r}},y.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+t:" "+t+'="'+e+'"'};function qe(t,e,i){const r=this.j2x(t,i+1);return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,r.attrStr,i):this.buildObjectNode(r.val,e,r.attrStr,i)}y.prototype.buildObjectNode=function(t,e,i,r){if(t==="")return e[0]==="?"?this.indentate(r)+"<"+e+i+"?"+this.tagEndChar:this.indentate(r)+"<"+e+i+this.closeTag(e)+this.tagEndChar;{let n="</"+e+this.tagEndChar,s="";return e[0]==="?"&&(s="?",n=""),(i||i==="")&&t.indexOf("<")===-1?this.indentate(r)+"<"+e+i+s+">"+t+n:this.options.commentPropName!==!1&&e===this.options.commentPropName&&s.length===0?this.indentate(r)+`<!--${t}-->`+this.newLine:this.indentate(r)+"<"+e+i+s+this.tagEndChar+t+this.indentate(r)+n}},y.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e},y.prototype.buildTextValNode=function(t,e,i,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(r)+"<"+e+i+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(e,t);return n=this.replaceEntitiesValue(n),n===""?this.indentate(r)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+i+">"+n+"</"+e+this.tagEndChar}},y.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t};function Ue(t){return this.options.indentBy.repeat(t)}function ze(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var Ge=y;const Xe=z,He=$e,Ke=Ge;var et={XMLParser:He,XMLValidator:Xe,XMLBuilder:Ke};function We(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);if(t=t.trim(),t.length===0||et.XMLValidator.validate(t)!==!0)return!1;let e;const i=new et.XMLParser;try{e=i.parse(t)}catch{return!1}return!(!e||!("svg"in e))}class Ye{_view;constructor(e){Ze(e),this._view=e}get id(){return this._view.id}get name(){return this._view.name}get caption(){return this._view.caption}get emptyTitle(){return this._view.emptyTitle}get emptyCaption(){return this._view.emptyCaption}get getContents(){return this._view.getContents}get icon(){return this._view.icon}set icon(e){this._view.icon=e}get order(){return this._view.order}set order(e){this._view.order=e}get params(){return this._view.params}set params(e){this._view.params=e}get columns(){return this._view.columns}get emptyView(){return this._view.emptyView}get parent(){return this._view.parent}get sticky(){return this._view.sticky}get expanded(){return this._view.expanded}set expanded(e){this._view.expanded=e}get defaultSortKey(){return this._view.defaultSortKey}}const Ze=function(t){if(!t.id||typeof t.id!="string")throw new Error("View id is required and must be a string");if(!t.name||typeof t.name!="string")throw new Error("View name is required and must be a string");if(t.columns&&t.columns.length>0&&(!t.caption||typeof t.caption!="string"))throw new Error("View caption is required for top-level views and must be a string");if(!t.getContents||typeof t.getContents!="function")throw new Error("View getContents is required and must be a function");if(!t.icon||typeof t.icon!="string"||!We(t.icon))throw new Error("View icon is required and must be a valid svg string");if(!("order"in t)||typeof t.order!="number")throw new Error("View order is required and must be a number");if(t.columns&&t.columns.forEach(e=>{if(!(e instanceof dt))throw new Error("View columns must be an array of Column. Invalid column found")}),t.emptyView&&typeof t.emptyView!="function")throw new Error("View emptyView must be a function");if(t.parent&&typeof t.parent!="string")throw new Error("View parent must be a string");if("sticky"in t&&typeof t.sticky!="boolean")throw new Error("View sticky must be a boolean");if("expanded"in t&&typeof t.expanded!="boolean")throw new Error("View expanded must be a boolean");if(t.defaultSortKey&&typeof t.defaultSortKey!="string")throw new Error("View defaultSortKey must be a string");return!0},Je=function(t){return k().registerEntry(t)},Qe=function(t){return k().unregisterEntry(t)},ti=function(t){return k().getEntries(t)};exports.Column=dt,exports.DefaultType=L,exports.File=st,exports.FileAction=Et,exports.FileType=P,exports.Folder=ot,exports.Header=At,exports.Navigation=lt,exports.Node=B,exports.NodeStatus=M,exports.Permission=m,exports.View=Ye,exports.addNewFileMenuEntry=Je,exports.davGetClient=Dt,exports.davGetDefaultPropfind=Pt,exports.davGetFavoritesReport=it,exports.davGetRecentSearch=Ct,exports.davParsePermissions=nt,exports.davRemoteURL=U,exports.davResultToNode=at,exports.davRootPath=q,exports.defaultDavNamespaces=j,exports.defaultDavProperties=R,exports.formatFileSize=bt,exports.getDavNameSpaces=O,exports.getDavProperties=I,exports.getFavoriteNodes=St,exports.getFileActions=_t,exports.getFileListHeaders=It,exports.getNavigation=Ft,exports.getNewFileMenuEntries=ti,exports.parseFileSize=xt,exports.registerDavProperty=Ot,exports.registerFileAction=Nt,exports.registerFileListHeaders=Tt,exports.removeNewFileMenuEntry=Qe;
|