47 lines
82 KiB
JavaScript
47 lines
82 KiB
JavaScript
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
if you want to view the source, please visit the github repository of this plugin
|
|
*/
|
|
|
|
var Ue=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var nn=Object.prototype.hasOwnProperty;var sn=(t,e)=>{for(var r in e)Ue(t,r,{get:e[r],enumerable:!0})},an=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of on(e))!nn.call(t,n)&&n!==r&&Ue(t,n,{get:()=>e[n],enumerable:!(o=rn(e,n))||o.enumerable});return t};var ln=t=>an(Ue({},"__esModule",{value:!0}),t);var ls={};sn(ls,{default:()=>Ve});module.exports=ln(ls);var T=require("obsidian");function Ht(t,e){let r=Object.keys(e).map(o=>dn(t,o,e[o]));return r.length===1?r[0]:function(){r.forEach(o=>o())}}function dn(t,e,r){let o=t[e],n=t.hasOwnProperty(e),i=n?o:function(){return Object.getPrototypeOf(t)[e].apply(this,arguments)},a=r(i);return o&&Object.setPrototypeOf(a,o),Object.setPrototypeOf(s,a),t[e]=s,l;function s(...d){return a===i&&t[e]===s&&l(),a.apply(this,d)}function l(){t[e]===s&&(n?t[e]=i:delete t[e]),a!==i&&(a=i,Object.setPrototypeOf(s,o||Function))}}var ge=require("obsidian");var Ut="getData",Vt="obsidian-icon-folder",Yt=t=>{var r,o,n,i;let e=(o=(r=t==null?void 0:t.plugins)==null?void 0:r.plugins)==null?void 0:o[Vt];if(e&&e._loaded&&((i=(n=t==null?void 0:t.plugins)==null?void 0:n.enabledPlugins)!=null&&i.has(Vt))){let a=e;if(typeof(a==null?void 0:a[Ut])=="function")return a}},jt=(t,e)=>{var n;let r=e[Ut](),o=r==null?void 0:r[t.path];return typeof o=="string"?o:typeof(o==null?void 0:o.iconName)=="string"&&(n=o==null?void 0:o.iconName)!=null?n:void 0};var Ye=t=>t,J="sort-index-value";function L(t){return t!=null}function ue(t){return(t==null?void 0:t.length)>0?t[t.length-1]:void 0}function Y(t){let e=(t!=null?t:"").lastIndexOf("/");return e>=0?t.substring(e+1):t}function Q(t){let e=(t!=null?t:"").lastIndexOf("/");return e>0?t.substring(0,e):""}function Zt(t){return typeof t=="string"&&t.endsWith(".md")?t.slice(0,-3):t}var xe=class{constructor(e,r){this.value=e;this.error=r;e&&(this.error=void 0)}setValue(e){return this.value=e,this.error=void 0,this}setError(e){return this.value=void 0,this.error=e,this}get v(){return this.value}get e(){return this.error}};var cn="{:",un=":}",mn="%parent-folder-name%",gn=cn+mn+un,je=function(t,e){return t&&e?t.replace(gn,e):t},Ze=function(t,e){var r;(r=t.groupsShadow)==null||r.forEach(o=>{e&&(o.exactText&&(o.exactText=je(o.exactText,e)),o.exactPrefix&&(o.exactPrefix=je(o.exactPrefix,e)),o.exactSuffix&&(o.exactSuffix=je(o.exactSuffix,e)))})};var N=new Intl.Collator(void 0,{usage:"sort",sensitivity:"base",numeric:!0}).compare,me=new Intl.Collator(void 0,{usage:"sort",sensitivity:"base",numeric:!1}).compare;var E=!0,z=!0,H=!1,O=0,Xt=(t,e)=>{switch(e){case 1:return t.metadataFieldValueSecondary;case 2:return t.metadataFieldValueForDerived;case 3:return t.metadataFieldValueForDerivedSecondary;case 0:default:return t.metadataFieldValue}},R=(t,e,r)=>{let o=e?me:N;return(n,i)=>{let[a,s]=[Xt(n,r),Xt(i,r)];return t&&([a,s]=[s,a]),a!==void 0&&s!==void 0?o(a,s):a!==void 0?t?1:-1:s!==void 0?t?-1:1:O}},qt=t=>(e,r)=>(t&&([e,r]=[r,e]),e.bookmarkedIdx&&r.bookmarkedIdx?e.bookmarkedIdx-r.bookmarkedIdx:e.bookmarkedIdx?t?1:-1:r.bookmarkedIdx?t?-1:1:O),Fe=t=>(e,r)=>(t&&([e,r]=[r,e]),e.ctime&&r.ctime?e.ctime-r.ctime:e.ctime?t?1:-1:r.ctime?t?-1:1:O),ke=t=>(e,r)=>(t&&([e,r]=[r,e]),e.mtime&&r.mtime?e.mtime-r.mtime:e.mtime?t?1:-1:r.mtime?t?-1:1:O),Kt=(t,e,r)=>t||(e.isFolder===r.isFolder?O:e.isFolder?1:-1);var ae={[1]:(t,e)=>N(t.sortString,e.sortString),[30]:(t,e)=>Kt(N(t.sortString,e.sortString),t,e),[31]:(t,e)=>Kt(N(t.sortString,e.sortString),t,e),[2]:(t,e)=>N(t.sortStringWithExt,e.sortStringWithExt),[3]:(t,e)=>me(t.sortString,e.sortString),[4]:(t,e)=>me(t.sortStringWithExt,e.sortStringWithExt),[5]:(t,e)=>N(e.sortString,t.sortString),[6]:(t,e)=>N(e.sortStringWithExt,t.sortStringWithExt),[7]:(t,e)=>me(e.sortString,t.sortString),[8]:(t,e)=>me(e.sortStringWithExt,t.sortStringWithExt),[9]:(t,e)=>t.isFolder&&e.isFolder?N(t.sortString,e.sortString):t.mtime-e.mtime,[10]:ke(),[11]:ke(),[12]:(t,e)=>t.isFolder&&e.isFolder?N(t.sortString,e.sortString):e.mtime-t.mtime,[13]:ke(!0),[14]:ke(!0),[15]:(t,e)=>t.isFolder&&e.isFolder?N(t.sortString,e.sortString):t.ctime-e.ctime,[16]:Fe(),[17]:Fe(),[18]:(t,e)=>t.isFolder&&e.isFolder?N(t.sortString,e.sortString):e.ctime-t.ctime,[19]:Fe(!0),[20]:Fe(!0),[21]:R(H,!E,0),[22]:R(H,E,0),[23]:R(z,!E,0),[24]:R(z,E,0),[26]:qt(H),[27]:qt(z),[28]:(t,e)=>t.isFolder===e.isFolder?O:t.isFolder?1:-1,[29]:(t,e)=>t.isFolder===e.isFolder?O:t.isFolder?-1:1,[32]:(t,e)=>t.sortString===e.sortString?O:t.sortString<e.sortString?-1:1,[33]:(t,e)=>t.sortString===e.sortString?O:e.sortString<t.sortString?-1:1,[25]:(t,e)=>N(t.sortString,e.sortString)},fn={[21]:R(H,!E,1),[22]:R(H,E,1),[23]:R(z,!E,1),[24]:R(z,E,1)},pn={[21]:R(H,!E,2),[22]:R(H,E,2),[23]:R(z,!E,2),[24]:R(z,E,2)},hn={[21]:R(H,!E,3),[22]:R(H,E,3),[23]:R(z,!E,3),[24]:R(z,E,3)},fe="alphabetical",or="alphabeticalReverse",Xe="byModifiedTime",nr="byModifiedTimeReverse",qe="byCreatedTime",ir="byCreatedTimeReverse",sr=fe,ar={[fe]:1,[or]:5,[Xe]:12,[nr]:9,[qe]:18,[ir]:15},Ce={[fe]:(t,e)=>N(t.basename,e.basename),[or]:(t,e)=>-Ce[fe](t,e),[Xe]:(t,e)=>e.stat.mtime-t.stat.mtime,[nr]:(t,e)=>-Ce[Xe](t,e),[qe]:(t,e)=>e.stat.ctime-t.stat.ctime,[ir]:(t,e)=>-Ce[qe](t,e)},yn=t=>{let e=ae[t];return(r,o)=>r.isFolder||o.isFolder?r.isFolder&&!o.isFolder?-1:o.isFolder&&!r.isFolder?1:ae[1](r,o):e(r,o)},Sn=t=>{let e=Ce[t]||ar[fe];return(r,o)=>{let n=r instanceof ge.TFolder,i=o instanceof ge.TFolder;return n||i?n&&!i?-1:i&&!n?1:N(r.name,o.name):e(r,o)}},ie=(t,e,r)=>{var o,n,i,a;if(t===25)return t=(o=ar[e!=null?e:"alphabetical"])!=null?o:1,yn(t);switch(r){case 1:return(n=fn[t])!=null?n:ae[t];case 2:return(i=pn[t])!=null?i:ae[t];case 3:return(a=hn[t])!=null?a:ae[t];case 0:default:return ae[t]}},lr=(t,e)=>(o,n)=>{if(o.groupIdx!=null&&n.groupIdx!=null)if(o.groupIdx===n.groupIdx){let i=t.groups[o.groupIdx],a=i!=null&&i.sorting?ie(i.sorting.order,e,0)(o,n):O;if(a!==O)return a;let s=i!=null&&i.secondarySorting?ie(i.secondarySorting.order,e,1)(o,n):O;if(s!==O)return s;let l=t.defaultSorting?ie(t.defaultSorting.order,e,2)(o,n):O;if(l!==O)return l;let d=t.defaultSecondarySorting?ie(t.defaultSecondarySorting.order,e,3)(o,n):O;return d!==O?d:ie(30,void 0,4)(o,n)}else return o.groupIdx-n.groupIdx;else return o.groupIdx!==void 0?-1:n.groupIdx!==void 0?1:ie(30,e)(o,n)},Je=t=>!!t.isRoot,Ie=t=>t===21||t===23||t===22||t===24,dr=0,Ke=0,se=(t,e)=>{let r=t.regex.exec(e);if(r){let o=t.normalizerFn,n=r[1];return n?[!0,o?o(n):n,r[0]]:[!0,void 0,r[0]]}return[!1,void 0,void 0]},Ae=(t,e,r,o)=>{let n;o&&(n=o==null?void 0:o[t]);let i=n!=null?n:r==null?void 0:r[t];return e?e(i):i},cr=function(t,e,r){var P,K,ce,Dt,vt,Mt,Lt,wt,Bt,h,Wt,Gt,$t,zt;let o,n=!1,i,a,s,l=Je(t),d=!l,m=t,c=l?t.name:m.basename,u=e.priorityOrder?e.priorityOrder.length:e.groups.length;for(let I=0;I<u&&!n;I++){i=null,o=e.priorityOrder?e.priorityOrder[I]:I;let y=e.groupsShadow?e.groupsShadow[o]:e.groups[o];if(y.foldersOnly&&d||y.filesOnly&&l)continue;let C=y.matchFilenameWithExt?t.name:c;switch(y.type){case 3:if(y.exactPrefix)C.startsWith(y.exactPrefix)&&(n=!0);else{let[A,S]=se(y.regexPrefix,C);n=A,i=S!=null?S:i}break;case 4:if(y.exactSuffix)C.endsWith(y.exactSuffix)&&(n=!0);else{let[A,S]=se(y.regexSuffix,C);n=A,i=S!=null?S:i}break;case 5:if(y.exactPrefix&&y.exactSuffix)C.length>=y.exactPrefix.length+y.exactSuffix.length&&C.startsWith(y.exactPrefix)&&C.endsWith(y.exactSuffix)&&(n=!0);else if(y.exactPrefix||y.exactSuffix){if(y.exactPrefix&&C.startsWith(y.exactPrefix)||y.exactSuffix&&C.endsWith(y.exactSuffix)){let[A,S,G]=se(y.exactPrefix?y.regexSuffix:y.regexPrefix,C);A&&G.length+((K=(P=y.exactPrefix)==null?void 0:P.length)!=null?K:0)+((Dt=(ce=y.exactSuffix)==null?void 0:ce.length)!=null?Dt:0)<=C.length&&(n=!0,i=S!=null?S:i)}}else{let[A,S,G]=se(y.regexPrefix,C),[$,U,be]=se(y.regexSuffix,C);A&&$&&G.length+be.length<=C.length&&(n=!0,(S||U)&&(i=(S||"")+(U||"")||i))}break;case 2:if(y.exactText)C===y.exactText&&(n=!0);else{let[A,S]=se(y.regexPrefix,C);A&&(n=!0,i=S!=null?S:i)}break;case 6:if(y.withMetadataFieldName&&r!=null&&r._mCache){let A=d?t.path:`${t.path}/${t.name}.md`,S=(vt=r._mCache.getCache(A))==null?void 0:vt.frontmatter,G=S==null?void 0:S.hasOwnProperty(y.withMetadataFieldName);if(l){let $=(Mt=r==null?void 0:r.plugin)==null?void 0:Mt.indexNoteBasename();$&&(S=(Lt=r._mCache.getCache(`${t.path}/${$}.md`))==null?void 0:Lt.frontmatter,G=G||(S==null?void 0:S.hasOwnProperty(y.withMetadataFieldName)))}G&&(n=!0)}break;case 7:if(r!=null&&r.bookmarksPluginInstance){let A=r==null?void 0:r.bookmarksPluginInstance.determineBookmarkOrder(t.path);A&&(n=!0,s=A)}case 8:if(r!=null&&r.iconFolderPluginInstance){let A=jt(t,r.iconFolderPluginInstance);A&&(y.iconName?n=A===y.iconName:n=!0)}break;case 1:n=!0;break}n&&i&&(a=i+"//"+t.name,i=i+"//"+c)}let g=e.groups.length,f=n?o:g;if(n){let I=e.groups[f].combineWithIdx;I!==void 0&&(f=I)}n||(L(e.outsidersFilesGroupIdx)&&d?(f=e.outsidersFilesGroupIdx,n=!0):L(e.outsidersFoldersGroupIdx)&&l?(f=e.outsidersFoldersGroupIdx,n=!0):L(e.outsidersGroupIdx)&&(f=e.outsidersGroupIdx,n=!0));let x,_,b,p;if(n&&f!==void 0){let I=e.groups[f],y=Ie((wt=I==null?void 0:I.sorting)==null?void 0:wt.order),C=Ie((Bt=I==null?void 0:I.secondarySorting)==null?void 0:Bt.order),A=Ie((h=e.defaultSorting)==null?void 0:h.order),S=Ie((Wt=e.defaultSecondarySorting)==null?void 0:Wt.order);if((y||C||A||S)&&r!=null&&r._mCache){let G=d?t.path:`${t.path}/${t.name}.md`,$=(Gt=r._mCache.getCache(G))==null?void 0:Gt.frontmatter,U;if(l){let be=($t=r==null?void 0:r.plugin)==null?void 0:$t.indexNoteBasename();be&&(U=(zt=r._mCache.getCache(`${t.path}/${be}.md`))==null?void 0:zt.frontmatter)}y&&(x=Ae(I.sorting.byMetadata||I.withMetadataFieldName||J,I.sorting.metadataValueExtractor,$,U)),C&&(_=Ae(I.secondarySorting.byMetadata||I.withMetadataFieldName||J,I.secondarySorting.metadataValueExtractor,$,U)),A&&(b=Ae(e.defaultSorting.byMetadata||J,e.defaultSorting.metadataValueExtractor,$,U)),S&&(p=Ae(e.defaultSecondarySorting.byMetadata||J,e.defaultSecondarySorting.metadataValueExtractor,$,U))}}return{groupIdx:f,sortString:i!=null?i:c,sortStringWithExt:i?a:t.name,metadataFieldValue:x,metadataFieldValueSecondary:_,metadataFieldValueForDerived:b,metadataFieldValueForDerivedSecondary:p,isFolder:l,folder:l?t:void 0,path:t.path,ctime:d?m.stat.ctime:Ke,mtime:d?m.stat.mtime:dr,bookmarkedIdx:s}},ur=new Set([11,14,17,20]),Jt=(...t)=>t.some(e=>e&&ur.has(e)),bn=new Set([...ur,10,13,16,19]),Qt=(...t)=>t.some(e=>e&&bn.has(e)),xn=new Set([26,27]),er=(...t)=>t.some(e=>e&&xn.has(e)),Fn=(t,e)=>{for(let r=[t];r.length>0;){let o=r.pop();if(o&&(e(o),Je(o))){let n=o.children;r=r.concat(n)}}},kn=(t,e)=>{var i,a;let r=dr,o=Ke,n=s=>{if(Je(s))return;let l=s;l.stat.mtime>r&&(r=l.stat.mtime),(l.stat.ctime<o||o===Ke)&&(o=l.stat.ctime)};return e?((a=(i=ge.Vault)==null?void 0:i.recurseChildren)!=null?a:Fn)(t,n):t.children.forEach(n),[r,o]},mr=(t,e)=>{var i,a,s,l,d;let r=Qt((i=e.defaultSorting)==null?void 0:i.order,(a=e.defaultSecondarySorting)==null?void 0:a.order),o=Jt((s=e.defaultSorting)==null?void 0:s.order,(l=e.defaultSecondarySorting)==null?void 0:l.order),n=(d=e.groups)==null?void 0:d.map(m=>{var c,u,g,f;return{foldersDatesNeeded:Qt((c=m.sorting)==null?void 0:c.order,(u=m.secondarySorting)==null?void 0:u.order),foldersDeepDatesNeeded:Jt((g=m.sorting)==null?void 0:g.order,(f=m.secondarySorting)==null?void 0:f.order)}});t.forEach(m=>{m.folder&&(r||m.groupIdx!==void 0&&n[m.groupIdx].foldersDatesNeeded)&&([m.mtime,m.ctime]=kn(m.folder,o||m.groupIdx!==void 0&&n[m.groupIdx].foldersDeepDatesNeeded))})},gr=(t,e,r)=>{var n;if(!r)return;let o=!!(e.defaultSorting&&er(e.defaultSorting.order,(n=e.defaultSecondarySorting)==null?void 0:n.order));t.forEach(i=>{var s,l;let a=!1;if(!o){let d=i.groupIdx;if(d!==void 0){let m=(s=e.groups[d].sorting)==null?void 0:s.order,c=(l=e.groups[d].secondarySorting)==null?void 0:l.order;a=er(m,c)}}(o||a)&&(i.bookmarkedIdx=r.determineBookmarkOrder(i.path))})},fr=function(t,e,r){let o=this.sortOrder,n=this.fileItems;return In(t,o,e,n,r)},In=function(t,e,r,o,n){var d;r.groupsShadow=(d=r.groups)==null?void 0:d.map(m=>Object.assign({},m));let i=t.name;Ze(r,i);let a=(r.itemsToHide?t.children.filter(m=>!r.itemsToHide.has(m.name)):t.children).map(m=>cr(m,r,n));mr(a,r),n.bookmarksPluginInstance&&gr(a,r,n.bookmarksPluginInstance);let s=lr(r,e);return a.sort(s),a.map(m=>o[m.path])},An=function(t,e,r,o,n){var i;if(r){let a={};r.groupsShadow=(i=r.groups)==null?void 0:i.map(c=>Object.assign({},c));let s=t.name;Ze(r,s);let l=e.map(c=>(a[c.path]=c,cr(c,r,o)));mr(l,r),o.bookmarksPluginInstance&&gr(l,r,o.bookmarksPluginInstance);let d=lr(r,n);return l.sort(d),l.map(c=>a[c.path])}else{let a=e.map(l=>l),s=Sn(n);return a.sort(s),a}},pr=An;var Qe={},Cn=t=>{let e=new Date(`${t}-01-01T00:00:00.000Z`),r=0,o=1,n=4,i=5,a=6,s=e.getDay(),l=0;s===r?l=6:s>o&&(l=s-o);let d=[i,a,r].includes(s)?7:0;return{year:t,mondayDateOf1stWeekUS:new Date(e).setDate(e.getDate()-l),sundayDateOf1stWeekUS:new Date(e).setDate(e.getDate()-l+7-1),mondayDateOf1stWeekISO:new Date(e).setDate(e.getDate()-l+d),sundayDateOf1stWeekISO:new Date(e).setDate(e.getDate()-l+d+7-1)}},hr=(t,e,r,o)=>{var l;let i=(l=Qe[t])!=null?l:Qe[t]=Cn(t),a=(r?i.mondayDateOf1stWeekISO:i.mondayDateOf1stWeekUS)+(e-1)*6048e5,s=(r?i.sundayDateOf1stWeekISO:i.sundayDateOf1stWeekUS)+(e-1)*6048e5;return new Date(o?s:a)};var Sr=" *([MDCLXVI]+)",br=" *([MDCLXVI]+(?:\\.[MDCLXVI]+)*)",xr=" *([MDCLXVI]+(?:-[MDCLXVI]+)*)",Fr=" *(\\d+)",kr=" *(\\d+(?:\\.\\d+)*)",Ir=" *(\\d+(?:-\\d+)*)",tt=" *(\\d{4}-[0-3]*[0-9]-[0-3]*[0-9])",Ar=tt,rt=" *([0-3]*[0-9]-[0-3]*[0-9]-\\d{4})",Cr=rt,_r=" *([0-3]*[0-9]-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\\d{4})",Tr=" *((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-3]*[0-9]-\\d{4})",Or=" *(\\d{4}-W[0-5]*[0-9] \\([0-3]*[0-9]-[0-3]*[0-9]\\))",ot=" *(\\d{4}-W[0-5]*[0-9][-+]?)",Er=ot,Te=".",nt="-",M="/",_n=">",Rr="|",Tn=Te,On=_n,_e=8,Pr="(\\p{Letter}+)",Nr="([a-zA-Z]+)";function w(t,e){if(typeof t=="string")if(t.length<e){let r=e-t.length;return"000000000000000000000000000".substring(0,r)+t}else return t;else return w((t!=null?t:"").toString(),e)}function Oe(t="",e,r){return e?`${t.split(e).filter(n=>n).map(n=>w(n,r!=null?r:_e)).join(Rr)}${M}${M}`:`${w(t,r!=null?r:_e)}${M}${M}`}function et(t){let e="0iIvVxXlLcCdDmM",r=[0,1,1,5,5,10,10,50,50,100,100,500,500,1e3,1e3];if(t){let o=e.indexOf(t[0]);return o>0?r[o]:0}else return 0}function yr(t){if(t==null)return"0";let e=et(t.charAt(0)),r,o;for(let n=1;n<t.length;n++)o=et(t.charAt(n)),r=et(t.charAt(n-1)),o<=r?e+=o:e=e-r*2+o;return`${e}`}function Ee(t,e,r){return e?`${t.split(e).filter(n=>n).map(n=>w(yr(n),r!=null?r:_e)).join(Rr)}${M}${M}`:`${w(yr(t),r!=null?r:_e)}${M}${M}`}var Dr=2,vr=2,Mr=4,it=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function V(t,e,r,o,n){return i=>{let a=i.split(t),s=w(a[e],Dr),l=n?`${1+it.indexOf(a[r])}`:a[r],d=w(l,vr);return`${w(a[o],Mr)}-${d}-${s}${M}${M}`}}var Lr=V("-",2,1,0),wr=V("-",1,2,0),Br=V("-",1,0,2),Wr=V("-",0,1,2),Gr=V("-",0,1,2,it),$r=V("-",1,0,2,it),En="-",Rn="+",Pn=/(\d{4})-W(\d{1,2}) \((\d{2})-(\d{2})\)/,Nn=/(\d{4})-W(\d{1,2})([-+]?)/,Dn=1,vn=2,Mn=3,Ln=4,wn=3,Bn=12,Wn=1;function st(t,e){return r=>{let o=t?Nn.exec(r):Pn.exec(r),n=o[Dn],i=Number.parseInt(n,10),a,s,l=M,d=!1;if(t){let m=o[vn],c=Number.parseInt(m,10),u=o[wn];u===En?l=Tn:u===Rn&&(l=On,d=!0);let g=hr(i,c,e,d);a=g.getMonth()+1,s=g.getDate(),c===1&&a===Bn&&i--,c>=50&&a===Wn&&i++}else a=Number.parseInt(o[Mn],10),s=Number.parseInt(o[Ln],10);return`${w(`${i}`,Mr)}-${w(`${a}`,vr)}-${w(`${s}`,Dr)}${l}${M}`}}var zr=st(!1),Hr=st(!0,!0),Vr=st(!0,!1);var Gn="/",Re="...",Yr="*",Ne=`/${Re}`,De=`/${Re}/`,ve=`/${Yr}`,at=0,Ur=t=>t.split(Gn).filter(e=>!!e),Pe=class{constructor(e){this.checkIfImplicitSpec=e;this.tree={subtree:{}};this.determinedWildcardRules={};this.addWildcardDefinition=(e,r)=>{let o=Ur(e),n=o.pop();if(n!==Yr&&n!==Re)return null;let i=this.tree;if(o.forEach(a=>{let s=i.subtree[a];if(s)i=s;else{let l={name:a,subtree:{}};i.subtree[a]=l,i=l}}),n===Re){if(i.matchChildren&&!this.checkIfImplicitSpec(i.matchChildren))return{errorMsg:`Duplicate wildcard '${n}' specification for ${e}`};i.matchChildren=r}else{if(i.matchAll&&!this.checkIfImplicitSpec(i.matchAll))return{errorMsg:`Duplicate wildcard '${n}' specification for ${e}`};i.matchAll=r}};this.addRegexpDefinition=(e,r,o,n,i)=>{let a={regexp:e,againstName:r,priority:o||at,sortingSpec:i,logMatches:!!n};if(this.regexps===void 0||this.regexps.length===0)this.regexps=[a];else{let s=0;for(;s<this.regexps.length&&this.regexps[s].priority>a.priority;)s++;this.regexps.splice(s,0,a)}};this.folderMatch=(e,r)=>{var n,i,a;let o=this.determinedWildcardRules[e];if(o)return(n=o.spec)!=null?n:null;{let s;if(this.regexps){for(let l of this.regexps)if(!(l.againstName&&!r)&&l.regexp.test(l.againstName?r||"":e)){if(s=l.sortingSpec,l.logMatches){let d=l.againstName?`name: ${r}`:`path: ${e}`;console.log(`custom-sort plugin - regexp <${l.regexp.source}> matched folder ${d}`)}break}}if(!s){s=this.tree.matchChildren;let l=this.tree.matchAll,d=Ur(e),m=this.tree,c=d.length-1;for(let u=0;u<=c;u++){let g=d[u],f=m.subtree[g];if(f)m=f,s=(i=f==null?void 0:f.matchChildren)!=null?i:null,l=(a=f.matchAll)!=null?a:l;else{u<c&&(s=l);break}}s!=null||(s=l)}return s?(this.determinedWildcardRules[e]={spec:s},s):(this.determinedWildcardRules[e]={},null)}}}};function jr(t,e){return r=>{var n;let o=r==null?void 0:r.match(t);if(o&&o[0])return(n=e(o[0]))!=null?n:void 0}}var lt=[{specPattern:"date(dd/mm/yyyy)",extractorFn:jr(new RegExp("\\d{2}/\\d{2}/\\d{4}"),V("/",0,1,2))},{specPattern:"date(mm/dd/yyyy)",extractorFn:jr(new RegExp("\\d{2}/\\d{2}/\\d{4}"),V("/",1,0,2))}],qr=t=>{for(let e of lt)if(typeof e.specPattern=="string"&&t.trim().startsWith(e.specPattern))return{m:e.extractorFn,remainder:t.substring(e.specPattern.length).trim()}},Zr,Xr,Ms={extractorFnForDate_ddmmyyyy:(Zr=lt.find(t=>t.specPattern==="date(dd/mm/yyyy)"))==null?void 0:Zr.extractorFn,extractorFnForDate_mmddyyyy:(Xr=lt.find(t=>t.specPattern==="date(mm/dd/yyyy)"))==null?void 0:Xr.extractorFn};var So=(h=>(h[h.SyntaxError=0]="SyntaxError",h[h.SyntaxErrorInGroupSpec=1]="SyntaxErrorInGroupSpec",h[h.DuplicateSortSpecForSameFolder=2]="DuplicateSortSpecForSameFolder",h[h.DuplicateOrderAttr=3]="DuplicateOrderAttr",h[h.DanglingOrderAttr=4]="DanglingOrderAttr",h[h.MissingAttributeValue=5]="MissingAttributeValue",h[h.NoSpaceBetweenAttributeAndValue=6]="NoSpaceBetweenAttributeAndValue",h[h.InvalidAttributeValue=7]="InvalidAttributeValue",h[h.TargetFolderNestedSpec=8]="TargetFolderNestedSpec",h[h.TooManySortingSymbols=9]="TooManySortingSymbols",h[h.SortingSymbolAdjacentToWildcard=10]="SortingSymbolAdjacentToWildcard",h[h.ItemToHideExactNameWithExtRequired=11]="ItemToHideExactNameWithExtRequired",h[h.ItemToHideNoSupportForThreeDots=12]="ItemToHideNoSupportForThreeDots",h[h.DuplicateWildcardSortSpecForSameFolder=13]="DuplicateWildcardSortSpecForSameFolder",h[h.ProblemNoLongerApplicable_StandardObsidianSortAllowedOnlyAtFolderLevel=14]="ProblemNoLongerApplicable_StandardObsidianSortAllowedOnlyAtFolderLevel",h[h.PriorityNotAllowedOnOutsidersGroup=15]="PriorityNotAllowedOnOutsidersGroup",h[h.TooManyPriorityPrefixes=16]="TooManyPriorityPrefixes",h[h.CombiningNotAllowedOnOutsidersGroup=17]="CombiningNotAllowedOnOutsidersGroup",h[h.TooManyCombinePrefixes=18]="TooManyCombinePrefixes",h[h.ModifierPrefixesOnlyOnOutsidersGroup=19]="ModifierPrefixesOnlyOnOutsidersGroup",h[h.OnlyLastCombinedGroupCanSpecifyOrder=20]="OnlyLastCombinedGroupCanSpecifyOrder",h[h.TooManyGroupTypePrefixes=21]="TooManyGroupTypePrefixes",h[h.PriorityPrefixAfterGroupTypePrefix=22]="PriorityPrefixAfterGroupTypePrefix",h[h.CombinePrefixAfterGroupTypePrefix=23]="CombinePrefixAfterGroupTypePrefix",h[h.InlineRegexInPrefixAndSuffix=24]="InlineRegexInPrefixAndSuffix",h[h.DuplicateByNameSortSpecForFolder=25]="DuplicateByNameSortSpecForFolder",h[h.EmptyFolderNameToMatch=26]="EmptyFolderNameToMatch",h[h.InvalidOrEmptyFolderMatchingRegexp=27]="InvalidOrEmptyFolderMatchingRegexp",h))(So||{}),$n=new Set([2,13,20,25,26,27]),v="...",pe=v.length,pt="./...",Kr=pt.length,Jr=1,zn=1,Qr={"a-z.":{asc:2,desc:6},"a-z":{asc:1,desc:5},"true a-z.":{asc:4,desc:8},"true a-z":{asc:3,desc:7},created:{asc:15,desc:18},modified:{asc:9,desc:12},"advanced modified":{asc:10,desc:13},"advanced created":{asc:16,desc:19},"advanced recursive modified":{asc:11,desc:14},"advanced recursive created":{asc:17,desc:20},standard:{asc:25,desc:25},"ui selected":{asc:25,desc:25},"by-bookmarks-order":{asc:26,desc:27},"files-first":{asc:28,desc:28},"folders-first":{asc:29,desc:29},"vsc-unicode":{asc:32,desc:33},"unicode-charcode":{asc:32,desc:33}},eo="by-metadata:",to="using-extractor:",Hn=",";var dt="Invalid sorting order",ct={[1]:"Invalid target folder specification",[2]:dt,[3]:dt,[4]:dt},ht="target-folder:",bo={"<":2,"\\<":2,">":3,"\\>":3},yt={...bo,"order-asc:":2,"order-desc:":3,"sorting:":4},St={...bo,"order-asc":2,"order-desc":3,asc:2,desc:3},Vn={[ht]:1,"::::":1},ro={...yt,...St,...Vn},oo=(t,e)=>{let r=Object.keys(e?St:yt).find(o=>t==null?void 0:t.toLowerCase().startsWith(o));return r?{lexeme:r,attr:e?St[r]:yt[r]}:void 0},Un=t=>{let e=Object.keys(Qr).find(r=>t==null?void 0:t.toLowerCase().startsWith(r));return e?{literal:e,order:Qr[e]}:void 0},Yn={[1]:21,[5]:23,[3]:22,[7]:24,[2]:21,[6]:23,[4]:22,[8]:24},no=".",jn="/:files",Zn="/:",Xn="/:files.",qn="/:.",Kn="/folders",Jn="/",Qn="%",ei="/folders:files",ti="/folders:files.",ri="/%",oi="/%.",ni="--%",ii="/--hide:",io="with-metadata:",si="bookmarked:",so="with-icon:",ut="//",ai="/!",li="/!!",di="/!!!",ci="/!:",ui="/!!:",mi="/!!!:",xo=1,Fo=2,ko=3,ao={[ai]:xo,[li]:Fo,[di]:ko},lo={[ci]:xo,[ui]:Fo,[mi]:ko},gi="/+",fi=[gi],co={[ti]:{filenameWithExt:!0},[oi]:{filenameWithExt:!0},[qn]:{filesOnly:!0,filenameWithExt:!0},[Xn]:{filesOnly:!0,filenameWithExt:!0},[Zn]:{filesOnly:!0},[jn]:{filesOnly:!0},[Jn]:{foldersOnly:!0},[Kn]:{foldersOnly:!0},[Qn]:{},[ei]:{},[ri]:{},[ni]:{itemToHide:!0},[ii]:{itemToHide:!0}},B=t=>t===v,le=t=>t.indexOf(v)!==-1,Io="\\R+",Ao="\\.R+",Co="\\-R+",_o="\\d+",To="\\.d+",Oo="\\-d+",Eo="\\a+",Ro="\\A+",Po="\\d",No="\\[0-9]",Do="\\[0-3]",vo="\\[yyyy-mm-dd]",Mo="\\[yyyy-dd-mm]",Lo="\\[dd-Mmm-yyyy]",wo="\\[Mmm-dd-yyyy]",Bo="\\[dd-mm-yyyy]",Wo="\\[mm-dd-yyyy]",Go="\\[yyyy-Www (mm-dd)]",$o="\\[yyyy-Www]",zo="\\[yyyy-WwwISO]",Ho="\\C",Vo="\\l",pi=/[\^$.\-+\[\]{}()|*?=!\\]/g,F=t=>t.replace(pi,"\\$&"),hi=[F(_o),F(Io),F(To),F(Oo),F(Ao),F(Co),F(Eo),F(Ro),F(vo),F(Mo),F(Lo),F(wo),F(Bo),F(Wo),F(Go),F(zo),F($o)],ee=new RegExp(hi.join("|"),"gi"),yi=[F(Po),F(No),F(Do),F(Ho),F(Vo)],uo={[Po]:{regexExpr:"\\d"},[No]:{regexExpr:"[0-9]"},[Do]:{regexExpr:"[0-3]"},[Ho]:{regexExpr:"[\\p{Lu}\\p{Lt}]",isUnicode:!0,isCaseSensitive:!0},[Vo]:{regexExpr:"\\p{Ll}",isUnicode:!0,isCaseSensitive:!0}},mo=new RegExp(yi.join("|"),"gi"),Si=t=>(ee.lastIndex=0,ee.test(t)&&ee.test(t)),bi=t=>(ee.lastIndex=0,ee.test(t)),xi=t=>(mo.lastIndex=0,t?mo.test(t):!1),Fi=t=>{if(t){ee.lastIndex=0;let e=ee.exec(t);return e?e[0]:null}else return null},ki=t=>Ee(t),Ii=t=>Ee(t,Te),Ai=t=>Ee(t,nt),Ci=t=>Oe(t),_i=t=>Oe(t,Te),Ti=t=>Oe(t,nt),Oi=t=>Lr(t),Ei=t=>wr(t),Ri=t=>Gr(t),Pi=t=>$r(t),Ni=t=>Wr(t),Di=t=>Br(t),vi=t=>zr(t),Mi=t=>Hr(t),Li=t=>Vr(t);var go={[Io.toLowerCase()]:{regexpStr:Sr,normalizerFn:ki,advancedRegexType:4},[Ao.toLowerCase()]:{regexpStr:br,normalizerFn:Ii,advancedRegexType:5},[Co.toLowerCase()]:{regexpStr:xr,normalizerFn:Ai,advancedRegexType:6},[_o.toLowerCase()]:{regexpStr:Fr,normalizerFn:Ci,advancedRegexType:1},[To.toLowerCase()]:{regexpStr:kr,normalizerFn:_i,advancedRegexType:2},[Oo.toLowerCase()]:{regexpStr:Ir,normalizerFn:Ti,advancedRegexType:3},[Eo]:{regexpStr:Nr,normalizerFn:Ye,advancedRegexType:7},[Ro]:{regexpStr:Pr,normalizerFn:Ye,advancedRegexType:8,unicodeRegex:!0},[vo]:{regexpStr:tt,normalizerFn:Oi,advancedRegexType:9},[Mo]:{regexpStr:Ar,normalizerFn:Ei,advancedRegexType:10},[Lo]:{regexpStr:_r,normalizerFn:Ri,advancedRegexType:11},[wo]:{regexpStr:Tr,normalizerFn:Pi,advancedRegexType:12},[Bo]:{regexpStr:Cr,normalizerFn:Ni,advancedRegexType:13},[Wo]:{regexpStr:rt,normalizerFn:Di,advancedRegexType:14},[Go]:{regexpStr:Or,normalizerFn:vi,advancedRegexType:15},[zo]:{regexpStr:ot,normalizerFn:Mi,advancedRegexType:16},[$o]:{regexpStr:Er,normalizerFn:Li,advancedRegexType:17}};var fo=t=>bt(t,1),po=t=>bt(t,2),wi=t=>bt(t,3),bt=(t,e)=>{var i;let r=[1,3].includes(e),o=[2,3].includes(e),n=Fi(t);if(n){let a=(i=go[n])!=null?i:go[n.toLowerCase()],[s,l]=t.split(n),d=r?"^":"",m=o?"$":"",c=mt(s),u=mt(l),g=!!a.unicodeRegex||!!c.isUnicodeRegex||!!u.isUnicodeRegex,f=!!c.isCaseSensitiveRegex||!!u.isCaseSensitiveRegex,x=`${g?"u":""}${f?"":"i"}`;return{regexpSpec:{regex:new RegExp(`${d}${c.s}${a.regexpStr}${u.s}${m}`,x),normalizerFn:a.normalizerFn},prefix:s,suffix:l,containsAdvancedRegex:a.advancedRegexType}}else if(xi(t)){let a=mt(t),s=r?"^":"",l=o?"$":"",d=`${a.isUnicodeRegex?"u":""}${a.isCaseSensitiveRegex?"":"i"}`;return{regexpSpec:{regex:new RegExp(`${s}${a.s}${l}`,d)},prefix:"",suffix:"",containsAdvancedRegex:0}}else return null},mt=t=>{if(t==="")return{s:t};let e=[],r=!1,o=!1;for(;t.length>0;){let n,i;for(let a of Object.keys(uo)){let s=t.indexOf(a);s>=0&&(n!==void 0?s<n&&(n=s,i=a):(n=s,i=a))}if(n!==void 0){if(n>0){let s=t.substring(0,n);e.push(F(s)),t=t.substring(n)}let a=uo[i];e.push(a.regexExpr),r||(r=!!a.isUnicode),o||(o=!!a.isCaseSensitive),t=t.substring(i.length)}else e.push(F(t)),t=""}return{s:e.join(""),isUnicodeRegex:r,isCaseSensitiveRegex:o}},he="name:",gt="regexp:",Bi="for-name:",Wi="debug:",Gi=t=>(t!=null||(t={}),t.sortSpecByPath||(t.sortSpecByPath={}),t),$i=t=>(t!=null||(t={}),t.sortSpecByName||(t.sortSpecByName={}),t),ho=t=>(t!=null||(t={}),t.sortSpecByWildcard||(t.sortSpecByWildcard=new Pe(e=>!!e.implicit)),t),Me=t=>({noPrefix:t.prefix.length===0,noSuffix:t.suffix.length===0}),zi=t=>t.endsWith(Ne)||t.endsWith(De)||t.endsWith(ve);var Hi=(t,e)=>t.endsWith(ve)?(t=t.slice(0,-ve.length),{path:t.length>0?t:"/",detectedWildcardPriority:e?6:4}):t.endsWith(Ne)?(t=t.slice(0,-Ne.length),{path:t.length>0?t:"/",detectedWildcardPriority:e?5:3}):t.endsWith(De)?(t=t.slice(0,-De.length),{path:t.length>0?t:"/",detectedWildcardPriority:e?5:3}):{path:t,detectedWildcardPriority:e?2:1},ft=(t,e,r)=>t.startsWith(e)?(r(),t.substring(e.length).trim()):t,Vi=t=>{let e=!1,r,o,n;do{n=!1,t=ft(t,Bi,()=>{e=!0,n=!0});for(let i of Object.keys(lo)){let a=!1;if(t=ft(t,i,()=>{r=lo[i],n=!0,a=!0}),a)break}t=ft(t,Wi,()=>{o=!0,n=!0})}while(n);if(!t||t.trim()==="")throw new Error("Empty regexp");return{regexp:new RegExp(t),againstName:e,priority:r===void 0?at:r,log:!!o}},j=class{constructor(e){this.errorMsg=e}},yo=(t,e)=>{var o,n;let r=(n=(o=t.trim().split(" "))==null?void 0:o[0])==null?void 0:n.trim();return r||e},Le="Sorting symbol must not be directly adjacent to a wildcard because of potential performance problem. An additional explicit separator helps in such case.",we=class{constructor(e){this.errorLogger=e;this.pathMatchPriorityForPath={};this.problem=(e,r)=>{var s;let o=So[e],n=(s=this.errorLogger)!=null?s:console.error,i=!$n.has(e),a=i?` line ${this.currentEntryLineIdx} of`:"";n(`Sorting specification problem: ${e}:${o} ${r} ---encountered in${a} sorting spec in file ${this.currentSortingSpecContainerFilePath}`),a&&n(`Content of problematic line: "${this.currentEntryLine}"`),this.recentErrorMessage=`File: ${this.currentSortingSpecContainerFilePath}
|
|
`+(i?`Specification line #${this.currentEntryLineIdx}: "${this.currentEntryLine}"
|
|
`:"")+`Problem: ${e}:${o}
|
|
Details: ${r}`,this.problemAlreadyReportedForCurrentLine=!0};this.parseAttribute=e=>{let r=e.trimStart(),o=e.length-r.length,n=r.indexOf(" ");if(n===-1)return null;let i=r.substring(0,n),a=i.toLowerCase(),s=ro[a];if(s){let l=r.substring(n).trim();if(l){let d=this.attrValueValidators[s];if(d){let m=d(l,s,i);if(m instanceof j)this.problem(7,m.errorMsg||ct[s]);else{if(m)return{nesting:o,attribute:s,value:m};this.problem(7,ct[s])}}else return{nesting:o,attribute:s,value:l}}else this.problem(5,`${ct[s]}: "${i}" requires a value to follow`)}return null};this.checkForRiskyAttrSyntaxError=e=>{let r=e.trimStart(),o=r.toLowerCase();for(let n of Object.keys(ro))if(o.startsWith(n)){let i=r.substring(0,n.length);return o.length===n.length?(this.problem(5,`Attribute "${i}" requires a value to follow`),!0):(this.problem(6,`Space required after attribute name "${i}"`),!0)}return!1};this.parseSortingGroupSpec=e=>{let r=e.trim();if(Si(r))return this.problem(9,"Maximum one sorting symbol allowed per line"),null;if(le(r)){let[u,g]=r.split(v);if(le(u)&&le(g))return this.problem(24,"In current version, inline regex symbols are not allowed both in prefix and suffix."),null}let o,n=0,i,a=0,s,l=0,d=!1,m=!1,c;for(;c===void 0||c;){let u=!1;for(let g of Object.keys(ao))if(r===g||r.startsWith(g+" ")){o=ao[g],n++,c=!0,u=!0,s&&(d=!0),r=r.substring(g.length).trim();break}if(!u){for(let g of fi)if(r===g||r.startsWith(g+" ")){i=!0,a++,c=!0,u=!0,s&&(m=!0),r=r.substring(g.length).trim();break}if(!u){for(let g of Object.keys(co))if(r===g||r.startsWith(g+" ")){s=co[g],l++,c=!0,u=!0,r=r.substring(g.length).trim();break}u||(c=!1)}}}return n>1?(this.problem(16,"Only one priority prefix allowed on sorting group"),null):r===""&&o?(this.problem(15,"Priority is not allowed for sorting group with empty match-pattern"),null):a>1?(this.problem(18,"Only one combining prefix allowed on sorting group"),null):r===""&&i?(this.problem(17,"Combining is not allowed for sorting group with empty match-pattern"),null):l>1?(this.problem(21,"Only one sorting group type prefix allowed on sorting group"),null):d?(this.problem(22,"Priority prefix must be used before sorting group type indicator"),null):m?(this.problem(23,"Combining prefix must be used before sorting group type indicator"),null):r===""&&s?s.itemToHide?(this.problem(11,"Exact name with ext of file or folders to hide is required"),null):{outsidersGroup:!0,filesOnly:s.filesOnly,foldersOnly:s.foldersOnly}:s?s.itemToHide?{itemToHide:!0,plainSpec:r,filesOnly:s.filesOnly,foldersOnly:s.foldersOnly}:{plainSpec:r,filesOnly:s.filesOnly,foldersOnly:s.foldersOnly,matchFilenameWithExt:s.filenameWithExt,priority:o!=null?o:void 0,combine:i}:(o||i)&&r!==""?{plainSpec:r,priority:o,combine:i}:null};this.COMBINING_INDICATOR_IDX=-1;this.validateTargetFolderAttrValue=(e,r,o)=>e&&e.trim()||null;this.internalValidateOrderAttrValue=(e,r)=>{var i,a;e.indexOf(ut)>=0&&(e=e.substring(0,e.indexOf(ut)));let o=`${r||""} ${e}`.trim().split(Hn),n=[];for(let s=0;s<=zn&&s<o.length;s++){let l=s===0?"Primary":"Secondary",d=o[s].trim(),m=!1,c=oo(d);d=c?d.substring(c.lexeme.length).trim():d;let u=Un(d);d=u?d.substring(u.literal.length).trim():d;let g=u?oo(d,!0):void 0;d=g?d.substring(g.lexeme.length).trim():d;let f,x;if(d.startsWith(eo)){m=!0;let p=d.substring(eo.length).trim()||void 0;if(p)if(p.indexOf(to)>-1){let P=p.split(to);f=(i=P.shift())==null?void 0:i.trim();let K=(a=P==null?void 0:P.shift())==null?void 0:a.trim(),ce=K?qr(K):void 0;if(ce)x=ce.m;else return new j(`${l} sorting order contains unrecognized value extractor: >>> ${K} <<<`);d=""}else f=p,d="";else d=""}let _=d.trim()||void 0;if(_)return new j(`${l} sorting order contains unrecognized text: >>> ${_} <<<`);if(c&&g&&c.attr!==4&&g.attr!==4&&c.attr!==g.attr)return new j(`${l} sorting direction ${c.lexeme} and ${g.lexeme} are contradicting`);let b;if(u){switch(c?c.attr:g?g.attr:2){case 2:b=u.order.asc;break;case 3:b=u.order.desc;break;case 4:g?b=g.attr===2?u.order.asc:u.order.desc:b=u.order.asc;break;default:b=void 0}if(m&&(b&&(b=Yn[b]),!b))return new j("Sorting by metadata requires one of alphabetical orders")}else return null;n[s]={order:b,byMetadata:f,metadataValueExtractor:x}}return n};this.validateOrderAttrValue=(e,r,o)=>{let n=this.internalValidateOrderAttrValue(e,o);return n?n instanceof j?n:{primary:n[0],secondary:n[1]}:null};this.attrValueValidators={[1]:this.validateTargetFolderAttrValue.bind(this),[2]:this.validateOrderAttrValue.bind(this),[3]:this.validateOrderAttrValue.bind(this),[4]:this.validateOrderAttrValue.bind(this)};this.convertPlainStringSortingGroupSpecToArraySpec=e=>{if(e=e.trim(),B(e))return[v];if(e.startsWith(v))return[v,e.substring(pe)];if(e.endsWith(v))return e.endsWith(pt)?[e.substring(0,e.length-Kr+Jr),v]:[e.substring(0,e.length-pe),v];let r=e.indexOf(v),o=e.indexOf(pt);return r>0?o>=0&&o===r-(Kr-pe)?[e.substring(0,o+Jr),v,e.substring(r+pe)]:[e.substring(0,r),v,e.substring(r+pe)]:[e]};this.consumeParsedSortingGroupSpec=e=>{var r,o,n;if(e.outsidersGroup)return{type:0,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt};if(((r=e.arraySpec)==null?void 0:r.length)===1){let i=e.arraySpec[0];if(B(i))return{type:1,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt};if(i.startsWith(io)){let a=yo(i.substring(io.length),J);return{type:6,withMetadataFieldName:a,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt}}else{if(i.startsWith(si))return{type:7,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt};if(i.startsWith(so)){let a=yo(i.substring(so.length));return{type:8,iconName:a,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt}}else return{type:2,exactText:i,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt}}}if(((o=e.arraySpec)==null?void 0:o.length)===2){let i=e.arraySpec[0],a=e.arraySpec[1];return B(i)&&!B(a)&&!le(a)?{type:4,exactSuffix:a,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt}:!B(i)&&B(a)&&!le(i)?{type:3,exactPrefix:i,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt}:(this.problem(1,"three dots occurring more than once and no more text specified"),null)}if(((n=e.arraySpec)==null?void 0:n.length)===3){let i=e.arraySpec[0],a=e.arraySpec[1],s=e.arraySpec[2];return B(a)&&!B(i)&&!B(s)&&!le(s)?{type:5,exactPrefix:i,exactSuffix:s,filesOnly:e.filesOnly,foldersOnly:e.foldersOnly,matchFilenameWithExt:e.matchFilenameWithExt}:(this.problem(1,"three dots occurring more than once or unrecognized specification of sorting rule"),null)}return this.problem(1,"Unrecognized specification of sorting rule"),null};this.adjustSortingGroupForRegexBasedMatchers=e=>this.adjustSortingGroupForSortingSymbol(e);this.adjustSortingGroupForSortingSymbol=e=>{switch(e.type){case 3:let r=fo(e.exactPrefix);if(r){if(r.containsAdvancedRegex&&Me(r).noSuffix)return this.problem(10,Le),!1;delete e.exactPrefix,e.regexPrefix=r.regexpSpec}break;case 4:let o=po(e.exactSuffix);if(o){if(o.containsAdvancedRegex&&Me(o).noPrefix)return this.problem(10,Le),!1;delete e.exactSuffix,e.regexSuffix=o.regexpSpec}break;case 5:let n=fo(e.exactPrefix);if(n){if(n.containsAdvancedRegex&&Me(n).noSuffix)return this.problem(10,Le),!1;delete e.exactPrefix,e.regexPrefix=n.regexpSpec}let i=po(e.exactSuffix);if(i){if(i.containsAdvancedRegex&&Me(i).noPrefix)return this.problem(10,Le),!1;delete e.exactSuffix,e.regexSuffix=i.regexpSpec}break;case 2:let a=wi(e.exactText);a&&(delete e.exactText,e.regexPrefix=a.regexpSpec);break}return!0};this.addExpediteGroupInfo=(e,r,o)=>{e.priorityOrder||(e.priorityOrder=[]);let n=!1;for(let i=0;i<e.priorityOrder.length;i++)if(r>e.groups[e.priorityOrder[i]].priority){e.priorityOrder.splice(i,0,o),n=!0;break}n||e.priorityOrder.push(o)}}parseSortSpecFromText(e,r,o,n,i){this.ctx={folderPath:r,specs:[],implicitSpec:i},this.currentEntryLine=null,this.currentEntryLineIdx=null,this.currentSortingSpecContainerFilePath=null,this.problemAlreadyReportedForCurrentLine=null,this.recentErrorMessage=null;let a=!1,s=0;for(let l of e){s++,this.currentEntryLine=l,this.currentEntryLineIdx=s,this.currentSortingSpecContainerFilePath=`${r==="/"?"":r}/${o}`,this.problemAlreadyReportedForCurrentLine=!1;let d=l.trim();if(d===""||d.startsWith(ut))continue;a=!1;let m=this.parseAttribute(l);if(m)a=this.processParsedSortingAttribute(m),this.ctx.previousValidEntryWasTargetFolderAttr=a&&m.attribute===1;else if(!this.problemAlreadyReportedForCurrentLine&&!this.checkForRiskyAttrSyntaxError(l)){let c=this.parseSortingGroupSpec(l);!this.problemAlreadyReportedForCurrentLine&&!c&&(c={plainSpec:d}),c&&(a=this.processParsedSortGroupSpec(c)),this.ctx.previousValidEntryWasTargetFolderAttr=void 0}if(!a){this.problemAlreadyReportedForCurrentLine||this.problem(0,"Sorting specification line doesn't match any supported syntax");break}}if(a){if(this.ctx.specs.length>0){for(let l of this.ctx.specs)if(!this.postprocessSortSpec(l))return null;for(let l of this.ctx.specs)for(let d=0;d<l.targetFoldersPaths.length;d++){let m=l.targetFoldersPaths[d];if(m.startsWith(he)){let c=m.substring(he.length).trim();if(c==="")return this.problem(26,`Empty '${ht} ${he}' value`),null;if(n=$i(n),n.sortSpecByName[c])return this.problem(25,`Duplicate '${ht} ${he}' definition for the same name <${c}>`),null;n.sortSpecByName[c]=l}}for(let l of this.ctx.specs)for(let d=0;d<l.targetFoldersPaths.length;d++){let m=l.targetFoldersPaths[d];if(m.startsWith(gt)){n=ho(n);let c=m.substring(gt.length).trim();try{let u=Vi(c);n.sortSpecByWildcard.addRegexpDefinition(u.regexp,u.againstName,u.priority,u.log,l)}catch(u){return this.problem(27,`Invalid or empty folder regexp expression <${c}>`),null}}else if(zi(m)){n=ho(n);let c=n.sortSpecByWildcard.addWildcardDefinition(m,l);if(c!=null&&c.errorMsg)return this.problem(13,c==null?void 0:c.errorMsg),null}}for(let l of this.ctx.specs)for(let d=0;d<l.targetFoldersPaths.length;d++){let m=l.targetFoldersPaths[d];if(!m.startsWith(he)&&!m.startsWith(gt)){let{path:c,detectedWildcardPriority:u}=Hi(m,!!l.implicit),g=!0,f=this.pathMatchPriorityForPath[c];if(f){if(f===1&&u===1)return this.problem(2,`Duplicate sorting spec for folder ${c}`),null;u>=f&&(g=!1)}g&&(n=Gi(n),n.sortSpecByPath[c]=l,this.pathMatchPriorityForPath[c]=u)}}}return n}else return null}processParsedSortingAttribute(e){if(e.attribute===1)return e.nesting===0?(this.ctx.previousValidEntryWasTargetFolderAttr?this.ctx.currentSpec?this.ctx.currentSpec.targetFoldersPaths.push(e.value):this.ctx.currentSpec=this.putNewSpecForNewTargetFolder(e.value):this.ctx.currentSpec=this.putNewSpecForNewTargetFolder(e.value),!0):(this.problem(8,"Nested (indented) specification of target folder is not allowed"),!1);if(e.attribute===2||e.attribute===3||e.attribute===4){if(e.nesting===0){if(this.ctx.currentSpec||(this.ctx.currentSpec=this.putNewSpecForNewTargetFolder()),this.ctx.currentSpec.defaultSorting){let o=this.ctx.currentSpec.targetFoldersPaths.join(" :: ");return this.problem(3,`Duplicate order specification for folder(s) ${o}`),!1}let r=e.value;return this.ctx.currentSpec.defaultSorting=r.primary,this.ctx.currentSpec.defaultSecondarySorting=r.secondary,!0}else if(e.nesting>0){if(!this.ctx.currentSpec||!this.ctx.currentSpecGroup)return this.problem(4,"Nested (indented) attribute requires prior sorting group definition"),!1;if(this.ctx.currentSpecGroup.sorting){let o=this.ctx.currentSpec.targetFoldersPaths.join(" :: ");return this.problem(3,`Duplicate order specification for a sorting rule of folder ${o}`),!1}let r=e.value;return this.ctx.currentSpecGroup.sorting=r.primary,this.ctx.currentSpecGroup.secondarySorting=r.secondary,!0}}return!1}processParsedSortGroupSpec(e){if(this.ctx.currentSpec||(this.ctx.currentSpec=this.putNewSpecForNewTargetFolder()),e.plainSpec&&(e.arraySpec=this.convertPlainStringSortingGroupSpecToArraySpec(e.plainSpec),delete e.plainSpec),e.itemToHide)return this.consumeParsedItemToHide(e)?!0:(this.problem(12,"For hiding of file or folder, the exact name with ext is required and no sorting symbols allowed"),!1);{let r=this.consumeParsedSortingGroupSpec(e);if(r)if(this.adjustSortingGroupForSortingSymbol(r))if(this.ctx.currentSpec){let o=this.ctx.currentSpec.groups.push(r)-1;return this.ctx.currentSpecGroup=r,e.priority&&e.priority>0&&(r.priority=e.priority,this.addExpediteGroupInfo(this.ctx.currentSpec,e.priority,o)),e.combine&&(r.combineWithIdx=this.COMBINING_INDICATOR_IDX),!0}else return!1;else return!1;else return!1}}postprocessSortSpec(e){e.outsidersGroupIdx=void 0,e.outsidersFilesGroupIdx=void 0,e.outsidersFoldersGroupIdx=void 0;let r,o;for(let s=0;s<e.groups.length;s++){let l=e.groups[s];l.type===0&&(l.filesOnly?L(e.outsidersFilesGroupIdx)?console.warn(`Ignoring duplicate Outsiders-files sorting group definition in sort spec for folder '${ue(e.targetFoldersPaths)}'`):(e.outsidersFilesGroupIdx=s,o=!0):l.foldersOnly?L(e.outsidersFoldersGroupIdx)?console.warn(`Ignoring duplicate Outsiders-folders sorting group definition in sort spec for folder '${ue(e.targetFoldersPaths)}'`):(e.outsidersFoldersGroupIdx=s,r=!0):L(e.outsidersGroupIdx)?console.warn(`Ignoring duplicate Outsiders sorting group definition in sort spec for folder '${ue(e.targetFoldersPaths)}'`):(e.outsidersGroupIdx=s,r=!0,o=!0))}L(e.outsidersGroupIdx)&&(L(e.outsidersFilesGroupIdx)||L(e.outsidersFoldersGroupIdx))&&console.warn(`Inconsistent Outsiders sorting group definition in sort spec for folder '${ue(e.targetFoldersPaths)}'`),o&&r||(e.outsidersGroupIdx=e.groups.length,e.groups.push({type:0}));let n=!1,i;for(let s=0;s<e.groups.length;s++){let l=e.groups[s];if(l.combineWithIdx===this.COMBINING_INDICATOR_IDX){if(i===void 0)i=s;else if(e.groups[s-1].sorting)return this.problem(20,"Predecessor group of combined group cannot contain order specification. Put it at the last of group in combined groups"),!1;l.combineWithIdx=i,n=!0}else i=void 0}if(n){let s,l,d;for(let m=e.groups.length-1;m>=0;m--){let c=e.groups[m];c.combineWithIdx!==void 0?c.combineWithIdx===d?(c.sorting=s,c.secondarySorting=l):(d=c.combineWithIdx,s=c.sorting,l=c.secondarySorting):(d=void 0,s=void 0,l=void 0)}}if(e.priorityOrder)for(let s=0;s<e.groups.length;s++){let l=e.groups[s];l.priority===void 0&&l.type!==0&&e.priorityOrder.push(s)}let a=`${no}/`;return e.targetFoldersPaths.forEach((s,l)=>{s===no?e.targetFoldersPaths[l]=this.ctx.folderPath:s.startsWith(a)&&(e.targetFoldersPaths[l]=`${this.ctx.folderPath}/${s.substring(a.length)}`)}),!0}putNewSpecForNewTargetFolder(e){let r={targetFoldersPaths:[e!=null?e:this.ctx.folderPath],groups:[],implicit:this.ctx.implicitSpec};return this.ctx.specs.push(r),this.ctx.currentSpec=void 0,this.ctx.currentSpecGroup=void 0,r}consumeParsedItemToHide(e){var r,o,n;if(((r=e.arraySpec)==null?void 0:r.length)===1){let i=e.arraySpec[0];if(!B(i)){let a=i.trim();if(a&&!bi(a)&&this.ctx.currentSpec){let s=(n=(o=this.ctx.currentSpec)==null?void 0:o.itemsToHide)!=null?n:new Set;return s.add(a),this.ctx.currentSpec.itemsToHide=s,!0}}}return!1}};var te=require("obsidian"),xt="custom-sort-icon-active",Ft="custom-sort-icon-mobile-initial",Be="custom-sort-icon-suspended",Ui="custom-sort-icon-enabled-not-applied",kt="custom-sort-icon-syntax-error",It="custom-sort-icon-general-error";function Uo(){(0,te.addIcon)(xt,`<path d="M 93.54751 9.983795 L 79.21469 31.556912 C 78.297815 32.93695 76.4358 33.31242 75.05576 32.395544 C 74.72319 32.174593 74.43808 31.88948 74.21713 31.556912 L 59.8843 9.983795 C 58.96743 8.603756 59.3429 6.74174 60.722935 5.824865 C 61.21491 5.4980047 61.792426 5.3236456 62.383084 5.3236456 L 91.04873 5.3236456 C 92.70559 5.3236456 94.04873 6.666791 94.04873 8.323646 C 94.04873 8.914304 93.87437 9.49182 93.54751 9.983795 Z" fill="currentColor"/>
|
|
<path d="M 11.096126 32.678017 L 20.217128 18.949499 C 21.134003 17.56946 22.99602 17.193992 24.376058 18.110867 C 24.708624 18.331818 24.99374 18.616933 25.21469 18.949499 L 34.33569 32.678017 C 35.252567 34.058055 34.8771 35.92007 33.49706 36.836947 C 33.005085 37.163807 32.42757 37.338166 31.83691 37.338166 L 13.594907 37.338166 C 11.938053 37.338166 10.594907 35.99502 10.594907 34.338166 C 10.594907 33.747508 10.769266 33.16999 11.096126 32.678017 Z" fill="currentColor"/>
|
|
<path d="M 11.096126 55.71973 L 20.217128 41.991214 C 21.134003 40.611175 22.99602 40.235707 24.376058 41.15258 C 24.708624 41.373533 24.99374 41.65865 25.21469 41.991214 L 34.33569 55.71973 C 35.252567 57.09977 34.8771 58.96179 33.49706 59.87866 C 33.005085 60.20552 32.42757 60.37988 31.83691 60.37988 L 13.594907 60.37988 C 11.938053 60.37988 10.594907 59.036736 10.594907 57.37988 C 10.594907 56.78922 10.769266 56.21171 11.096126 55.71973 Z" fill="currentColor"/>
|
|
<path d="M 2.5382185 90.37054 L 20.217128 63.76105 C 21.134003 62.38101 22.99602 62.005545 24.376058 62.92242 C 24.708624 63.14337 24.99374 63.428486 25.21469 63.76105 L 42.8936 90.37054 C 43.810475 91.75058 43.435006 93.6126 42.05497 94.52947 C 41.562993 94.85633 40.985477 95.03069 40.39482 95.03069 L 5.0369993 95.03069 C 3.380145 95.03069 2.0369993 93.68755 2.0369993 92.03069 C 2.0369993 91.44004 2.2113584 90.86252 2.5382185 90.37054 Z" fill="currentColor"/>
|
|
<path d="M 88.33569 46.24901 L 79.21469 59.97753 C 78.297815 61.35757 76.4358 61.73304 75.05576 60.81616 C 74.72319 60.59521 74.43808 60.310096 74.21713 59.97753 L 65.09613 46.24901 C 64.17925 44.868973 64.55472 43.006957 65.93476 42.09008 C 66.42673 41.76322 67.00425 41.588863 67.59491 41.588863 L 85.83691 41.588863 C 87.49377 41.588863 88.83691 42.93201 88.83691 44.58886 C 88.83691 45.17952 88.66255 45.757036 88.33569 46.24901 Z" fill="currentColor"/>
|
|
<path d="M 88.33569 77.48964 L 79.21469 91.21816 C 78.297815 92.5982 76.4358 92.97366 75.05576 92.05679 C 74.72319 91.83584 74.43808 91.55072 74.21713 91.21816 L 65.09613 77.48964 C 64.17925 76.1096 64.55472 74.247585 65.93476 73.33071 C 66.42673 73.00385 67.00425 72.82949 67.59491 72.82949 L 85.83691 72.82949 C 87.49377 72.82949 88.83691 74.17264 88.83691 75.82949 C 88.83691 76.42015 88.66255 76.99766 88.33569 77.48964 Z" fill="currentColor"/>`),(0,te.addIcon)(Ft,`<path d="M 93.54751 9.983795 L 79.21469 31.556912 C 78.297815 32.93695 76.4358 33.31242 75.05576 32.395544 C 74.72319 32.174593 74.43808 31.88948 74.21713 31.556912 L 59.8843 9.983795 C 58.96743 8.603756 59.3429 6.74174 60.722935 5.824865 C 61.21491 5.4980047 61.792426 5.3236456 62.383084 5.3236456 L 91.04873 5.3236456 C 92.70559 5.3236456 94.04873 6.666791 94.04873 8.323646 C 94.04873 8.914304 93.87437 9.49182 93.54751 9.983795 Z" fill="currentColor"/>
|
|
<path d="M 11.096126 55.71973 L 20.217128 41.991214 C 21.134003 40.611175 22.99602 40.235707 24.376058 41.15258 C 24.708624 41.373533 24.99374 41.65865 25.21469 41.991214 L 34.33569 55.71973 C 35.252567 57.09977 34.8771 58.96179 33.49706 59.87866 C 33.005085 60.20552 32.42757 60.37988 31.83691 60.37988 L 13.594907 60.37988 C 11.938053 60.37988 10.594907 59.036736 10.594907 57.37988 C 10.594907 56.78922 10.769266 56.21171 11.096126 55.71973 Z" fill="currentColor"/>
|
|
<path d="M 2.5382185 90.37054 L 20.217128 63.76105 C 21.134003 62.38101 22.99602 62.005545 24.376058 62.92242 C 24.708624 63.14337 24.99374 63.428486 25.21469 63.76105 L 42.8936 90.37054 C 43.810475 91.75058 43.435006 93.6126 42.05497 94.52947 C 41.562993 94.85633 40.985477 95.03069 40.39482 95.03069 L 5.0369993 95.03069 C 3.380145 95.03069 2.0369993 93.68755 2.0369993 92.03069 C 2.0369993 91.44004 2.2113584 90.86252 2.5382185 90.37054 Z" fill="currentColor"/>
|
|
<path d="M 88.33569 77.48964 L 79.21469 91.21816 C 78.297815 92.5982 76.4358 92.97366 75.05576 92.05679 C 74.72319 91.83584 74.43808 91.55072 74.21713 91.21816 L 65.09613 77.48964 C 64.17925 76.1096 64.55472 74.247585 65.93476 73.33071 C 66.42673 73.00385 67.00425 72.82949 67.59491 72.82949 L 85.83691 72.82949 C 87.49377 72.82949 88.83691 74.17264 88.83691 75.82949 C 88.83691 76.42015 88.66255 76.99766 88.33569 77.48964 Z" fill="currentColor"/>`),(0,te.addIcon)(Be,`<path d="M 93.54751 9.983795 L 79.21469 31.556912 C 78.297815 32.93695 76.4358 33.31242 75.05576 32.395544 C 74.72319 32.174593 74.43808 31.88948 74.21713 31.556912 L 59.8843 9.983795 C 58.96743 8.603756 59.3429 6.74174 60.722935 5.824865 C 61.21491 5.4980047 61.792426 5.3236456 62.383084 5.3236456 L 91.04873 5.3236456 C 92.70559 5.3236456 94.04873 6.666791 94.04873 8.323646 C 94.04873 8.914304 93.87437 9.49182 93.54751 9.983795 Z" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
<path d="M 2.5382185 90.37054 L 20.217128 63.76105 C 21.134003 62.38101 22.99602 62.005545 24.376058 62.92242 C 24.708624 63.14337 24.99374 63.428486 25.21469 63.76105 L 42.8936 90.37054 C 43.810475 91.75058 43.435006 93.6126 42.05497 94.52947 C 41.562993 94.85633 40.985477 95.03069 40.39482 95.03069 L 5.0369993 95.03069 C 3.380145 95.03069 2.0369993 93.68755 2.0369993 92.03069 C 2.0369993 91.44004 2.2113584 90.86252 2.5382185 90.37054 Z" stroke="currentColor" stroke-width="2" fill="none"/>`),(0,te.addIcon)(kt,`<path d="M 93.54751 9.983795 L 79.21469 31.556912 C 78.297815 32.93695 76.4358 33.31242 75.05576 32.395544 C 74.72319 32.174593 74.43808 31.88948 74.21713 31.556912 L 59.8843 9.983795 C 58.96743 8.603756 59.3429 6.74174 60.722935 5.824865 C 61.21491 5.4980047 61.792426 5.3236456 62.383084 5.3236456 L 91.04873 5.3236456 C 92.70559 5.3236456 94.04873 6.666791 94.04873 8.323646 C 94.04873 8.914304 93.87437 9.49182 93.54751 9.983795 Z" fill="red"/>
|
|
<path d="M 11.096126 32.678017 L 20.217128 18.949499 C 21.134003 17.56946 22.99602 17.193992 24.376058 18.110867 C 24.708624 18.331818 24.99374 18.616933 25.21469 18.949499 L 34.33569 32.678017 C 35.252567 34.058055 34.8771 35.92007 33.49706 36.836947 C 33.005085 37.163807 32.42757 37.338166 31.83691 37.338166 L 13.594907 37.338166 C 11.938053 37.338166 10.594907 35.99502 10.594907 34.338166 C 10.594907 33.747508 10.769266 33.16999 11.096126 32.678017 Z" stroke="red" stroke-width="2" fill="none"/>
|
|
<path d="M 11.096126 55.71973 L 20.217128 41.991214 C 21.134003 40.611175 22.99602 40.235707 24.376058 41.15258 C 24.708624 41.373533 24.99374 41.65865 25.21469 41.991214 L 34.33569 55.71973 C 35.252567 57.09977 34.8771 58.96179 33.49706 59.87866 C 33.005085 60.20552 32.42757 60.37988 31.83691 60.37988 L 13.594907 60.37988 C 11.938053 60.37988 10.594907 59.036736 10.594907 57.37988 C 10.594907 56.78922 10.769266 56.21171 11.096126 55.71973 Z" stroke="red" stroke-width="2" fill="none"/>
|
|
<path d="M 2.5382185 90.37054 L 20.217128 63.76105 C 21.134003 62.38101 22.99602 62.005545 24.376058 62.92242 C 24.708624 63.14337 24.99374 63.428486 25.21469 63.76105 L 42.8936 90.37054 C 43.810475 91.75058 43.435006 93.6126 42.05497 94.52947 C 41.562993 94.85633 40.985477 95.03069 40.39482 95.03069 L 5.0369993 95.03069 C 3.380145 95.03069 2.0369993 93.68755 2.0369993 92.03069 C 2.0369993 91.44004 2.2113584 90.86252 2.5382185 90.37054 Z" stroke="red" stroke-width="2" fill="none"/>
|
|
<path d="M 88.33569 46.24901 L 79.21469 59.97753 C 78.297815 61.35757 76.4358 61.73304 75.05576 60.81616 C 74.72319 60.59521 74.43808 60.310096 74.21713 59.97753 L 65.09613 46.24901 C 64.17925 44.868973 64.55472 43.006957 65.93476 42.09008 C 66.42673 41.76322 67.00425 41.588863 67.59491 41.588863 L 85.83691 41.588863 C 87.49377 41.588863 88.83691 42.93201 88.83691 44.58886 C 88.83691 45.17952 88.66255 45.757036 88.33569 46.24901 Z" fill="red"/>
|
|
<path d="M 88.33569 77.48964 L 79.21469 91.21816 C 78.297815 92.5982 76.4358 92.97366 75.05576 92.05679 C 74.72319 91.83584 74.43808 91.55072 74.21713 91.21816 L 65.09613 77.48964 C 64.17925 76.1096 64.55472 74.247585 65.93476 73.33071 C 66.42673 73.00385 67.00425 72.82949 67.59491 72.82949 L 85.83691 72.82949 C 87.49377 72.82949 88.83691 74.17264 88.83691 75.82949 C 88.83691 76.42015 88.66255 76.99766 88.33569 77.48964 Z" fill="red"/>`),(0,te.addIcon)(It,`<path d="M 93.54751 9.983795 L 79.21469 31.556912 C 78.297815 32.93695 76.4358 33.31242 75.05576 32.395544 C 74.72319 32.174593 74.43808 31.88948 74.21713 31.556912 L 59.8843 9.983795 C 58.96743 8.603756 59.3429 6.74174 60.722935 5.824865 C 61.21491 5.4980047 61.792426 5.3236456 62.383084 5.3236456 L 91.04873 5.3236456 C 92.70559 5.3236456 94.04873 6.666791 94.04873 8.323646 C 94.04873 8.914304 93.87437 9.49182 93.54751 9.983795 Z" fill="red"/>
|
|
<path d="M 11.096126 32.678017 L 20.217128 18.949499 C 21.134003 17.56946 22.99602 17.193992 24.376058 18.110867 C 24.708624 18.331818 24.99374 18.616933 25.21469 18.949499 L 34.33569 32.678017 C 35.252567 34.058055 34.8771 35.92007 33.49706 36.836947 C 33.005085 37.163807 32.42757 37.338166 31.83691 37.338166 L 13.594907 37.338166 C 11.938053 37.338166 10.594907 35.99502 10.594907 34.338166 C 10.594907 33.747508 10.769266 33.16999 11.096126 32.678017 Z" fill="red"/>
|
|
<path d="M 11.096126 55.71973 L 20.217128 41.991214 C 21.134003 40.611175 22.99602 40.235707 24.376058 41.15258 C 24.708624 41.373533 24.99374 41.65865 25.21469 41.991214 L 34.33569 55.71973 C 35.252567 57.09977 34.8771 58.96179 33.49706 59.87866 C 33.005085 60.20552 32.42757 60.37988 31.83691 60.37988 L 13.594907 60.37988 C 11.938053 60.37988 10.594907 59.036736 10.594907 57.37988 C 10.594907 56.78922 10.769266 56.21171 11.096126 55.71973 Z" fill="red"/>
|
|
<path d="M 2.5382185 90.37054 L 20.217128 63.76105 C 21.134003 62.38101 22.99602 62.005545 24.376058 62.92242 C 24.708624 63.14337 24.99374 63.428486 25.21469 63.76105 L 42.8936 90.37054 C 43.810475 91.75058 43.435006 93.6126 42.05497 94.52947 C 41.562993 94.85633 40.985477 95.03069 40.39482 95.03069 L 5.0369993 95.03069 C 3.380145 95.03069 2.0369993 93.68755 2.0369993 92.03069 C 2.0369993 91.44004 2.2113584 90.86252 2.5382185 90.37054 Z" fill="red"/>
|
|
<path d="M 88.33569 46.24901 L 79.21469 59.97753 C 78.297815 61.35757 76.4358 61.73304 75.05576 60.81616 C 74.72319 60.59521 74.43808 60.310096 74.21713 59.97753 L 65.09613 46.24901 C 64.17925 44.868973 64.55472 43.006957 65.93476 42.09008 C 66.42673 41.76322 67.00425 41.588863 67.59491 41.588863 L 85.83691 41.588863 C 87.49377 41.588863 88.83691 42.93201 88.83691 44.58886 C 88.83691 45.17952 88.66255 45.757036 88.33569 46.24901 Z" fill="red"/>
|
|
<path d="M 88.33569 77.48964 L 79.21469 91.21816 C 78.297815 92.5982 76.4358 92.97366 75.05576 92.05679 C 74.72319 91.83584 74.43808 91.55072 74.21713 91.21816 L 65.09613 77.48964 C 64.17925 76.1096 64.55472 74.247585 65.93476 73.33071 C 66.42673 73.00385 67.00425 72.82949 67.59491 72.82949 L 85.83691 72.82949 C 87.49377 72.82949 88.83691 74.17264 88.83691 75.82949 C 88.83691 76.42015 88.66255 76.99766 88.33569 77.48964 Z" fill="red"/>`),(0,te.addIcon)(Ui,`<path d="M 93.54751 9.983795 L 79.21469 31.556912 C 78.297815 32.93695 76.4358 33.31242 75.05576 32.395544 C 74.72319 32.174593 74.43808 31.88948 74.21713 31.556912 L 59.8843 9.983795 C 58.96743 8.603756 59.3429 6.74174 60.722935 5.824865 C 61.21491 5.4980047 61.792426 5.3236456 62.383084 5.3236456 L 91.04873 5.3236456 C 92.70559 5.3236456 94.04873 6.666791 94.04873 8.323646 C 94.04873 8.914304 93.87437 9.49182 93.54751 9.983795 Z" stroke="orange" stroke-width="2" fill="none"/>
|
|
<path d="M 11.096126 55.71973 L 20.217128 41.991214 C 21.134003 40.611175 22.99602 40.235707 24.376058 41.15258 C 24.708624 41.373533 24.99374 41.65865 25.21469 41.991214 L 34.33569 55.71973 C 35.252567 57.09977 34.8771 58.96179 33.49706 59.87866 C 33.005085 60.20552 32.42757 60.37988 31.83691 60.37988 L 13.594907 60.37988 C 11.938053 60.37988 10.594907 59.036736 10.594907 57.37988 C 10.594907 56.78922 10.769266 56.21171 11.096126 55.71973 Z" stroke="orange" stroke-width="2" fill="none"/>
|
|
<path d="M 2.5382185 90.37054 L 20.217128 63.76105 C 21.134003 62.38101 22.99602 62.005545 24.376058 62.92242 C 24.708624 63.14337 24.99374 63.428486 25.21469 63.76105 L 42.8936 90.37054 C 43.810475 91.75058 43.435006 93.6126 42.05497 94.52947 C 41.562993 94.85633 40.985477 95.03069 40.39482 95.03069 L 5.0369993 95.03069 C 3.380145 95.03069 2.0369993 93.68755 2.0369993 92.03069 C 2.0369993 91.44004 2.2113584 90.86252 2.5382185 90.37054 Z" stroke="orange" stroke-width="2" fill="none"/>
|
|
<path d="M 88.33569 46.24901 L 79.21469 59.97753 C 78.297815 61.35757 76.4358 61.73304 75.05576 60.81616 C 74.72319 60.59521 74.43808 60.310096 74.21713 59.97753 L 65.09613 46.24901 C 64.17925 44.868973 64.55472 43.006957 65.93476 42.09008 C 66.42673 41.76322 67.00425 41.588863 67.59491 41.588863 L 85.83691 41.588863 C 87.49377 41.588863 88.83691 42.93201 88.83691 44.58886 C 88.83691 45.17952 88.66255 45.757036 88.33569 46.24901 Z" stroke="orange" stroke-width="2" fill="none"/>`)}var oe=require("obsidian");var Yi="getBookmarks",$e="items",_t=t=>{if(!t||(t==null?void 0:t.length)===0)return!0;for(let e of t)if(e.type!=="group"||!e.title||!q(e.title)||!_t(e.items))return!1;return!0},Yo=t=>_t(t.items),Ct=class{constructor(){this.determineBookmarkOrder=e=>{if(Z||([Z,Se]=Ji(this.plugin,this.groupNameForSorting),We=Date.now()),e&&e.length>0){let r=Z==null?void 0:Z[e];return r&&r>0?r:void 0}else return};this.bookmarkFolderItem=e=>{this.bookmarkSiblings([e],!0)};this.unbookmarkFolderItem=e=>{this.unbookmarkSiblings([e])};this.saveDataAndUpdateBookmarkViews=(e=!0)=>{if(this.plugin.onItemsChanged(!0),e){let r=this.app.workspace.getLeavesOfType("bookmarks");r==null||r.forEach(o=>{var n,i;(i=(n=o.view)==null?void 0:n.update)==null||i.call(n)})}};this.bookmarkSiblings=(e,r)=>{if(e.length===0)return;let o=X(e[0].path,Xo,this.plugin,this.groupNameForSorting);o&&e.forEach(n=>{let i=Y(n.path),a=o.items.find(s=>s.type==="group"&&W(s.title||"")===i&&q(s.title));if(a)a.title=W(a.title||"");else if(!o.items.find(s=>(s.type==="folder"||s.type==="file")&&s.path===n.path||s.type==="group"&&s.title===i)){let s=n instanceof oe.TFolder?Zo(i):Qi(n.path);r?o.items.unshift(s):o.items.push(s)}})};this.unbookmarkSiblings=e=>{if(e.length===0)return;let r=X(e[0].path,de,this.plugin,this.groupNameForSorting);if(r){let o=[];e.forEach(n=>{let i=Y(n.path),a=r.items.find(s=>s.type==="group"&&W(s.title||"")===i);if(a)Yo(a)?(r.items.remove(a),re(r,this.plugin,this.groupNameForSorting)):q(a.title)||(a.title=Ge(a.title||""));else{let s=r.items.find(l=>(l.type==="folder"||l.type==="file")&&l.path===n.path);s&&(r.items.remove(s),re(r,this.plugin,this.groupNameForSorting))}})}};this.updateSortingBookmarksAfterItemRenamed=(e,r)=>{es(this.plugin,e,r,this.groupNameForSorting)};this.updateSortingBookmarksAfterItemDeleted=e=>{ts(this.plugin,e,this.groupNameForSorting)};this.isBookmarkedForSorting=e=>{var o,n;let r=X(e.path,de,this.plugin,this.groupNameForSorting);if(r){if(e instanceof oe.TFile)return(o=r.items)==null?void 0:o.some(i=>i.type==="file"&&i.path===e.path);{let i=Y(e.path);return(n=r.items)==null?void 0:n.some(a=>a.type==="group"&&a.title===i||a.type==="folder"&&a.path===e.path)}}return!1};this.bookmarksIncludeItemsInFolder=e=>!!(Se!=null&&Se[e])}},ji="bookmarks",D=(t,e,r,o)=>{var i;Xi(r);let n=(i=t==null?void 0:t.internalPlugins)==null?void 0:i.getPluginById(ji);if(n&&n.enabled&&n.instance){let a=n.instance;if(typeof(a==null?void 0:a[Yi])=="function"&&Array.isArray(a==null?void 0:a[$e]))return ye.app=t,ye.plugin=a,ye.groupNameForSorting=e,o&&!Z&&ye.determineBookmarkOrder(),ye}},Z,We,Se,ye=new Ct,Zi=1e3,Xi=t=>{if(Z){let e=!0;!t&&We&&Date.now()-Zi<=We&&(e=!1),e&&(Z=void 0,We=void 0,Se=void 0)}},qi=(t,e)=>{if(!Array.isArray(t))return;let r=(o,n)=>{if(Array.isArray(o))for(let i=0,a=o;i<a.length;i++){let s=a[i];if(e(s,n))return;if(s.type==="group"){let l=W(s.title||"");r(s.items,`${n}${n?"/":""}${l}`)}}};r(t,"")},jo="#^-",Ki="/",Tt="\\\\",q=t=>!!(t!=null&&t.startsWith(Tt)),Ge=t=>q(t)?t:`${Tt}${t}`,W=t=>q(t)?t.substring(Tt.length):t,Ji=(t,e)=>{let r=t==null?void 0:t[$e],o={};if(r&&Array.isArray(r)){if(e){let n=r.find(i=>i.type==="group"&&i.title===e);r=n?n.items:void 0}if(r){let n={},i=1;qi(r,(l,d)=>{if(l.type==="group"){if(!q(l.title)){let m=`${d}${d?"/":""}${l.title}`,c=n[m];if(c&&(c.isGroup||c.hasSortingIndicator))return;n[m]={path:m,order:i++,isGroup:!0}}}else if(l.type==="file"||l.type==="folder"){let m=l,c=l.type==="file"?l:void 0,u=n[m.path],g=c?c.subpath===jo:void 0,f=Q(m.path),x=d===f,_=!((d==null?void 0:d.length)>0);if(!x&&!_)return;if(u){if(g){if(u.hasSortingIndicator&&u.bookmarkPathMatches||u.hasSortingIndicator&&!x)return}else if(u.hasSortingIndicator||!x||u.bookmarkPathMatches||u.isGroup)return}n[m.path]={path:m.path,order:i++,isGroup:!1,bookmarkPathMatches:x,hasSortingIndicator:g}}});let s={};for(let l in n){s[l]=n[l].order;let d=Q(l);o[d.length>0?d:Ki]=!0}return[s,o]}}return[void 0,void 0]},Qi=t=>({type:"file",ctime:Date.now(),path:t,subpath:jo}),Zo=t=>({type:"group",ctime:Date.now(),items:[],title:t}),X=(t,e,r,o)=>{let n=r==null?void 0:r[$e];if(!Array.isArray(n)||!t||!t.trim())return;let i=Q(t),a=i?i.split("/"):[];o&&a.unshift(o);let s,l=!1,d=!0;for(let m of a){if(s=n.find(c=>c.type==="group"&&W(c.title||"")===m),!s){if(e){let u=!!o&&d?m:Ge(m);s=Zo(u),n.push(s)}else{l=!0;break}d=!1}n=s.items}if(!l)return{items:n,group:s,pathOfGroup:i}},Xo=!0,de=!1,At=(t,e,r)=>{r===!0?t.title=Ge(e):r===!1?t.title=e:t.title=q(t.title)?Ge(e):e},re=(t,e,r)=>{var o,n;if(t&&t.group&&_t(t.items)){t.group.items=[];let i=X(t.pathOfGroup||"",de,e,r);i&&(q(t.group.title)&&((n=(o=i.group)==null?void 0:o.items)==null||n.remove(t.group)),re(i,e,r))}},es=(t,e,r,o)=>{var f,x,_,b;if(e.path===r)return;let n=e instanceof oe.TFolder,i=!n,a=Q(r),s=Y(r),l=Q(e.path),d=Y(e.path),m=a!==l,c=s!==d;if(i&&c)return;let u=X(r,de,t,o);if(!u)return;let g=n?u.items.find(p=>p.type==="group"&&W(p.title||"")===s):u.items.find(p=>p.type==="file"&&p.path===e.path);if(g)if(i)m&&((f=u.group)==null||f.items.remove(g),re(u,t,o));else{let p=g;if(Yo(p))m?((x=u.group)==null||x.items.remove(p),re(u,t,o)):c&&At(p,d,void 0);else{if(m){(_=u.group)==null||_.items.remove(p);let P=X(e.path,Xo,t,o);P&&((b=P.group)==null||b.items.push(p),At(p,W(p.title||""),!0)),re(u,t,o)}c&&At(p,d,void 0)}}},ts=(t,e,r)=>{if(e instanceof oe.TFile)return;let o=t[$e];if(!Array.isArray(o))return;let n=e instanceof oe.TFolder,i=!n,a=X(e.path,de,t,r),s=!!Q(e.path),l=r&&!s?X("intentionally-in-root-path",de,t,r):void 0;!a&&!l||[a,l].forEach(d=>{let m=[];d==null||d.items.forEach(c=>{n&&c.type==="group"&&W(c.title||"")===e.name&&m.push(c),i&&c.type==="file"&&c.path===e.path&&m.push(c)}),m.forEach(c=>{var u;(u=d==null?void 0:d.group)==null||u.items.remove(c)}),re(d,t,r)})};var qo=`
|
|
target-folder: /*
|
|
bookmarked:
|
|
< by-bookmarks-order
|
|
sorting: standard
|
|
`,rs=(t,e,r)=>{r===7&&t.grouping.byBookmarks++,(e===26||e===27)&&t.sorting.byBookmarks++},os=(t,e,r)=>{r===8&&t.grouping.byIcon++},ns=(t,e,r)=>{e===25&&t.sorting.standardObsidian++},ze=(t,e,r)=>{rs(t,e,r),os(t,e,r),ns(t,e,r),e!==void 0&&t.sorting.total++,r!==void 0&&r!==0&&t.grouping.total++},Ot=t=>{var r,o,n,i;let e={grouping:{byIcon:0,byBookmarks:0,total:0},sorting:{byBookmarks:0,standardObsidian:0,total:0}};if(!t)return e;if(ze(e,(r=t.defaultSorting)==null?void 0:r.order),ze(e,(o=t.defaultSecondarySorting)==null?void 0:o.order),t.groups)for(let a of t.groups)ze(e,(n=a.sorting)==null?void 0:n.order,a.type),ze(e,(i=a.secondarySorting)==null?void 0:i.order);return e},Ko=t=>t.sorting.total===t.sorting.standardObsidian+t.sorting.byBookmarks&&t.grouping.total===t.grouping.byBookmarks;var k=require("obsidian");var Pt=1e3,Jo=1,Et=0,Rt=30,is=Jo*Pt,Nt={additionalSortspecFile:"",indexNoteNameForFolderNotes:"",suspended:!0,statusBarEntryEnabled:!0,notificationsEnabled:!0,mobileNotificationsEnabled:!1,customSortContextSubmenu:!0,automaticBookmarksIntegration:!1,bookmarksContextMenus:!1,bookmarksGroupToConsumeAsOrderingReference:"sortspec",delayForInitialApplication:is},Qo={automaticBookmarksIntegration:!0,bookmarksContextMenus:!0},ss=t=>t.replace(/\//g,"_").replace(/\\/g,"_"),He=class extends k.PluginSettingTab{constructor(r,o){super(r,o);this.plugin=o}display(){let{containerEl:r}=this;r.empty();let o=(0,k.sanitizeHTMLToDom)(`Number of seconds to wait before applying custom ordering on plugin / app start.<br>For large vaults, multi-plugin vaults or on mobile the value might need to be increased if you encounter issues with auto-applying of custom ordering on start. The delay gives Obsidian additional time to sync notes from cloud storages, to populate notes metadata caches, etc.<br>At the same time if your vault is relatively small or only used on desktop, or not synced with other copies, decreasing the delay to 0 could be a safe option.<br>Min: ${Et} sec., max. ${Rt} sec.`);new k.Setting(r).setName("Delay for initial automatic application of custom ordering").setDesc(o).addText(l=>l.setValue(`${this.plugin.settings.delayForInitialApplication/Pt}`).onChange(async d=>{let m=parseFloat(d);m=Number.isNaN(m)||!Number.isFinite(m)?Jo:m<Et?Et:m>Rt?Rt:m,m=Math.round(m*10)/10,this.plugin.settings.delayForInitialApplication=m*Pt,await this.plugin.saveSettings()}));let n=(0,k.sanitizeHTMLToDom)("A note name or note path to scan (YAML frontmatter) for sorting specification in addition to the `sortspec` notes and Folder Notes.<br> The `.md` filename suffix is optional.<br><p>NOTE: After updating this setting remember to refresh the custom sorting via clicking on the ribbon icon or via the <b>sort-on</b> command or by restarting Obsidian or reloading the vault</p>");new k.Setting(r).setName("Path or name of additional note(s) containing sorting specification").setDesc(n).addText(l=>l.setPlaceholder("e.g. sorting-configuration").setValue(this.plugin.settings.additionalSortspecFile).onChange(async d=>{this.plugin.settings.additionalSortspecFile=d.trim()?(0,k.normalizePath)(d):"",await this.plugin.saveSettings()}));let i=(0,k.sanitizeHTMLToDom)('If you employ the <i>Index-File based</i> approach to folder notes (as documented in <a href="https://github.com/aidenlx/alx-folder-note/wiki/folder-note-pref">Aidenlx Folder Note preferences</a>) enter here the index note name, e.g. <b>_about_</b> or <b>index</b><br> The `.md` filename suffix is optional.<br>This will tell the plugin to read sorting specs and also folders metadata from these files.<br>The <i>Inside Folder, with Same Name Recommended</i> mode of Folder Notes is handled automatically, no additional configuration needed.</p><p>NOTE: After updating this setting remember to refresh the custom sorting via clicking on the ribbon icon or via the <b>sort-on</b> command or by restarting Obsidian or reloading the vault</p>');new k.Setting(r).setName("Name of index note (Folder Notes support)").setDesc(i).addText(l=>l.setPlaceholder("e.g. _about_ or index").setValue(this.plugin.settings.indexNoteNameForFolderNotes).onChange(async d=>{this.plugin.settings.indexNoteNameForFolderNotes=d.trim()?(0,k.normalizePath)(d):"",await this.plugin.saveSettings()})),new k.Setting(r).setName("Enable the status bar entry").setDesc("The status bar entry shows the label `Custom sort:ON` or `Custom sort:OFF`, representing the current state of the plugin.").addToggle(l=>l.setValue(this.plugin.settings.statusBarEntryEnabled).onChange(async d=>{this.plugin.settings.statusBarEntryEnabled=d,d?(this.plugin.statusBarItemEl&&this.plugin.statusBarItemEl.detach(),this.plugin.statusBarItemEl=this.plugin.addStatusBarItem(),this.plugin.updateStatusBar()):this.plugin.statusBarItemEl&&this.plugin.statusBarItemEl.detach(),await this.plugin.saveSettings()})),new k.Setting(r).setName("Enable notifications of plugin state changes").setDesc("The plugin can show notifications about its state changes: e.g. when successfully parsed and applied the custom sorting specification, or, when the parsing failed. If the notifications are disabled, the only indicator of plugin state is the ribbon button icon. The developer console presents the parsing error messages regardless if the notifications are enabled or not.").addToggle(l=>l.setValue(this.plugin.settings.notificationsEnabled).onChange(async d=>{this.plugin.settings.notificationsEnabled=d,await this.plugin.saveSettings()})),new k.Setting(r).setName("Enable notifications of plugin state changes for mobile devices only").setDesc("See above.").addToggle(l=>l.setValue(this.plugin.settings.mobileNotificationsEnabled).onChange(async d=>{this.plugin.settings.mobileNotificationsEnabled=d,await this.plugin.saveSettings()})),new k.Setting(r).setName("Enable File Explorer context submenu`Custom sort:`").setDesc("Gives access to operations relevant for custom sorting, e.g. applying custom sorting.").addToggle(l=>l.setValue(this.plugin.settings.customSortContextSubmenu).onChange(async d=>{this.plugin.settings.customSortContextSubmenu=d,await this.plugin.saveSettings()})),r.createEl("h2",{text:"Bookmarks integration"});let a=(0,k.sanitizeHTMLToDom)(`If enabled, order of files and folders in File Explorer will reflect the order of bookmarked items in the bookmarks (core plugin) view. Automatically, without any need for sorting configuration. At the same time, it integrates seamlessly with <pre style="display: inline;">sorting-spec:</pre> configurations and they can nicely cooperate.<br><p>To separate regular bookmarks from the bookmarks created for sorting, you can put the latter in a separate dedicated bookmarks group. The default name of the group is '<i>`+Nt.bookmarksGroupToConsumeAsOrderingReference+`</i>' and you can change the group name in the configuration field below.<br>If left empty, all the bookmarked items will be used to impose the order in File Explorer.</p><p>More information on this functionality in the <a href="https://github.com/SebastianMC/obsidian-custom-sort/blob/master/docs/manual.md#bookmarks-plugin-integration">manual</a> of this custom-sort plugin.</p>`);new k.Setting(r).setName("Automatic integration with core Bookmarks plugin (for indirect drag & drop ordering)").setDesc(a).addToggle(l=>l.setValue(this.plugin.settings.automaticBookmarksIntegration).onChange(async d=>{this.plugin.settings.automaticBookmarksIntegration=d,await this.plugin.saveSettings()})),new k.Setting(r).setName("Name of the group in Bookmarks from which to read the order of items").setDesc("See above.").addText(l=>l.setPlaceholder("e.g. Group for sorting").setValue(this.plugin.settings.bookmarksGroupToConsumeAsOrderingReference).onChange(async d=>{d=W(d.trim()).trim(),this.plugin.settings.bookmarksGroupToConsumeAsOrderingReference=d?ss((0,k.normalizePath)(d)):"",await this.plugin.saveSettings()}));let s=(0,k.sanitizeHTMLToDom)("Enable <i>Custom-sort: bookmark for sorting</i> and <i>Custom-sort: bookmark+siblings for sorting</i> (and related) entries in context menu in File Explorer");new k.Setting(r).setName("Context menus for Bookmarks integration").setDesc(s).addToggle(l=>l.setValue(this.plugin.settings.bookmarksContextMenus).onChange(async d=>{this.plugin.settings.bookmarksContextMenus=d,d&&(this.plugin.settings.customSortContextSubmenu=!0),await this.plugin.saveSettings()}))}};var ne="custom-sort",en="sortspec.md",tn="sorting-spec",as=1e4;var Ve=class extends T.Plugin{constructor(){super(...arguments);this.customSortAppliedAtLeastOnce=!1;this.uninstallerOfFileExplorerPatch=void 0;this.FROM_DOM_WATCHER=!0}showNotice(r,o){(this.settings.notificationsEnabled||T.Platform.isMobile&&this.settings.mobileNotificationsEnabled)&&new T.Notice(r,o)}readAndParseSortingSpec(){let r=this.app.metadataCache,o=!1,n=!1,i=null;this.sortSpecCache=null;let a=new we;this.settings.automaticBookmarksIntegration&&(this.sortSpecCache=a.parseSortSpecFromText(qo.split(`
|
|
`),"System internal path","System internal file",this.sortSpecCache,!0)),T.Vault.recurseChildren(this.app.vault.getRoot(),s=>{var l,d,m;if(!o&&s instanceof T.TFile){let c=s,u=c.parent;if(c.name===en||c.name===`${en}.md`||c.basename===u.name||c.basename===this.settings.additionalSortspecFile||c.name===this.settings.additionalSortspecFile||c.path===this.settings.additionalSortspecFile||c.path===`${this.settings.additionalSortspecFile}.md`||c.basename===this.settings.indexNoteNameForFolderNotes||c.name===this.settings.indexNoteNameForFolderNotes){let g=(d=(l=r.getCache(c.path))==null?void 0:l.frontmatter)==null?void 0:d[tn];typeof g=="string"&&(n=!0,this.sortSpecCache=a.parseSortSpecFromText(g.split(`
|
|
`),u.path,c.name,this.sortSpecCache),this.sortSpecCache===null&&(o=!0,i=(m=a.recentErrorMessage)!=null?m:""))}}}),this.sortSpecCache?n?this.showNotice("Parsing custom sorting specification SUCCEEDED!"):this.showNotice("No custom sorting spec, will go with implicit sorting (bookmarks-based)."):(n?i=i||`No valid '${tn}:' key(s) in YAML front matter or multiline YAML indentation error or general YAML syntax error`:i="No custom sorting specification found or only empty specification(s)",this.showNotice(`Parsing custom sorting specification FAILED. Suspending the plugin.
|
|
${i}`,as),this.settings.suspended=!0,this.saveSettings())}getFileExplorer(){var n;let r=(n=this.app.workspace.getLeavesOfType("file-explorer"))==null?void 0:n.first(),o=new xe;return r?r.isDeferred?o.setError({state:2,fileExplorerInDeferredState:r}):o.setValue(r):o.setError({state:1})}checkFileExplorerIsAvailableAndPatchable(r=!0){let o=this.getFileExplorer();return o.e&&o.e.state===2?(r&&this.logDeferredFileExplorerInfo(),o):(o.v&&o.v.view&&typeof o.v.view.requestSort=="function"&&typeof o.v.view.getSortedFolderItems=="function"||r&&this.logWarningFileExplorerNotAvailable(),o)}patchFileExplorer(r){let o=this;if(r)return this.uninstallFileExplorerPatchIfInstalled(),this.uninstallerOfFileExplorerPatch=Ht(r.view.constructor.prototype,{getSortedFolderItems(n){return function(...i){if(o.settings.suspended)return n.call(this,...i);let a=i[0],s=o.determineAndPrepareSortingDataForFolder(a);return s.sortSpec?(o.customSortAppliedAtLeastOnce||(o.customSortAppliedAtLeastOnce=!0,setTimeout(()=>{o.setRibbonIconToEnabled.apply(o),o.showNotice("Custom sort APPLIED."),o.updateStatusBar()})),fr.call(this,a,s.sortSpec,o.createProcessingContextForSorting(s.sortingAndGroupingStats))):n.call(this,...i)}}}),r}logDeferredFileExplorerInfo(){let r=`${ne} v${this.manifest.version}: File Explorer is not displayed yet (Obsidian deferred view detected).
|
|
Until the File Explorer is visible, the custom-sort plugin cannot apply the custom order.
|
|
`;console.warn(r)}logDeferredFileExplorerWatcherSetupInfo(){let r=`${ne} v${this.manifest.version}: A watcher was set up to apply custom sort automatically when the File Explorer is displayed.
|
|
`;console.warn(r)}logWarningFileExplorerNotAvailable(){let r=`${ne} v${this.manifest.version}: failed to locate File Explorer. The 'Files' core plugin can be disabled.
|
|
Some community plugins can also disable it.
|
|
See the example of MAKE.md plugin: https://github.com/Make-md/makemd/issues/25
|
|
You can find there instructions on how to re-enable the File Explorer in MAKE.md plugin`;console.warn(r)}switchPluginStateTo(r){this.settings.suspended=!r,this.saveSettings();let o=this.checkFileExplorerIsAvailableAndPatchable(!this.settings.suspended),n=o.v?this.patchFileExplorer(o.v):void 0;this.settings.suspended?(this.showNotice("Custom sort OFF"),this.sortSpecCache=null,(0,T.setIcon)(this.ribbonIconEl,Be),n&&n.view.requestSort()):(this.readAndParseSortingSpec(),this.sortSpecCache?n?(this.customSortAppliedAtLeastOnce=!1,n.view.requestSort()):(T.Platform.isDesktop?this.showNotice("Custom sort File Explorer view problem. See console for detailed message."):this.showNotice("Custom sort File Explorer view problem - is it visible? Can't apply custom sorting when the File Explorer was not displayed at least once."),(0,T.setIcon)(this.ribbonIconEl,It),this.settings.suspended=!0,this.saveSettings()):((0,T.setIcon)(this.ribbonIconEl,kt),this.settings.suspended=!0,this.saveSettings()));let i=!0;this.settings.suspended||D(this.app,this.settings.bookmarksGroupToConsumeAsOrderingReference,i),this.updateStatusBar()}async onload(){console.log(`loading ${ne} v${this.manifest.version}`),await this.loadSettings(),this.settings.statusBarEntryEnabled&&(this.statusBarItemEl=this.addStatusBarItem(),this.updateStatusBar()),Uo(),this.ribbonIconEl=this.addRibbonIcon(T.Platform.isDesktop?Be:Ft,"Toggle custom sorting",r=>{this.switchPluginStateTo(this.settings.suspended)}),this.addSettingTab(new He(this.app,this)),this.registerEventHandlers(),this.registerCommands(),this.registerPluginUnloadHandler(),this.initialize()}registerEventHandlers(){let r=this,o=T.Platform.isMobile,n=u=>{u.setTitle(o?"Custom sort: apply custom sorting":"Apply custom sorting"),u.onClick(()=>{r.switchPluginStateTo(!0)})},i=u=>{u.setTitle(o?"Custom sort: suspend custom sorting":"Suspend custom sorting"),u.onClick(()=>{r.switchPluginStateTo(!1)})},a=u=>g=>{g.setTitle(o?"Bookmark it for custom sorting":"Bookmark it for sorting"),g.onClick(()=>{let f=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);f&&(f.bookmarkFolderItem(u),f.saveDataAndUpdateBookmarkViews(!0))})},s=u=>g=>{g.setTitle(o?"UNbookmark it from custom sorting":"UNbookmark it from sorting"),g.onClick(()=>{let f=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);f&&(f.unbookmarkFolderItem(u),f.saveDataAndUpdateBookmarkViews(!0))})},l=u=>g=>{g.setTitle(o?"Bookmark it+siblings for custom sorting":"Bookmark it+siblings for sorting"),g.onClick(()=>{let f=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);if(f){let x=r.orderedFolderItemsForBookmarking(u.parent,f);f.bookmarkSiblings(x),f.saveDataAndUpdateBookmarkViews(!0)}})},d=u=>g=>{g.setTitle(o?"UNbookmark it+siblings from custom sorting":"UNbookmark it+siblings from sorting"),g.onClick(()=>{let f=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);if(f){let x=u.parent.children.map(_=>_);f.unbookmarkSiblings(x),f.saveDataAndUpdateBookmarkViews(!0)}})},m=u=>g=>{g.setTitle(o?"Bookmark selected for custom sorting":"Custom sort: bookmark selected for sorting"),g.onClick(()=>{let f=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);f&&(u.forEach(x=>{f.bookmarkFolderItem(x)}),f.saveDataAndUpdateBookmarkViews(!0))})},c=u=>g=>{g.setTitle(o?"UNbookmark selected from custom sorting":"Custom sort: UNbookmark selected from sorting"),g.onClick(()=>{let f=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);f&&(u.forEach(x=>{f.unbookmarkFolderItem(x)}),f.saveDataAndUpdateBookmarkViews(!0))})};this.registerEvent(this.app.workspace.on("file-menu",(u,g,f,x)=>{if(!this.settings.customSortContextSubmenu)return;let _=b=>{let p;if(b&&(b.setTitle("Custom sort:"),b.setIcon("hashtag"),p=b.setSubmenu()),p||u.addSeparator(),(p!=null?p:u).addItem(n),p&&p.addSeparator(),this.settings.bookmarksContextMenus){let P=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);P&&(P.isBookmarkedForSorting(g)?(p!=null?p:u).addItem(s(g)):(p!=null?p:u).addItem(a(g)),(p!=null?p:u).addItem(l(g)),(p!=null?p:u).addItem(d(g)))}(p!=null?p:u).addItem(i)};o?_(void 0):u.addItem(_)})),this.registerEvent(this.app.workspace.on("files-menu",(u,g,f,x)=>{if(!this.settings.customSortContextSubmenu)return;let _=b=>{let p;b&&(b.setTitle("Custom sort:"),b.setIcon("hashtag"),p=b.setSubmenu()),p||u.addSeparator(),(p!=null?p:u).addItem(n),p&&p.addSeparator(),this.settings.bookmarksContextMenus&&D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference)&&((p!=null?p:u).addItem(m(g)),(p!=null?p:u).addItem(c(g))),(p!=null?p:u).addItem(i)};o?_(void 0):u.addItem(_)})),this.registerEvent(this.app.vault.on("rename",(u,g)=>{let f=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);f&&(f.updateSortingBookmarksAfterItemRenamed(u,g),f.saveDataAndUpdateBookmarkViews(!0))})),this.app.vault.on("delete",u=>{let g=D(r.app,r.settings.bookmarksGroupToConsumeAsOrderingReference);g&&(g.updateSortingBookmarksAfterItemDeleted(u),g.saveDataAndUpdateBookmarkViews(!0))})}uninstallFileExplorerPatchIfInstalled(){if(this.uninstallerOfFileExplorerPatch){try{this.uninstallerOfFileExplorerPatch()}catch(r){}this.uninstallerOfFileExplorerPatch=void 0}}registerPluginUnloadHandler(){let r=this;this.register(()=>{var n,i;r.uninstallFileExplorerPatchIfInstalled();let o=r.checkFileExplorerIsAvailableAndPatchable();o.v&&o.v.view&&((i=(n=o.v.view).requestSort)==null||i.call(n))})}registerCommands(){let r=this;this.addCommand({id:"enable-custom-sorting",name:"Enable and apply the custom sorting, (re)parsing the sorting configuration first. Sort-on.",callback:()=>{r.switchPluginStateTo(!0)}}),this.addCommand({id:"suspend-custom-sorting",name:"Suspend the custom sorting. Sort-off.",callback:()=>{r.switchPluginStateTo(!1)}})}initialize(){let r=this;this.app.workspace.onLayoutReady(()=>{setTimeout(()=>{r.delayedApplicationOfCustomSorting.apply(this)},r.settings.delayForInitialApplication)})}determineSortSpecForFolder(r,o){var i,a,s,l,d,m;o!=null||(o=Y(r));let n=(a=(i=this.sortSpecCache)==null?void 0:i.sortSpecByPath)==null?void 0:a[r];return n!=null||(n=(l=(s=this.sortSpecCache)==null?void 0:s.sortSpecByName)==null?void 0:l[o]),!n&&((d=this.sortSpecCache)!=null&&d.sortSpecByWildcard)&&(n=(m=this.sortSpecCache)==null?void 0:m.sortSpecByWildcard.folderMatch(r,o)),n}createProcessingContextForSorting(r){return{_mCache:this.app.metadataCache,bookmarksPluginInstance:r.grouping.byBookmarks||r.sorting.byBookmarks?D(this.app,this.settings.bookmarksGroupToConsumeAsOrderingReference,!1,!0):void 0,iconFolderPluginInstance:r.grouping.byIcon?Yt(this.app):void 0,plugin:this}}determineAndPrepareSortingDataForFolder(r){let o=this.determineSortSpecForFolder(r.path,r.name),n=Ot(o);if(Ko(n)){let i=D(this.app,this.settings.bookmarksGroupToConsumeAsOrderingReference,!1,!0);i!=null&&i.bookmarksIncludeItemsInFolder(r.path)||(o=null)}return{sortSpec:o,sortingAndGroupingStats:n}}orderedFolderItemsForBookmarking(r,o){var s,l;let n;this.settings.suspended||(n=this.determineSortSpecForFolder(r.path,r.name));let i=((l=(s=this.getFileExplorer().v)==null?void 0:s.view)==null?void 0:l.sortOrder)||sr,a=Ot(n);return pr(r,r.children,n,this.createProcessingContextForSorting(a),i)}onunload(){}onUserEnable(){}updateStatusBar(){if(this.statusBarItemEl){let r=!this.settings.suspended&&this.customSortAppliedAtLeastOnce?"ON":"OFF";this.statusBarItemEl.setText(`Custom sort:${r}`)}}async loadSettings(){let r=await this.loadData()||{},o=Object.keys(r).length===0;this.settings=Object.assign({},Nt,r),o&&(this.settings=Object.assign(this.settings,Qo))}async saveSettings(){await this.saveData(this.settings)}isThePluginStillInstalledAndEnabled(){var o,n,i,a,s,l;let r=(i=(n=(o=this==null?void 0:this.app)==null?void 0:o.plugins)==null?void 0:n.plugins)==null?void 0:i[ne];return!!(r&&r._loaded&&((l=(s=(a=this==null?void 0:this.app)==null?void 0:a.plugins)==null?void 0:s.enabledPlugins)!=null&&l.has(ne)))}setWatcherForDelayedFileExplorerView(r){var i,a;let o=this,n=(a=(i=r==null?void 0:r.view)==null?void 0:i.containerEl)==null?void 0:a.parentElement;if(n||(n=document.querySelector(".workspace")),n){let s=n,l=()=>s.querySelector('[data-type="file-explorer"] .nav-files-container');new MutationObserver((m,c)=>{l()&&(c.disconnect(),o.delayedApplicationOfCustomSorting(o.FROM_DOM_WATCHER))}).observe(n,{childList:!0,subtree:!1})}}delayedApplicationOfCustomSorting(r){if(!(this!=null&&this.isThePluginStillInstalledAndEnabled())){console.log(`${ne} v${this.manifest.version} - delayed handler skipped, plugin no longer active.`);return}if(!(this.settings.suspended||this.customSortAppliedAtLeastOnce))if(r)this.switchPluginStateTo(!0);else{let n=this.checkFileExplorerIsAvailableAndPatchable();n.e&&n.e.state===2?(this.logDeferredFileExplorerWatcherSetupInfo(),this.setWatcherForDelayedFileExplorerView(n.e.fileExplorerInDeferredState)):n.e?this.switchPluginStateTo(!0):this.switchPluginStateTo(!0)}}setRibbonIconToEnabled(){(0,T.setIcon)(this.ribbonIconEl,xt)}indexNoteBasename(){return this.indexNoteNameForFolderNotesDerivedFrom!==this.settings.indexNoteNameForFolderNotes&&(this.derivedIndexNoteNameForFolderNotes=Zt(this.settings.indexNoteNameForFolderNotes),this.indexNoteNameForFolderNotesDerivedFrom=this.settings.indexNoteNameForFolderNotes),this.derivedIndexNoteNameForFolderNotes}};
|
|
|
|
/* nosourcemap */ |